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 <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2017-01-25 14:55:27 +01:00
parent 95b1305613
commit b4b007796c
3 changed files with 15 additions and 9 deletions

View File

@ -564,10 +564,6 @@ main(int argc, char **argv)
string_array_append(&searchpath, entry); string_array_append(&searchpath, entry);
} }
/* init lua */
luaA_init(&xdg, &searchpath);
string_array_wipe(&searchpath);
if (run_test) if (run_test)
{ {
bool success = true; bool success = true;
@ -704,10 +700,6 @@ main(int argc, char **argv)
/* init atom cache */ /* init atom cache */
atoms_init(globalconf.connection); atoms_init(globalconf.connection);
/* init screens information */
screen_scan();
/* do this only for real screen */
ewmh_init(); ewmh_init();
systray_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 */ /* get the current wallpaper, from now on we are informed when it changes */
root_update_wallpaper(); 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 */ /* Parse and run configuration file */
if (!luaA_parserc(&xdg, confpath)) if (!luaA_parserc(&xdg, confpath))
fatal("couldn't find any rc file"); fatal("couldn't find any rc file");

6
ewmh.c
View File

@ -125,7 +125,6 @@ ewmh_client_update_frame_extents(lua_State *L)
void void
ewmh_init(void) ewmh_init(void)
{ {
lua_State *L = globalconf_get_lua_State();
xcb_window_t father; xcb_window_t father;
xcb_screen_t *xscreen = globalconf.screen; xcb_screen_t *xscreen = globalconf.screen;
xcb_atom_t atom[] = xcb_atom_t atom[] =
@ -206,7 +205,12 @@ ewmh_init(void)
i = getpid(); i = getpid();
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
father, _NET_WM_PID, XCB_ATOM_CARDINAL, 32, 1, &i); 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, "focus", ewmh_update_net_active_window);
luaA_class_connect_signal(L, &client_class, "unfocus", ewmh_update_net_active_window); luaA_class_connect_signal(L, &client_class, "unfocus", ewmh_update_net_active_window);

1
ewmh.h
View File

@ -30,6 +30,7 @@
typedef struct client_t client_t; typedef struct client_t client_t;
void ewmh_init(void); void ewmh_init(void);
void ewmh_init_lua(void);
void ewmh_update_net_numbers_of_desktop(void); void ewmh_update_net_numbers_of_desktop(void);
int ewmh_update_net_current_desktop(lua_State *); int ewmh_update_net_current_desktop(lua_State *);
void ewmh_update_net_desktop_names(void); void ewmh_update_net_desktop_names(void);