From 48d4a31b171498b00f38d5a0ac7dd82f7ec4a901 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 22 Aug 2018 13:22:51 +0200 Subject: [PATCH 1/4] awful.rules: Support titlebars_enabled being a function Signed-off-by: Uli Schlachter --- lib/awful/rules.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From fa1728d749d4af27794f10eb072ee4d8ba5e8aee Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 22 Aug 2018 13:23:20 +0200 Subject: [PATCH 2/4] Add c.requests_to_titlebar This property is based on Motif WM hints and checks if the client requests that it is not decorated with a titlebar. Signed-off-by: Uli Schlachter --- lib/awful/client.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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. From 9d41488e43bd9cc2824272df3026dc40a8a20da9 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 22 Aug 2018 13:25:18 +0200 Subject: [PATCH 3/4] awesomerc: Add comment mentioning c.requests_no_titlebar Signed-off-by: Uli Schlachter --- awesomerc.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/awesomerc.lua b/awesomerc.lua index 3d5d73d6..94a9de95 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -521,6 +521,10 @@ awful.rules.rules = { -- @DOC_DIALOG_RULE@ -- Add titlebars to normal clients and dialogs { rule_any = {type = { "normal", "dialog" } + -- If you want programs to be able to request no titlebars, use: + -- 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 }, properties = { titlebars_enabled = true } }, From 45430daf7f22724b89004afa0cd06a5f937ff51d Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 26 Aug 2018 19:26:19 +0200 Subject: [PATCH 4/4] rc.lua: Move Motif hints example to generated docs Signed-off-by: Uli Schlachter --- awesomerc.lua | 5 +---- docs/05-awesomerc.md.lua | 9 +++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index 94a9de95..10994c99 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -521,10 +521,7 @@ awful.rules.rules = { -- @DOC_DIALOG_RULE@ -- Add titlebars to normal clients and dialogs { rule_any = {type = { "normal", "dialog" } - -- If you want programs to be able to request no titlebars, use: - -- 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 + -- @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 = [[   ]]