screen: Move the "added" signal from CAPI to Lua.

When the screens are created from the viewport in Lua, the signal is
sent too early and the DPI and outputs have not yet been added. This
cause the `connect_for_each_screen` callbacks to be called with a
partially initialized screen object. It also causes the drawables to be
repainted too early.

CAPI now emits "_added" and "awful.screen" takes care of emitting
"added".
This commit is contained in:
Emmanuel Lepage Vallee 2019-07-10 23:14:33 -04:00
parent 3e19251d14
commit aa76b11b81
3 changed files with 6 additions and 2 deletions

View File

@ -937,11 +937,12 @@ require("awful.screen.dpi")(screen, data)
-- Set the wallpaper(s) and create the bar(s) for new screens -- Set the wallpaper(s) and create the bar(s) for new screens
capi.screen.connect_signal("added", function(s) capi.screen.connect_signal("_added", function(s)
-- If it was emited from here when screens are created with fake_add, -- 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 -- the Lua code would not have an opportunity to polutate the screen
-- metadata. Thus, the DPI may be wrong when setting the wallpaper. -- metadata. Thus, the DPI may be wrong when setting the wallpaper.
if s._managed ~= "Lua" then if s._managed ~= "Lua" then
s:emit_signal("added")
s:emit_signal("request::desktop_decoration") s:emit_signal("request::desktop_decoration")
s:emit_signal("request::wallpaper") s:emit_signal("request::wallpaper")
end end

View File

@ -160,6 +160,9 @@ function module.create_screen_handler(viewport)
s:emit_signal("request::desktop_decoration") s:emit_signal("request::desktop_decoration")
s:emit_signal("request::wallpaper") s:emit_signal("request::wallpaper")
-- Will call all `connect_for_each_screen`.
s:emit_signal("added")
end end
function module.remove_screen_handler(viewport) function module.remove_screen_handler(viewport)

View File

@ -949,7 +949,7 @@ screen_added(lua_State *L, screen_t *screen)
screen->workarea = screen->geometry; screen->workarea = screen->geometry;
screen->valid = true; screen->valid = true;
luaA_object_push(L, screen); luaA_object_push(L, screen);
luaA_object_emit_signal(L, -1, "added", 0); luaA_object_emit_signal(L, -1, "_added", 0);
lua_pop(L, 1); lua_pop(L, 1);
} }