Merge pull request #2368 from psychon/motif_hints

Add c.requests_no_titlebar based on motif hints
This commit is contained in:
Emmanuel Lepage Vallée 2018-10-06 22:00:03 -04:00 committed by GitHub
commit 768184d152
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 1 deletions

View File

@ -521,6 +521,7 @@ awful.rules.rules = {
-- @DOC_DIALOG_RULE@
-- Add titlebars to normal clients and dialogs
{ rule_any = {type = { "normal", "dialog" }
-- @DOC_CSD_TITLEBARS@
}, properties = { titlebars_enabled = true }
},

View File

@ -218,6 +218,15 @@ 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`
See `client.requests_no_titlebar` for more details.
]]
sections.DOC_BORDER = [[
 
]]

View File

@ -1040,6 +1040,38 @@ function client.dockable.set(c, value)
client.property.set(c, "dockable", value)
end
--- If the client requests not to be decorated with a titlebar.
--
-- The motif wm hints allow a client to request not to be decorated by the WM in
-- various ways. This property uses the motif MWM_DECOR_TITLE hint and
-- interprets it as the client (not) wanting a titlebar.
--
-- **Signal:**
--
-- * *property::requests_no_titlebar*
--
-- @property requests_no_titlebar
-- @param boolean Whether the client requests not to get a titlebar
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
if not decor then return false end
local result = not decor.title
if decor.all then
-- The "all" bit inverts the meaning of the other bits
result = not result
end
return result
end
capi.client.connect_signal("property::motif_wm_hints", function(c)
-- We cannot be sure that the property actually changes, but whatever
c:emit_signal("property::requests_no_titlebar")
end)
--- Get a client property.
--
-- This method is deprecated. It is now possible to use `c.value` directly.

View File

@ -582,7 +582,8 @@ end
-- @tab[opt] callbacks Callbacks to apply.
function rules.execute(c, props, callbacks)
-- This has to be done first, as it will impact geometry related props.
if props.titlebars_enabled then
if props.titlebars_enabled and (type(props.titlebars_enabled) ~= "function"
or props.titlebars_enabled(c,props)) then
c:emit_signal("request::titlebars", "rules", {properties=props})
end