From 789cf11d8d51a0f0070310a572cfe5c3cb927630 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 6 Oct 2018 18:11:23 -0400 Subject: [PATCH] titlebar: Emit `request::titlebars` from `awful.titlebar`. The toggle/show/hide function were incompatible with the current `rc.lua` is `titlebars_enabled` was removed from the rules because they were never created. This has always been the case but the introduction os `request::titlebars` in Awesome 4.0 allows to solve this longstanding issue. However until now it didn't. Fix #2419 --- lib/awful/rules.lua | 1 + lib/awful/titlebar.lua | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/lib/awful/rules.lua b/lib/awful/rules.lua index c652ede31..3af69bc97 100644 --- a/lib/awful/rules.lua +++ b/lib/awful/rules.lua @@ -584,6 +584,7 @@ function rules.execute(c, props, callbacks) -- This has to be done first, as it will impact geometry related props. if props.titlebars_enabled then c:emit_signal("request::titlebars", "rules", {properties=props}) + c._request_titlebars_called = true end -- Border width will also cause geometry related properties to fail diff --git a/lib/awful/titlebar.lua b/lib/awful/titlebar.lua index 969b4076b..d6230f9b3 100644 --- a/lib/awful/titlebar.lua +++ b/lib/awful/titlebar.lua @@ -453,6 +453,32 @@ local function get_titlebar_function(c, position) end end +--- Call `request::titlebars` to allow themes or rc.lua to create them even +-- when `titlebars_enabled` is not set in the rules. +-- @tparam client c The client. +-- @tparam[opt=false] boolean hide_all Hide all titlebars except `keep` +-- @tparam string keep Keep the titlebar at this position +-- @treturn boolean If the titlebars were loaded +local function load_titlebars(c, hide_all, keep) + if c._request_titlebars_called then return false end + + c:emit_signal("request::titlebars", "awful.titlebar", {}) + + if hide_all then + -- Don't bother checking if it has been created, `.hide` don't works + -- anyway. + for _, tb in ipairs {"top", "bottom", "left", "right"} do + if tb ~= keep then + titlebar.hide(c, tb) + end + end + end + + c._request_titlebars_called = true + + return true +end + --- Get a client's titlebar. -- @tparam client c The client for which a titlebar is wanted. -- @tparam[opt={}] table args A table with extra arguments for the titlebar. @@ -530,6 +556,7 @@ end -- "right", "top", "bottom". Default is "top". function titlebar.show(c, position) position = position or "top" + if load_titlebars(c, true, position) then return end local bars = all_titlebars[c] local data = bars and bars[position] local args = data and data.args @@ -551,6 +578,7 @@ end -- "right", "top", "bottom". Default is "top". function titlebar.toggle(c, position) position = position or "top" + if load_titlebars(c, true, position) then return end local _, size = get_titlebar_function(c, position)(c) if size == 0 then titlebar.show(c, position)