From 21a80871a53413d9a6c84ba7074334b684be59fb Mon Sep 17 00:00:00 2001 From: cnjhb Date: Fri, 27 Feb 2026 09:30:25 +0800 Subject: [PATCH] refactor: optimize globalconf initialization --- awesome.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/awesome.c b/awesome.c index c4fbbbe444..28f75a5f49 100644 --- a/awesome.c +++ b/awesome.c @@ -58,7 +58,15 @@ #include -awesome_t globalconf; +awesome_t globalconf = { + .keygrabber = LUA_REFNIL, + .mousegrabber = LUA_REFNIL, + .exit_code = EXIT_SUCCESS, + .focus = { + .need_update = true, + }, + .preferred_icon_size = 0, +}; /** argv used to run awesome */ static char **awesome_argv; @@ -582,9 +590,6 @@ main(int argc, char **argv) setvbuf(stdout, NULL, _IOLBF, 0); setvbuf(stderr, NULL, _IOLBF, 0); - globalconf.keygrabber = LUA_REFNIL; - globalconf.mousegrabber = LUA_REFNIL; - globalconf.exit_code = EXIT_SUCCESS; globalconf.api_level = awesome_default_api_level(); buffer_init(&globalconf.startup_errors); string_array_init(&searchpath); @@ -675,12 +680,6 @@ main(int argc, char **argv) sa.sa_flags = SA_NOCLDSTOP | SA_RESTART; sigaction(SIGCHLD, &sa, 0); - /* We have no clue where the input focus is right now */ - globalconf.focus.need_update = true; - - /* set the default preferred icon size */ - globalconf.preferred_icon_size = 0; - /* X stuff */ globalconf.connection = xcb_connect(NULL, &globalconf.default_screen); if(xcb_connection_has_error(globalconf.connection))