From b4b007796cccbda6aabfc3b8898740b4fb760edb Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 25 Jan 2017 14:55:27 +0100 Subject: [PATCH] Initialise Lua later This moves Lua initialisation to the latest possible point, just before loading the configuration file. This requires to also move screen initialisation and parts of EWMH initialisation to a later point. Signed-off-by: Uli Schlachter --- awesome.c | 17 +++++++++-------- ewmh.c | 6 +++++- ewmh.h | 1 + 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/awesome.c b/awesome.c index 325b7842..7ac16293 100644 --- a/awesome.c +++ b/awesome.c @@ -564,10 +564,6 @@ main(int argc, char **argv) string_array_append(&searchpath, entry); } - /* init lua */ - luaA_init(&xdg, &searchpath); - string_array_wipe(&searchpath); - if (run_test) { bool success = true; @@ -704,10 +700,6 @@ main(int argc, char **argv) /* init atom cache */ atoms_init(globalconf.connection); - /* init screens information */ - screen_scan(); - - /* do this only for real screen */ ewmh_init(); systray_init(); @@ -758,6 +750,15 @@ main(int argc, char **argv) /* get the current wallpaper, from now on we are informed when it changes */ root_update_wallpaper(); + /* init lua */ + luaA_init(&xdg, &searchpath); + string_array_wipe(&searchpath); + + ewmh_init_lua(); + + /* init screens information */ + screen_scan(); + /* Parse and run configuration file */ if (!luaA_parserc(&xdg, confpath)) fatal("couldn't find any rc file"); diff --git a/ewmh.c b/ewmh.c index f14f32e9..ca862a1e 100644 --- a/ewmh.c +++ b/ewmh.c @@ -125,7 +125,6 @@ ewmh_client_update_frame_extents(lua_State *L) void ewmh_init(void) { - lua_State *L = globalconf_get_lua_State(); xcb_window_t father; xcb_screen_t *xscreen = globalconf.screen; xcb_atom_t atom[] = @@ -206,7 +205,12 @@ ewmh_init(void) i = getpid(); xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, father, _NET_WM_PID, XCB_ATOM_CARDINAL, 32, 1, &i); +} +void +ewmh_init_lua(void) +{ + lua_State *L = globalconf_get_lua_State(); luaA_class_connect_signal(L, &client_class, "focus", ewmh_update_net_active_window); luaA_class_connect_signal(L, &client_class, "unfocus", ewmh_update_net_active_window); diff --git a/ewmh.h b/ewmh.h index ad11d207..67e3f3ae 100644 --- a/ewmh.h +++ b/ewmh.h @@ -30,6 +30,7 @@ typedef struct client_t client_t; void ewmh_init(void); +void ewmh_init_lua(void); void ewmh_update_net_numbers_of_desktop(void); int ewmh_update_net_current_desktop(lua_State *); void ewmh_update_net_desktop_names(void);