mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
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
This commit is contained in:
parent
ee9670b1ea
commit
789cf11d8d
2 changed files with 29 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue