diff --git a/docs/05-awesomerc.md.lua b/docs/05-awesomerc.md.lua index 674a364b..cfe52015 100644 --- a/docs/05-awesomerc.md.lua +++ b/docs/05-awesomerc.md.lua @@ -221,7 +221,7 @@ sections.DOC_TITLEBARS = [[ sections.DOC_CSD_TITLEBARS = [[ For client side decorations, clients might request no titlebars via Motif WM hints. To honor these hints, use: - `titlebars_enabled = function(c) return c.requests_no_titlebar end` + `titlebars_enabled = function(c) return not c.requests_no_titlebar end` See `client.requests_no_titlebar` for more details. ]] diff --git a/lib/awful/client.lua b/lib/awful/client.lua index f75270cf..28d66a92 100644 --- a/lib/awful/client.lua +++ b/lib/awful/client.lua @@ -1144,7 +1144,7 @@ function client.object.get_requests_no_titlebar(c) local hints = c.motif_wm_hints if not hints then return false end - local decor = hints.deocrations + local decor = hints.decorations if not decor then return false end local result = not decor.title diff --git a/tests/test-titlebar.lua b/tests/test-titlebar.lua index 38dd6413..869d8eab 100644 --- a/tests/test-titlebar.lua +++ b/tests/test-titlebar.lua @@ -3,10 +3,11 @@ local titlebar = require("awful.titlebar") local rules = require("awful.rules") local spawn = require("awful.spawn") -local tiny_client = {"lua", "-e", [[ +local tiny_client_code_template = [[ local Gtk, class = require('lgi').require('Gtk'), 'client' Gtk.init() window = Gtk.Window {default_width=100, default_height=100, title='title'} +%s window:set_wmclass(class, class) local app = Gtk.Application {} function app:on_activate() @@ -14,7 +15,13 @@ function app:on_activate() window:show_all() end app:run {''} -]]} +]] +local tiny_client = {"lua", "-e", string.format(tiny_client_code_template, "")} +local tiny_client_undecorated = {"lua", "-e", + string.format(tiny_client_code_template, [[ +window.decorated = false +]]) +} -- Use the test client props rules.rules = {} @@ -85,6 +92,67 @@ local steps = { c:kill() + 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) + + c:kill() + + 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) + + c:kill() + + 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) + + c:kill() + return true end, }