From ec91b9f68e192d1e07e63198ceec708425de5f04 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sun, 29 Sep 2013 13:22:58 +0200 Subject: [PATCH] wmaker: Moved definition of X Contexts into the global variables structure --- src/WindowMaker.h | 7 +++++++ src/appicon.c | 3 +-- src/application.c | 12 ++++-------- src/client.c | 5 +---- src/dock.c | 5 +---- src/event.c | 13 ++++++------- src/main.c | 3 --- src/menu.c | 7 ++----- src/stacking.c | 8 +++----- src/startup.c | 9 +++------ src/wcore.c | 8 +++----- src/window.c | 11 ++++------- 12 files changed, 35 insertions(+), 56 deletions(-) diff --git a/src/WindowMaker.h b/src/WindowMaker.h index cc4dc06c..36d52f54 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -522,6 +522,13 @@ extern struct wmaker_global_variables { } atom; + /* X Contexts */ + struct { + XContext client_win; + XContext app_win; + XContext stack; + } context; + } w_global; extern unsigned int ValidModMask; diff --git a/src/appicon.c b/src/appicon.c index 63005594..e78ea739 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -62,7 +62,6 @@ /**** Global variables ****/ extern WDDomain *WDWindowAttributes; -extern XContext wWinContext; #define MOD_MASK wPreferences.modifier_mask #define ICON_SIZE wPreferences.icon_size @@ -1221,7 +1220,7 @@ WAppIcon *wAppIconFor(Window window) if (window == None) return NULL; - if (XFindContext(dpy, window, wWinContext, (XPointer *) & desc) == XCNOENT) + if (XFindContext(dpy, window, w_global.context.client_win, (XPointer *) & desc) == XCNOENT) return NULL; if (desc->parent_type == WCLASS_APPICON || desc->parent_type == WCLASS_DOCK_ICON) diff --git a/src/application.c b/src/application.c index 1bb08901..a5063ba5 100644 --- a/src/application.c +++ b/src/application.c @@ -37,10 +37,6 @@ #include "dock.h" #include "defaults.h" -/******** Global variables ********/ - -extern XContext wAppWinContext; -extern XContext wWinContext; /******** Local variables ********/ @@ -73,7 +69,7 @@ WApplication *wApplicationOf(Window window) if (window == None) return NULL; - if (XFindContext(dpy, window, wAppWinContext, (XPointer *) & wapp) != XCSUCCESS) + if (XFindContext(dpy, window, w_global.context.app_win, (XPointer *) & wapp) != XCSUCCESS) return NULL; return wapp; } @@ -140,7 +136,7 @@ WApplication *wApplicationCreate(WWindow * wwin) wapp->flags.emulated = WFLAGP(wapp->main_window_desc, emulate_appicon); /* application descriptor */ - XSaveContext(dpy, main_window, wAppWinContext, (XPointer) wapp); + XSaveContext(dpy, main_window, w_global.context.app_win, (XPointer) wapp); create_appicon_for_application(wapp, wwin); @@ -183,7 +179,7 @@ void wApplicationDestroy(WApplication * wapp) wapp->prev->next = wapp->next; } - XDeleteContext(dpy, wapp->main_window, wAppWinContext); + XDeleteContext(dpy, wapp->main_window, w_global.context.app_win); wAppMenuDestroy(wapp->menu); /* Remove application icon */ @@ -195,7 +191,7 @@ void wApplicationDestroy(WApplication * wapp) if (wwin) { /* undelete client window context that was deleted in * wWindowDestroy */ - XSaveContext(dpy, wwin->client_win, wWinContext, (XPointer) & wwin->client_descriptor); + XSaveContext(dpy, wwin->client_win, w_global.context.client_win, (XPointer) & wwin->client_descriptor); } wfree(wapp); } diff --git a/src/client.c b/src/client.c index 2b04b6a1..6ec7458c 100644 --- a/src/client.c +++ b/src/client.c @@ -46,9 +46,6 @@ /****** Global Variables ******/ -/* contexts */ -extern XContext wWinContext; - #ifdef SHAPE extern Bool wShapeSupported; #endif @@ -191,7 +188,7 @@ void wClientConfigure(WWindow * wwin, XConfigureRequestEvent * xcre) WWindow *sibling; if ((xcre->value_mask & CWSibling) && - (XFindContext(dpy, xcre->above, wWinContext, (XPointer *) & desc) == XCSUCCESS) + (XFindContext(dpy, xcre->above, w_global.context.client_win, (XPointer *) & desc) == XCSUCCESS) && (desc->parent_type == WCLASS_WINDOW)) { sibling = desc->parent; xwc.sibling = sibling->frame->core->window; diff --git a/src/dock.c b/src/dock.c index fae31be2..f1ee0326 100644 --- a/src/dock.c +++ b/src/dock.c @@ -65,9 +65,6 @@ #define CLIP_IDLE 0 #define CLIP_FORWARD 2 -/**** Global variables ****/ -extern XContext wWinContext; - #define MOD_MASK wPreferences.modifier_mask #define ICON_SIZE wPreferences.icon_size @@ -4050,7 +4047,7 @@ static void clipLeave(WDock *dock) return; if (XCheckTypedEvent(dpy, EnterNotify, &event) != False) { - if (XFindContext(dpy, event.xcrossing.window, wWinContext, + if (XFindContext(dpy, event.xcrossing.window, w_global.context.client_win, (XPointer *) & desc) != XCNOENT && desc && desc->parent_type == WCLASS_DOCK_ICON && ((WAppIcon *) desc->parent)->dock == dock) { diff --git a/src/event.c b/src/event.c index bd84810e..c4e8a8a7 100644 --- a/src/event.c +++ b/src/event.c @@ -77,7 +77,6 @@ #include "switchmenu.h" /******** Global Variables **********/ -extern XContext wWinContext; extern XContext wVEdgeContext; extern WShortKey wKeyBindings[WKBD_LAST]; @@ -702,7 +701,7 @@ static void handleExpose(XEvent * event) while (XCheckTypedWindowEvent(dpy, event->xexpose.window, Expose, &ev)) ; - if (XFindContext(dpy, event->xexpose.window, wWinContext, (XPointer *) & desc) == XCNOENT) { + if (XFindContext(dpy, event->xexpose.window, w_global.context.client_win, (XPointer *) & desc) == XCNOENT) { return; } @@ -769,8 +768,8 @@ static void handleButtonPress(XEvent * event) } desc = NULL; - if (XFindContext(dpy, event->xbutton.subwindow, wWinContext, (XPointer *) & desc) == XCNOENT) { - if (XFindContext(dpy, event->xbutton.window, wWinContext, (XPointer *) & desc) == XCNOENT) { + if (XFindContext(dpy, event->xbutton.subwindow, w_global.context.client_win, (XPointer *) & desc) == XCNOENT) { + if (XFindContext(dpy, event->xbutton.window, w_global.context.client_win, (XPointer *) & desc) == XCNOENT) { return; } } @@ -1034,7 +1033,7 @@ static void handleClientMessage(XEvent * event) * For when the icon frame gets a ClientMessage * that should have gone to the icon_window. */ - if (XFindContext(dpy, event->xbutton.window, wWinContext, (XPointer *) & desc) != XCNOENT) { + if (XFindContext(dpy, event->xbutton.window, w_global.context.client_win, (XPointer *) & desc) != XCNOENT) { struct WIcon *icon = NULL; if (desc->parent_type == WCLASS_MINIWINDOW) { @@ -1084,7 +1083,7 @@ static void handleEnterNotify(XEvent * event) } } - if (XFindContext(dpy, event->xcrossing.window, wWinContext, (XPointer *) & desc) != XCNOENT) { + if (XFindContext(dpy, event->xcrossing.window, w_global.context.client_win, (XPointer *) & desc) != XCNOENT) { if (desc->handle_enternotify) (*desc->handle_enternotify) (desc, event); } @@ -1148,7 +1147,7 @@ static void handleLeaveNotify(XEvent * event) { WObjDescriptor *desc = NULL; - if (XFindContext(dpy, event->xcrossing.window, wWinContext, (XPointer *) & desc) != XCNOENT) { + if (XFindContext(dpy, event->xcrossing.window, w_global.context.client_win, (XPointer *) & desc) != XCNOENT) { if (desc->handle_leavenotify) (*desc->handle_leavenotify) (desc, event); } diff --git a/src/main.c b/src/main.c index 81917ef0..28536ea8 100644 --- a/src/main.c +++ b/src/main.c @@ -91,9 +91,6 @@ WDDomain *WDWindowAttributes = NULL; WDDomain *WDRootMenu = NULL; /* XContexts */ -XContext wWinContext; -XContext wAppWinContext; -XContext wStackContext; XContext wVEdgeContext; #ifdef SHAPE diff --git a/src/menu.c b/src/menu.c index a3f177df..de1630b0 100644 --- a/src/menu.c +++ b/src/menu.c @@ -45,9 +45,6 @@ #include "rootmenu.h" #include "switchmenu.h" -/****** Global Variables ******/ - -extern XContext wWinContext; #define MOD_MASK wPreferences.modifier_mask @@ -1276,7 +1273,7 @@ static WMenu *findMenu(WScreen * scr, int *x_ret, int *y_ret) if (win == None) return NULL; - if (XFindContext(dpy, win, wWinContext, (XPointer *) & desc) == XCNOENT) + if (XFindContext(dpy, win, w_global.context.client_win, (XPointer *) & desc) == XCNOENT) return NULL; if (desc->parent_type == WCLASS_MENU) { @@ -1398,7 +1395,7 @@ WMenu *wMenuUnderPointer(WScreen * screen) if (win == None) return NULL; - if (XFindContext(dpy, win, wWinContext, (XPointer *) & desc) == XCNOENT) + if (XFindContext(dpy, win, w_global.context.client_win, (XPointer *) & desc) == XCNOENT) return NULL; if (desc->parent_type == WCLASS_MENU) diff --git a/src/stacking.c b/src/stacking.c index 4a773406..d7daf179 100644 --- a/src/stacking.c +++ b/src/stacking.c @@ -35,8 +35,6 @@ #include "stacking.h" #include "workspace.h" -/*** Global Variables ***/ -extern XContext wStackContext; static void notifyStackChange(WCoreWindow * frame, char *detail) { @@ -77,7 +75,7 @@ void RemakeStackList(WScreen * scr) /* verify list integrity */ c = 0; for (i = 0; i < nwindows; i++) { - if (XFindContext(dpy, windows[i], wStackContext, (XPointer *) & frame) + if (XFindContext(dpy, windows[i], w_global.context.stack, (XPointer *) & frame) == XCNOENT) { continue; } @@ -404,7 +402,7 @@ void AddToStackList(WCoreWindow * frame) WCoreWindow *trans = NULL; frame->screen_ptr->window_count++; - XSaveContext(dpy, frame->window, wStackContext, (XPointer) frame); + XSaveContext(dpy, frame->window, w_global.context.stack, (XPointer) frame); curtop = WMGetFromBag(scr->stacking_list, index); /* first window in this level */ @@ -560,7 +558,7 @@ void RemoveFromStackList(WCoreWindow * frame) { int index = frame->stacking->window_level; - if (XDeleteContext(dpy, frame->window, wStackContext) == XCNOENT) { + if (XDeleteContext(dpy, frame->window, w_global.context.stack) == XCNOENT) { wwarning("RemoveFromStackingList(): window not in list "); return; } diff --git a/src/startup.c b/src/startup.c index aade6d6c..56213e16 100644 --- a/src/startup.c +++ b/src/startup.c @@ -102,9 +102,6 @@ extern int wXkbEventBase; #endif /* contexts */ -extern XContext wWinContext; -extern XContext wAppWinContext; -extern XContext wStackContext; extern XContext wVEdgeContext; #ifndef HAVE_INOTIFY @@ -472,9 +469,9 @@ void StartUp(Bool defaultScreenOnly) memset(&wKeyBindings, 0, sizeof(wKeyBindings)); - wWinContext = XUniqueContext(); - wAppWinContext = XUniqueContext(); - wStackContext = XUniqueContext(); + w_global.context.client_win = XUniqueContext(); + w_global.context.app_win = XUniqueContext(); + w_global.context.stack = XUniqueContext(); wVEdgeContext = XUniqueContext(); /* _XA_VERSION = XInternAtom(dpy, "VERSION", False); */ diff --git a/src/wcore.c b/src/wcore.c index 4b79fdcf..d04d0932 100644 --- a/src/wcore.c +++ b/src/wcore.c @@ -29,8 +29,6 @@ #include "WindowMaker.h" #include "wcore.h" -/****** Global Variables ******/ -extern XContext wWinContext; /*---------------------------------------------------------------------- * wCoreCreateTopLevel-- @@ -72,7 +70,7 @@ WCoreWindow *wCoreCreateTopLevel(WScreen *screen, int x, int y, int width, int h core->descriptor.self = core; XClearWindow(dpy, core->window); - XSaveContext(dpy, core->window, wWinContext, (XPointer) & core->descriptor); + XSaveContext(dpy, core->window, w_global.context.client_win, (XPointer) & core->descriptor); return core; } @@ -116,7 +114,7 @@ WCoreWindow *wCoreCreate(WCoreWindow *parent, int x, int y, int width, int heigh core->screen_ptr = parent->screen_ptr; core->descriptor.self = core; - XSaveContext(dpy, core->window, wWinContext, (XPointer) & core->descriptor); + XSaveContext(dpy, core->window, w_global.context.client_win, (XPointer) & core->descriptor); return core; } @@ -125,7 +123,7 @@ void wCoreDestroy(WCoreWindow * core) if (core->stacking) wfree(core->stacking); - XDeleteContext(dpy, core->window, wWinContext); + XDeleteContext(dpy, core->window, w_global.context.client_win); XDestroyWindow(dpy, core->window); wfree(core); } diff --git a/src/window.c b/src/window.c index 789159aa..2063a5c8 100644 --- a/src/window.c +++ b/src/window.c @@ -79,9 +79,6 @@ extern WShortKey wKeyBindings[WKBD_LAST]; extern Bool wShapeSupported; #endif -/* contexts */ -extern XContext wWinContext; - /***** Local Stuff *****/ static WWindowState *windowState = NULL; static FocusMode getFocusMode(WWindow *wwin); @@ -146,7 +143,7 @@ WWindow *wWindowFor(Window window) if (window == None) return NULL; - if (XFindContext(dpy, window, wWinContext, (XPointer *) & desc) == XCNOENT) + if (XFindContext(dpy, window, w_global.context.client_win, (XPointer *) & desc) == XCNOENT) return NULL; if (desc->parent_type == WCLASS_WINDOW) @@ -226,7 +223,7 @@ void wWindowDestroy(WWindow *wwin) if (wwin->cmap_windows) XFree(wwin->cmap_windows); - XDeleteContext(dpy, wwin->client_win, wWinContext); + XDeleteContext(dpy, wwin->client_win, w_global.context.client_win); if (wwin->frame) wFrameWindowDestroy(wwin->frame); @@ -621,7 +618,7 @@ WWindow *wManageWindow(WScreen *scr, Window window) else if (!wFetchName(dpy, window, &title)) title = NULL; - XSaveContext(dpy, window, wWinContext, (XPointer) & wwin->client_descriptor); + XSaveContext(dpy, window, w_global.context.client_win, (XPointer) & wwin->client_descriptor); #ifdef SHAPE if (wShapeSupported) { @@ -1360,7 +1357,7 @@ WWindow *wManageInternalWindow(WScreen *scr, Window window, Window owner, scr->resizebar_texture, scr->window_title_color, &scr->title_font, scr->w_depth, scr->w_visual, scr->w_colormap); - XSaveContext(dpy, window, wWinContext, (XPointer) & wwin->client_descriptor); + XSaveContext(dpy, window, w_global.context.client_win, (XPointer) & wwin->client_descriptor); wwin->frame->flags.is_client_window_frame = 1; wwin->frame->flags.justification = wPreferences.title_justification;