From ad84a2dc8f59e05502928c8d5d4ab5d92e22321b Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sun, 7 Dec 2014 17:10:15 +0100 Subject: [PATCH] wmaker: moved the variable 'process_workspacemap_event' to the global namespace The definition in the local header was not correct; it works because gcc is tolerant to this kind of errors but other compilers are not. The declaration was creating a local variable in each file that call header, and because it is not static gcc's linker will merge them. Other compilers will at best complain for duplicate symbol, and at worst silently duplicate the variable so it will not work as expected. The variable is now moved to the existing structure meant for global variables, so now the code is really clear about using a global variable instead of a static/local one. Took opportunity to add some missing 'static' attributes to some variables. Signed-off-by: Christophe CURIS --- src/WindowMaker.h | 7 +++++++ src/workspace.c | 2 +- src/wsmap.c | 14 +++++++------- src/wsmap.h | 2 -- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/WindowMaker.h b/src/WindowMaker.h index ce0a86c9..2d9ed1af 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -522,6 +522,13 @@ extern struct wmaker_global_variables { */ Bool ignore_workspace_change; + /* + * Process WorkspaceMap Event: + * this variable is set when the Workspace Map window is being displayed, + * it is mainly used to avoid re-opening another one at the same time + */ + Bool process_workspacemap_event; + #ifdef HAVE_INOTIFY struct { int fd_event_queue; /* Inotify's queue file descriptor */ diff --git a/src/workspace.c b/src/workspace.c index 165e3011..9a820574 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -476,7 +476,7 @@ void wWorkspaceForceChange(WScreen * scr, int workspace) if (workspace >= MAX_WORKSPACES || workspace < 0) return; - if (!wPreferences.disable_workspace_pager && !process_workspacemap_event) + if (!wPreferences.disable_workspace_pager && !w_global.process_workspacemap_event) wWorkspaceMapUpdate(scr); SendHelperMessage(scr, 'C', workspace + 1, NULL); diff --git a/src/wsmap.c b/src/wsmap.c index 244df94b..ee667f9f 100755 --- a/src/wsmap.c +++ b/src/wsmap.c @@ -46,9 +46,9 @@ static const int mini_workspace_per_line = 5; * will be 0 for workspaces number 0 to 9 * 1 for workspaces number 10 -> 19 */ -int wsmap_bulk_index; -WMPixmap *frame_bg_focused; -WMPixmap *frame_bg_unfocused; +static int wsmap_bulk_index; +static WMPixmap *frame_bg_focused; +static WMPixmap *frame_bg_unfocused; typedef struct { WScreen *scr; @@ -147,7 +147,7 @@ static void selected_workspace_callback(WMWidget *w, void *data) int workspace_id = atoi(WMGetButtonText(click_button)); wWorkspaceChange(wsmap->scr, workspace_id); - process_workspacemap_event = False; + w_global.process_workspacemap_event = False; } } @@ -482,8 +482,8 @@ static void handle_event(WWorkspaceMap *wsmap, W_WorkspaceMap *wsmap_array) ButtonMotionMask | ButtonReleaseMask | ButtonPressMask, GrabModeAsync, GrabModeAsync, WMWidgetXID(wsmap->win), None, CurrentTime); - process_workspacemap_event = True; - while (process_workspacemap_event) { + w_global.process_workspacemap_event = True; + while (w_global.process_workspacemap_event) { WMMaskEvent(dpy, KeyPressMask | KeyReleaseMask | ExposureMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask, &ev); @@ -496,7 +496,7 @@ static void handle_event(WWorkspaceMap *wsmap, W_WorkspaceMap *wsmap_array) if (ev.xkey.keycode == escKey || (wKeyBindings[WKBD_WORKSPACEMAP].keycode != 0 && wKeyBindings[WKBD_WORKSPACEMAP].keycode == ev.xkey.keycode && wKeyBindings[WKBD_WORKSPACEMAP].modifier == modifiers)) { - process_workspacemap_event = False; + w_global.process_workspacemap_event = False; } else { KeySym ks; int bulk_id; diff --git a/src/wsmap.h b/src/wsmap.h index 2133bd52..27a45cc4 100644 --- a/src/wsmap.h +++ b/src/wsmap.h @@ -20,8 +20,6 @@ #ifndef WSMAP_H #define WSMAP_H -Bool process_workspacemap_event; - void wWorkspaceMapUpdate(WScreen *scr); void StartWorkspaceMap(WScreen *scr);