From cd6998b18da55c77ca52effc9a35ba58a6442d84 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 10 Jul 2019 16:31:36 -0400 Subject: [PATCH] screen: Delay the request::wallpaper and desktop_decoration for the DPI. With this, there is plenty of palces where the DPI can be set before those signals are sent. This allows wallpaper with the proper DPI to work with screens created using `fake_add`. In turn, this will allow screen rules to control the DPI. In "the past", the DPI used for those handler was the native DPI of the screen with no opportunity to change it before hand. --- lib/awful/screen.lua | 20 ++++++++++++++++---- lib/awful/screen/dpi.lua | 3 +++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/awful/screen.lua b/lib/awful/screen.lua index db20b9ff..1f8a44cf 100644 --- a/lib/awful/screen.lua +++ b/lib/awful/screen.lua @@ -882,6 +882,8 @@ end -- function(viewport --[[, args]]) -- local geo = viewport.geometry -- local s = screen.fake_add(geo.x, geo.y, geo.width, geo.height) +-- s:emit_signal("request::desktop_decoration") +-- s:emit_signal("request::wallpaper") -- end -- -- If you implement this by hand, you must also implement handler for the @@ -934,9 +936,15 @@ end require("awful.screen.dpi")(screen, data) -- Set the wallpaper(s) and create the bar(s) for new screens + capi.screen.connect_signal("added", function(s) + -- If it was emited from here when screens are created with fake_add, + -- the Lua code would not have an opportunity to polutate the screen + -- metadata. Thus, the DPI may be wrong when setting the wallpaper. + --if capi.screen.automatic_factory then s:emit_signal("request::desktop_decoration") s:emit_signal("request::wallpaper") + --end end) -- Resize the wallpaper(s) @@ -948,15 +956,19 @@ 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) + if capi.screen.automatic_factory then + for s in capi.screen do + new_handler(s) + end 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) + if capi.screen.automatic_factory then + for s in capi.screen do + new_handler(s) + end end end) diff --git a/lib/awful/screen/dpi.lua b/lib/awful/screen/dpi.lua index cb582844..feaec470 100644 --- a/lib/awful/screen/dpi.lua +++ b/lib/awful/screen/dpi.lua @@ -156,6 +156,9 @@ function module.create_screen_handler(viewport) ) update_screen_viewport(s) + + --s:emit_signal("request::desktop_decoration") + --s:emit_signal("request::wallpaper") end function module.remove_screen_handler(viewport)