From 90058211800fd45ee7cc8408278d3b200bdfd2e5 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Split up InitMenus Preparation for the removal of FirstScreen: Separate code that is executed for all screens from code that is executed for only the first screen. Signed-off-by: Tim Wiederhake --- src/menus.c | 22 ++++++++++++---------- src/menus.h | 1 + src/twm.c | 2 ++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/menus.c b/src/menus.c index 4b5dd62..1e78a1a 100644 --- a/src/menus.c +++ b/src/menus.c @@ -133,7 +133,6 @@ void InitMenus(void) { int i, j, k; - FuncKey *key; for (i = 0; i < MAX_BUTTONS + 1; i++) for (j = 0; j < NUM_CONTEXTS; j++) @@ -144,18 +143,21 @@ InitMenus(void) Scr->DefaultFunction.func = 0; Scr->WindowFunction.func = 0; +} - if (FirstScreen) { - for (key = Scr->FuncKeyRoot.next; key != NULL;) { - FuncKey *tmp = key; +void +InitMenusFirst(void) +{ + FuncKey *key; - free(key->name); - key = key->next; - free(tmp); - } - Scr->FuncKeyRoot.next = NULL; - } + for (key = Scr->FuncKeyRoot.next; key != NULL;) { + FuncKey *tmp = key; + free(key->name); + key = key->next; + free(tmp); + } + Scr->FuncKeyRoot.next = NULL; } /** diff --git a/src/menus.h b/src/menus.h index 5e188fc..b30d596 100644 --- a/src/menus.h +++ b/src/menus.h @@ -161,6 +161,7 @@ extern int MenuDepth; #define COLORMAP_DEFAULT "default" extern void InitMenus(void); +extern void InitMenusFirst(void); extern Bool AddFuncKey(char *name, int cont, int mods, int func, char *win_name, char *action); extern int CreateTitleButton(const char *name, int func, const char *action, diff --git a/src/twm.c b/src/twm.c index b2c6e66..548f468 100644 --- a/src/twm.c +++ b/src/twm.c @@ -532,6 +532,8 @@ main(int argc, char *argv[]) InitVariables(); InitMenus(); + if (FirstScreen) + InitMenusFirst(); /* Parse it once for each screen. */ ParseTwmrc(InitFile); -- cgit v1.2.3