diff --git a/awesomerc.lua b/awesomerc.lua index 3d5d73d6..10994c99 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -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 } }, diff --git a/docs/05-awesomerc.md.lua b/docs/05-awesomerc.md.lua index dd336e8b..674a364b 100644 --- a/docs/05-awesomerc.md.lua +++ b/docs/05-awesomerc.md.lua @@ -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 = [[   ]] diff --git a/lib/awful/client.lua b/lib/awful/client.lua index 827c7375..be30a407 100644 --- a/lib/awful/client.lua +++ b/lib/awful/client.lua @@ -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. diff --git a/lib/awful/rules.lua b/lib/awful/rules.lua index c652ede3..6bf07d52 100644 --- a/lib/awful/rules.lua +++ b/lib/awful/rules.lua @@ -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