From b6423a7b4f0111f73690d2a99ca0433d30b5dd32 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Thu, 10 Oct 2013 20:38:21 +0200 Subject: [PATCH] wmaker: Moved variable Screen Count into the global namespace --- src/WindowMaker.h | 3 +++ src/defaults.c | 5 ++--- src/event.c | 9 ++++----- src/main.c | 6 ++---- src/screen.c | 7 +++---- src/shutdown.c | 5 ++--- src/startup.c | 25 ++++++++++++------------- 7 files changed, 28 insertions(+), 32 deletions(-) diff --git a/src/WindowMaker.h b/src/WindowMaker.h index e31c9c32..c861a7d9 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -481,6 +481,9 @@ extern struct wmaker_global_variables { } timestamp; + /* Screens related */ + int screen_count; + /* Workspace related */ struct { struct WWorkspace **array; /* data for the workspaces */ diff --git a/src/defaults.c b/src/defaults.c index b476c700..705142d2 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -75,7 +75,6 @@ extern WDDomain *WDWindowMaker; extern WDDomain *WDWindowAttributes; extern WDDomain *WDRootMenu; -extern int wScreenCount; extern WShortKey wKeyBindings[WKBD_LAST]; typedef struct _WDefaultEntry WDefaultEntry; @@ -995,7 +994,7 @@ void wDefaultsCheckDomains(void* arg) shared_dict = NULL; } - for (i = 0; i < wScreenCount; i++) { + for (i = 0; i < w_global.screen_count; i++) { scr = wScreenWithNumber(i); if (scr) wReadDefaults(scr, dict); @@ -1038,7 +1037,7 @@ void wDefaultsCheckDomains(void* arg) WMReleasePropList(WDWindowAttributes->dictionary); WDWindowAttributes->dictionary = dict; - for (i = 0; i < wScreenCount; i++) { + for (i = 0; i < w_global.screen_count; i++) { scr = wScreenWithNumber(i); if (scr) { wDefaultUpdateIcons(scr); diff --git a/src/event.c b/src/event.c index a69be0dc..780bab25 100644 --- a/src/event.c +++ b/src/event.c @@ -78,7 +78,6 @@ /******** Global Variables **********/ extern WShortKey wKeyBindings[WKBD_LAST]; -extern int wScreenCount; #define MOD_MASK wPreferences.modifier_mask @@ -1198,7 +1197,7 @@ static void handleXkbIndicatorStateNotify(XEvent *event) XkbStateRec staterec; int i; - for (i = 0; i < wScreenCount; i++) { + for (i = 0; i < w_global.screen_count; i++) { scr = wScreenWithNumber(i); wwin = scr->focused_window; if (wwin && wwin->flags.focused) { @@ -1697,17 +1696,17 @@ static void handleKeyPress(XEvent * event) break; case WKBD_SWITCH_SCREEN: - if (wScreenCount > 1) { + if (w_global.screen_count > 1) { WScreen *scr2; int i; /* find index of this screen */ - for (i = 0; i < wScreenCount; i++) { + for (i = 0; i < w_global.screen_count; i++) { if (wScreenWithNumber(i) == scr) break; } i++; - if (i >= wScreenCount) { + if (i >= w_global.screen_count) { i = 0; } scr2 = wScreenWithNumber(i); diff --git a/src/main.c b/src/main.c index 58623891..8924a5d3 100644 --- a/src/main.c +++ b/src/main.c @@ -79,8 +79,6 @@ int inotifyFD; int inotifyWD; #endif -int wScreenCount = 0; - struct WPreferences wPreferences; WShortKey wKeyBindings[WKBD_LAST]; @@ -423,7 +421,7 @@ noreturn void wAbort(Bool dumpCore) int i; WScreen *scr; - for (i = 0; i < wScreenCount; i++) { + for (i = 0; i < w_global.screen_count; i++) { scr = wScreenWithNumber(i); if (scr) RestoreDesktop(scr); @@ -792,7 +790,7 @@ static int real_main(int argc, char **argv) wXModifierInitialize(); StartUp(!multiHead); - if (wScreenCount == 1) + if (w_global.screen_count == 1) multiHead = False; execInitScript(); diff --git a/src/screen.c b/src/screen.c index 2ff3d9d4..18c76f50 100644 --- a/src/screen.c +++ b/src/screen.c @@ -70,7 +70,6 @@ |KeyPressMask|KeyReleaseMask) /**** Global variables ****/ -extern int wScreenCount; #ifdef KEEP_XKB_LOCK_STATUS extern int wXkbSupported; @@ -804,7 +803,7 @@ void wScreenRestoreState(WScreen * scr) make_keys(); - if (wScreenCount == 1) { + if (w_global.screen_count == 1) { path = wdefaultspathfordomain("WMState"); } else { char buf[16]; @@ -814,7 +813,7 @@ void wScreenRestoreState(WScreen * scr) w_global.session_state = WMReadPropListFromFile(path); wfree(path); - if (!w_global.session_state && wScreenCount > 1) { + if (!w_global.session_state && w_global.screen_count > 1) { path = wdefaultspathfordomain("WMState"); w_global.session_state = WMReadPropListFromFile(path); wfree(path); @@ -915,7 +914,7 @@ void wScreenSaveState(WScreen * scr) wMenuSaveState(scr); - if (wScreenCount == 1) { + if (w_global.screen_count == 1) { str = wdefaultspathfordomain("WMState"); } else { char buf[16]; diff --git a/src/shutdown.c b/src/shutdown.c index 5a822924..e6d3503b 100644 --- a/src/shutdown.c +++ b/src/shutdown.c @@ -38,7 +38,6 @@ #include "colormap.h" #include "shutdown.h" -extern int wScreenCount; static void wipeDesktop(WScreen * scr); @@ -68,7 +67,7 @@ void Shutdown(WShutdownMode mode) #ifdef HAVE_INOTIFY close(inotifyFD); #endif - for (i = 0; i < wScreenCount; i++) { + for (i = 0; i < w_global.screen_count; i++) { WScreen *scr; scr = wScreenWithNumber(i); @@ -89,7 +88,7 @@ void Shutdown(WShutdownMode mode) break; case WSRestartPreparationMode: - for (i = 0; i < wScreenCount; i++) { + for (i = 0; i < w_global.screen_count; i++) { WScreen *scr; #ifdef HAVE_INOTIFY diff --git a/src/startup.c b/src/startup.c index 8a229aa1..eaa8634c 100644 --- a/src/startup.c +++ b/src/startup.c @@ -89,7 +89,6 @@ extern WDDomain *WDWindowMaker; extern WDDomain *WDRootMenu; extern WDDomain *WDWindowAttributes; extern WShortKey wKeyBindings[WKBD_LAST]; -extern int wScreenCount; #ifdef SHAPE extern Bool wShapeSupported; @@ -371,7 +370,7 @@ wHackedGrabButton(unsigned int button, unsigned int modifiers, WScreen *wScreenWithNumber(int i) { - assert(i < wScreenCount); + assert(i < w_global.screen_count); return wScreen[i]; } @@ -380,13 +379,13 @@ WScreen *wScreenForRootWindow(Window window) { int i; - if (wScreenCount == 1) + if (w_global.screen_count == 1) return wScreen[0]; /* Since the number of heads will probably be small (normally 2), * it should be faster to use this than a hash table, because * of the overhead. */ - for (i = 0; i < wScreenCount; i++) + for (i = 0; i < w_global.screen_count; i++) if (wScreen[i]->root_win == window) return wScreen[i]; @@ -397,7 +396,7 @@ WScreen *wScreenForWindow(Window window) { XWindowAttributes attr; - if (wScreenCount == 1) + if (w_global.screen_count == 1) return wScreen[0]; if (XGetWindowAttributes(dpy, window, &attr)) @@ -656,7 +655,7 @@ void StartUp(Bool defaultScreenOnly) wScreen = wmalloc(sizeof(WScreen *) * max); - wScreenCount = 0; + w_global.screen_count = 0; /* Check if TIFF images are supported */ formats = RSupportedFileFormats(); @@ -672,25 +671,25 @@ void StartUp(Bool defaultScreenOnly) /* manage the screens */ for (j = 0; j < max; j++) { if (defaultScreenOnly || max == 1) { - wScreen[wScreenCount] = wScreenInit(DefaultScreen(dpy)); - if (!wScreen[wScreenCount]) { + wScreen[w_global.screen_count] = wScreenInit(DefaultScreen(dpy)); + if (!wScreen[w_global.screen_count]) { wfatal(_("it seems that there is already a window manager running")); Exit(1); } } else { - wScreen[wScreenCount] = wScreenInit(j); - if (!wScreen[wScreenCount]) { + wScreen[w_global.screen_count] = wScreenInit(j); + if (!wScreen[w_global.screen_count]) { wwarning(_("could not manage screen %i"), j); continue; } } - wScreenCount++; + w_global.screen_count++; } InitializeSwitchMenu(); /* initialize/restore state for the screens */ - for (j = 0; j < wScreenCount; j++) { + for (j = 0; j < w_global.screen_count; j++) { int lastDesktop; lastDesktop = wNETWMGetCurrentDesktopFromHint(wScreen[j]); @@ -743,7 +742,7 @@ void StartUp(Bool defaultScreenOnly) wSessionRestoreLastWorkspace(wScreen[j]); } - if (wScreenCount == 0) { + if (w_global.screen_count == 0) { wfatal(_("could not manage any screen")); Exit(1); }