2018-10-07 00:19:19 +02:00
|
|
|
local runner = require("_runner")
|
|
|
|
local titlebar = require("awful.titlebar")
|
2019-10-07 01:24:56 +02:00
|
|
|
local rules = require("ruled.client")
|
2018-10-07 00:19:19 +02:00
|
|
|
local spawn = require("awful.spawn")
|
2019-10-07 01:24:56 +02:00
|
|
|
local gdebug = require("gears.debug")
|
2021-10-26 06:30:09 +02:00
|
|
|
local textbox = require("wibox.widget.textbox")
|
2018-10-07 00:19:19 +02:00
|
|
|
|
2021-03-08 16:25:54 +01:00
|
|
|
local lua_executable = os.getenv("LUA")
|
2021-03-06 19:48:32 +01:00
|
|
|
if lua_executable == nil or lua_executable == "" then
|
|
|
|
lua_executable = "lua"
|
|
|
|
end
|
|
|
|
|
2018-11-12 09:19:24 +01:00
|
|
|
local tiny_client_code_template = [[
|
2019-09-30 04:19:41 +02:00
|
|
|
pcall(require, 'luarocks.loader')
|
2018-10-07 00:19:19 +02:00
|
|
|
local Gtk, class = require('lgi').require('Gtk'), 'client'
|
|
|
|
Gtk.init()
|
|
|
|
window = Gtk.Window {default_width=100, default_height=100, title='title'}
|
2018-11-12 09:19:24 +01:00
|
|
|
%s
|
2018-10-07 00:19:19 +02:00
|
|
|
window:set_wmclass(class, class)
|
|
|
|
local app = Gtk.Application {}
|
2021-10-26 06:30:09 +02:00
|
|
|
window:show_all()
|
|
|
|
Gtk:main{...}
|
2018-10-07 00:19:19 +02:00
|
|
|
app:run {''}
|
2018-11-12 09:19:24 +01:00
|
|
|
]]
|
2021-03-06 19:48:32 +01:00
|
|
|
local tiny_client = { lua_executable, "-e", string.format(tiny_client_code_template, "") }
|
|
|
|
local tiny_client_undecorated = { lua_executable, "-e",
|
2018-11-12 09:19:24 +01:00
|
|
|
string.format(tiny_client_code_template, [[
|
|
|
|
window.decorated = false
|
|
|
|
]])
|
|
|
|
}
|
2018-10-07 00:19:19 +02:00
|
|
|
|
2021-10-29 05:26:33 +02:00
|
|
|
local found_font, events, next_pos = nil, {}, {}
|
2021-10-26 06:30:09 +02:00
|
|
|
|
2018-10-07 00:19:19 +02:00
|
|
|
-- Use the test client props
|
2019-10-07 01:24:56 +02:00
|
|
|
local dep = gdebug.deprecate
|
|
|
|
gdebug.deprecate = function() end
|
2018-10-07 00:19:19 +02:00
|
|
|
rules.rules = {}
|
2019-10-07 01:24:56 +02:00
|
|
|
gdebug.deprecate = dep
|
2018-10-07 00:19:19 +02:00
|
|
|
|
2021-10-26 06:30:09 +02:00
|
|
|
local function kill_client(c)
|
|
|
|
-- Make sure the process finishes. Just `c:kill()` only
|
|
|
|
-- closes the window. Adding some handlers to the GTK "app"
|
|
|
|
-- created some unwanted side effects in the CI.
|
|
|
|
awesome.kill(c.pid, 9)
|
|
|
|
end
|
|
|
|
|
2021-10-29 05:26:33 +02:00
|
|
|
local function click()
|
|
|
|
local x, y= next_pos.x, next_pos.y
|
|
|
|
mouse.coords{x=x, y=y}
|
|
|
|
assert(mouse.coords().x == x and mouse.coords().y == y)
|
|
|
|
root.fake_input("button_press", 1)
|
|
|
|
awesome.sync()
|
|
|
|
root.fake_input("button_release", 1)
|
|
|
|
awesome.sync()
|
|
|
|
next_pos = nil
|
|
|
|
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2018-10-07 00:19:19 +02:00
|
|
|
-- Too bad there's no way to disconnect the rc.lua request::titlebars function
|
|
|
|
|
|
|
|
local steps = {
|
|
|
|
function()
|
|
|
|
assert(#client.get() == 0)
|
|
|
|
spawn(tiny_client)
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
function()
|
|
|
|
if #client.get() ~= 1 then return end
|
|
|
|
|
|
|
|
local c = client.get()[1]
|
|
|
|
|
|
|
|
-- The rules don't set any borders nor enable the titlebar
|
|
|
|
assert(not c._request_titlebars_called)
|
|
|
|
assert(c.width == 100 and c.height == 100)
|
|
|
|
|
|
|
|
-- Should create the top titlebar
|
|
|
|
titlebar.toggle(c, "top")
|
|
|
|
|
|
|
|
assert(c._request_titlebars_called)
|
|
|
|
|
|
|
|
local h = c.height
|
|
|
|
assert(h > 100)
|
|
|
|
|
|
|
|
-- Should do nothing, there is no titlebar at the bottom by default
|
|
|
|
titlebar.toggle(c, "bottom")
|
|
|
|
assert(h == c.height)
|
|
|
|
|
|
|
|
-- Should hide the titlebar
|
|
|
|
titlebar.toggle(c, "top")
|
|
|
|
assert(c.height == 100)
|
|
|
|
|
2021-10-26 06:30:09 +02:00
|
|
|
kill_client(c)
|
2018-10-07 00:19:19 +02:00
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
function()
|
|
|
|
if #client.get() ~= 0 then return end
|
|
|
|
|
|
|
|
spawn(tiny_client, {titlebars_enabled=true})
|
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
function()
|
|
|
|
if #client.get() ~= 1 then return end
|
|
|
|
|
|
|
|
local c = client.get()[1]
|
|
|
|
|
|
|
|
local h = c.height
|
|
|
|
assert(c.width == 100 and h > 100)
|
|
|
|
assert(c._request_titlebars_called)
|
|
|
|
|
|
|
|
titlebar.hide(c, "top")
|
|
|
|
|
|
|
|
assert(c.width == 100 and c.height == 100)
|
|
|
|
|
|
|
|
titlebar.hide(c, "top")
|
|
|
|
|
|
|
|
assert(c.width == 100 and c.height == 100)
|
|
|
|
titlebar.show(c, "top")
|
|
|
|
|
|
|
|
assert(c.width == 100 and c.height == h)
|
|
|
|
|
2021-10-26 06:30:09 +02:00
|
|
|
kill_client(c)
|
2018-10-07 00:19:19 +02:00
|
|
|
|
2018-11-12 09:19:24 +01:00
|
|
|
return true
|
|
|
|
end,
|
|
|
|
function()
|
|
|
|
if #client.get() ~= 0 then return end
|
|
|
|
|
|
|
|
spawn(tiny_client_undecorated, {titlebars_enabled=true})
|
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
function()
|
|
|
|
if #client.get() ~= 1 then return end
|
|
|
|
|
|
|
|
local c = client.get()[1]
|
|
|
|
|
|
|
|
assert(c.width == 100 and c.height > 100)
|
|
|
|
assert(c._request_titlebars_called)
|
|
|
|
|
2021-10-26 06:30:09 +02:00
|
|
|
kill_client(c)
|
2018-11-12 09:19:24 +01:00
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
function()
|
|
|
|
if #client.get() ~= 0 then return end
|
|
|
|
|
|
|
|
spawn(tiny_client, {titlebars_enabled=function(c)
|
|
|
|
return not c.requests_no_titlebar
|
|
|
|
end})
|
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
function()
|
|
|
|
if #client.get() ~= 1 then return end
|
|
|
|
|
|
|
|
local c = client.get()[1]
|
|
|
|
|
|
|
|
assert(c.width == 100 and c.height > 100)
|
|
|
|
assert(c._request_titlebars_called)
|
|
|
|
|
2021-10-26 06:30:09 +02:00
|
|
|
kill_client(c)
|
2018-11-12 09:19:24 +01:00
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
function()
|
|
|
|
if #client.get() ~= 0 then return end
|
|
|
|
|
|
|
|
spawn(tiny_client_undecorated, {titlebars_enabled=function(c)
|
|
|
|
return not c.requests_no_titlebar
|
|
|
|
end})
|
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
function()
|
|
|
|
if #client.get() ~= 1 then return end
|
|
|
|
|
|
|
|
local c = client.get()[1]
|
|
|
|
|
|
|
|
assert(not c._request_titlebars_called)
|
|
|
|
assert(c.width == 100 and c.height == 100)
|
|
|
|
|
2021-10-26 06:30:09 +02:00
|
|
|
function textbox:set_font(value)
|
|
|
|
found_font = value
|
|
|
|
end
|
|
|
|
|
|
|
|
local args = {size = 40, font = "sans 10", position = "bottom"}
|
|
|
|
titlebar(c, args).widget = titlebar.widget.titlewidget(c)
|
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
function()
|
|
|
|
local c = client.get()[1]
|
|
|
|
|
|
|
|
assert(found_font == "sans 10")
|
|
|
|
|
2021-10-29 05:26:33 +02:00
|
|
|
-- Test the events.
|
|
|
|
for _, event in ipairs { "button::press", "button::release", "mouse::move" } do
|
|
|
|
c:connect_signal(event, function()
|
|
|
|
table.insert(events, event)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
next_pos = { x = c:geometry().x + 5, y = c:geometry().y + 5 }
|
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
click,
|
|
|
|
function()
|
|
|
|
if #events == 0 then return end
|
|
|
|
|
|
|
|
events = {}
|
|
|
|
|
|
|
|
local c = client.get()[1]
|
|
|
|
|
|
|
|
next_pos = { x = c:geometry().x + 5, y = c:geometry().y + c:geometry().height - 5 }
|
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
click,
|
|
|
|
function()
|
|
|
|
if #events == 0 then return end
|
|
|
|
|
|
|
|
local c = client.get()[1]
|
|
|
|
|
|
|
|
next_pos = {
|
|
|
|
x = c:geometry().x + c:geometry().width/2,
|
|
|
|
y = c:geometry().y + c:geometry().height/2
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
click,
|
|
|
|
function()
|
|
|
|
if #events == 0 then return end
|
|
|
|
|
|
|
|
local c = client.get()[1]
|
|
|
|
|
2021-10-26 06:30:09 +02:00
|
|
|
kill_client(c)
|
|
|
|
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
function()
|
|
|
|
if #client.get() > 0 then return end
|
2018-11-12 09:19:24 +01:00
|
|
|
|
2018-10-07 00:19:19 +02:00
|
|
|
return true
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
|
|
|
runner.run_steps(steps)
|
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|