From 93c6222da4efa1114dc8eaa47dc2c2d7b483a9db Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 27 Dec 2018 02:02:52 -0500 Subject: [PATCH] screen: Add two new requests. * Add a request to handle the wallpaper when a screen is added or resized. * Add a request for screen decorations such as bars or gizmos when a screen is added. Both are also sent when a new handler is connected. --- lib/awful/screen.lua | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/lib/awful/screen.lua b/lib/awful/screen.lua index 89c0acc5e..a998a467a 100644 --- a/lib/awful/screen.lua +++ b/lib/awful/screen.lua @@ -602,6 +602,54 @@ function screen.object.set_dpi(s, dpi) s.data.dpi = dpi end +--- Emitted when a new screen is added. +-- +-- The handler(s) of this signal are responsible of adding elements such as +-- bars, docks or other elements to a screen. The signal is emitted when a +-- screen is added, including during startup. +-- +-- The only default implementation is the one provided by `rc.lua`. +-- +-- @signal request::desktop_decoration +-- @tparam screen s The screen object. + +--- Emitted when a new screen needs a wallpaper. +-- +-- The handler(s) of this signal are responsible to set the wallpaper. The +-- signal is emitted when a screen is added (including at startup), when its +-- DPI changes or when its geometry changes. +-- +-- The only default implementation is the one provided by `rc.lua`. +-- +-- @signal request::wallpaper +-- @tparam screen s The screen object. + +-- Set the wallpaper(s) and create the bar(s) for new screens +capi.screen.connect_signal("added", function(s) + s:emit_signal("request::desktop_decoration") + s:emit_signal("request::wallpaper") +end) + +-- Resize the wallpaper(s) +for _, prop in ipairs {"geometry", "dpi" } do + capi.screen.connect_signal("property::"..prop, function(s) + s:emit_signal("request::wallpaper") + end) +end + +-- Create the bar for existing screens when an handler is added +capi.screen.connect_signal("request::desktop_decoration::connected", function(new_handler) + for s in capi.screen do + new_handler(s) + end +end) + +-- Set the wallpaper when an handler is added. +capi.screen.connect_signal("request::wallpaper::connected", function(new_handler) + for s in capi.screen do + new_handler(s) + end +end) --- When the tag history changed. -- @signal tag::history::update