1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 20:38:08 +01:00

wmaker: Moved definition of X Contexts into the global variables structure

This commit is contained in:
Christophe CURIS
2013-09-29 13:22:58 +02:00
committed by Carlos R. Mafra
parent e2ce62eb5b
commit ec91b9f68e
12 changed files with 35 additions and 56 deletions

View File

@@ -522,6 +522,13 @@ extern struct wmaker_global_variables {
} atom; } atom;
/* X Contexts */
struct {
XContext client_win;
XContext app_win;
XContext stack;
} context;
} w_global; } w_global;
extern unsigned int ValidModMask; extern unsigned int ValidModMask;

View File

@@ -62,7 +62,6 @@
/**** Global variables ****/ /**** Global variables ****/
extern WDDomain *WDWindowAttributes; extern WDDomain *WDWindowAttributes;
extern XContext wWinContext;
#define MOD_MASK wPreferences.modifier_mask #define MOD_MASK wPreferences.modifier_mask
#define ICON_SIZE wPreferences.icon_size #define ICON_SIZE wPreferences.icon_size
@@ -1221,7 +1220,7 @@ WAppIcon *wAppIconFor(Window window)
if (window == None) if (window == None)
return NULL; return NULL;
if (XFindContext(dpy, window, wWinContext, (XPointer *) & desc) == XCNOENT) if (XFindContext(dpy, window, w_global.context.client_win, (XPointer *) & desc) == XCNOENT)
return NULL; return NULL;
if (desc->parent_type == WCLASS_APPICON || desc->parent_type == WCLASS_DOCK_ICON) if (desc->parent_type == WCLASS_APPICON || desc->parent_type == WCLASS_DOCK_ICON)

View File

@@ -37,10 +37,6 @@
#include "dock.h" #include "dock.h"
#include "defaults.h" #include "defaults.h"
/******** Global variables ********/
extern XContext wAppWinContext;
extern XContext wWinContext;
/******** Local variables ********/ /******** Local variables ********/
@@ -73,7 +69,7 @@ WApplication *wApplicationOf(Window window)
if (window == None) if (window == None)
return NULL; 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 NULL;
return wapp; return wapp;
} }
@@ -140,7 +136,7 @@ WApplication *wApplicationCreate(WWindow * wwin)
wapp->flags.emulated = WFLAGP(wapp->main_window_desc, emulate_appicon); wapp->flags.emulated = WFLAGP(wapp->main_window_desc, emulate_appicon);
/* application descriptor */ /* 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); create_appicon_for_application(wapp, wwin);
@@ -183,7 +179,7 @@ void wApplicationDestroy(WApplication * wapp)
wapp->prev->next = wapp->next; wapp->prev->next = wapp->next;
} }
XDeleteContext(dpy, wapp->main_window, wAppWinContext); XDeleteContext(dpy, wapp->main_window, w_global.context.app_win);
wAppMenuDestroy(wapp->menu); wAppMenuDestroy(wapp->menu);
/* Remove application icon */ /* Remove application icon */
@@ -195,7 +191,7 @@ void wApplicationDestroy(WApplication * wapp)
if (wwin) { if (wwin) {
/* undelete client window context that was deleted in /* undelete client window context that was deleted in
* wWindowDestroy */ * 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); wfree(wapp);
} }

View File

@@ -46,9 +46,6 @@
/****** Global Variables ******/ /****** Global Variables ******/
/* contexts */
extern XContext wWinContext;
#ifdef SHAPE #ifdef SHAPE
extern Bool wShapeSupported; extern Bool wShapeSupported;
#endif #endif
@@ -191,7 +188,7 @@ void wClientConfigure(WWindow * wwin, XConfigureRequestEvent * xcre)
WWindow *sibling; WWindow *sibling;
if ((xcre->value_mask & CWSibling) && 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)) { && (desc->parent_type == WCLASS_WINDOW)) {
sibling = desc->parent; sibling = desc->parent;
xwc.sibling = sibling->frame->core->window; xwc.sibling = sibling->frame->core->window;

View File

@@ -65,9 +65,6 @@
#define CLIP_IDLE 0 #define CLIP_IDLE 0
#define CLIP_FORWARD 2 #define CLIP_FORWARD 2
/**** Global variables ****/
extern XContext wWinContext;
#define MOD_MASK wPreferences.modifier_mask #define MOD_MASK wPreferences.modifier_mask
#define ICON_SIZE wPreferences.icon_size #define ICON_SIZE wPreferences.icon_size
@@ -4050,7 +4047,7 @@ static void clipLeave(WDock *dock)
return; return;
if (XCheckTypedEvent(dpy, EnterNotify, &event) != False) { 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 (XPointer *) & desc) != XCNOENT
&& desc && desc->parent_type == WCLASS_DOCK_ICON && desc && desc->parent_type == WCLASS_DOCK_ICON
&& ((WAppIcon *) desc->parent)->dock == dock) { && ((WAppIcon *) desc->parent)->dock == dock) {

View File

@@ -77,7 +77,6 @@
#include "switchmenu.h" #include "switchmenu.h"
/******** Global Variables **********/ /******** Global Variables **********/
extern XContext wWinContext;
extern XContext wVEdgeContext; extern XContext wVEdgeContext;
extern WShortKey wKeyBindings[WKBD_LAST]; extern WShortKey wKeyBindings[WKBD_LAST];
@@ -702,7 +701,7 @@ static void handleExpose(XEvent * event)
while (XCheckTypedWindowEvent(dpy, event->xexpose.window, Expose, &ev)) ; 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; return;
} }
@@ -769,8 +768,8 @@ static void handleButtonPress(XEvent * event)
} }
desc = NULL; desc = NULL;
if (XFindContext(dpy, event->xbutton.subwindow, wWinContext, (XPointer *) & desc) == XCNOENT) { if (XFindContext(dpy, event->xbutton.subwindow, w_global.context.client_win, (XPointer *) & desc) == XCNOENT) {
if (XFindContext(dpy, event->xbutton.window, wWinContext, (XPointer *) & desc) == XCNOENT) { if (XFindContext(dpy, event->xbutton.window, w_global.context.client_win, (XPointer *) & desc) == XCNOENT) {
return; return;
} }
} }
@@ -1034,7 +1033,7 @@ static void handleClientMessage(XEvent * event)
* For when the icon frame gets a ClientMessage * For when the icon frame gets a ClientMessage
* that should have gone to the icon_window. * 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; struct WIcon *icon = NULL;
if (desc->parent_type == WCLASS_MINIWINDOW) { 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) if (desc->handle_enternotify)
(*desc->handle_enternotify) (desc, event); (*desc->handle_enternotify) (desc, event);
} }
@@ -1148,7 +1147,7 @@ static void handleLeaveNotify(XEvent * event)
{ {
WObjDescriptor *desc = NULL; 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) if (desc->handle_leavenotify)
(*desc->handle_leavenotify) (desc, event); (*desc->handle_leavenotify) (desc, event);
} }

View File

@@ -91,9 +91,6 @@ WDDomain *WDWindowAttributes = NULL;
WDDomain *WDRootMenu = NULL; WDDomain *WDRootMenu = NULL;
/* XContexts */ /* XContexts */
XContext wWinContext;
XContext wAppWinContext;
XContext wStackContext;
XContext wVEdgeContext; XContext wVEdgeContext;
#ifdef SHAPE #ifdef SHAPE

View File

@@ -45,9 +45,6 @@
#include "rootmenu.h" #include "rootmenu.h"
#include "switchmenu.h" #include "switchmenu.h"
/****** Global Variables ******/
extern XContext wWinContext;
#define MOD_MASK wPreferences.modifier_mask #define MOD_MASK wPreferences.modifier_mask
@@ -1276,7 +1273,7 @@ static WMenu *findMenu(WScreen * scr, int *x_ret, int *y_ret)
if (win == None) if (win == None)
return NULL; return NULL;
if (XFindContext(dpy, win, wWinContext, (XPointer *) & desc) == XCNOENT) if (XFindContext(dpy, win, w_global.context.client_win, (XPointer *) & desc) == XCNOENT)
return NULL; return NULL;
if (desc->parent_type == WCLASS_MENU) { if (desc->parent_type == WCLASS_MENU) {
@@ -1398,7 +1395,7 @@ WMenu *wMenuUnderPointer(WScreen * screen)
if (win == None) if (win == None)
return NULL; return NULL;
if (XFindContext(dpy, win, wWinContext, (XPointer *) & desc) == XCNOENT) if (XFindContext(dpy, win, w_global.context.client_win, (XPointer *) & desc) == XCNOENT)
return NULL; return NULL;
if (desc->parent_type == WCLASS_MENU) if (desc->parent_type == WCLASS_MENU)

View File

@@ -35,8 +35,6 @@
#include "stacking.h" #include "stacking.h"
#include "workspace.h" #include "workspace.h"
/*** Global Variables ***/
extern XContext wStackContext;
static void notifyStackChange(WCoreWindow * frame, char *detail) static void notifyStackChange(WCoreWindow * frame, char *detail)
{ {
@@ -77,7 +75,7 @@ void RemakeStackList(WScreen * scr)
/* verify list integrity */ /* verify list integrity */
c = 0; c = 0;
for (i = 0; i < nwindows; i++) { 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) { == XCNOENT) {
continue; continue;
} }
@@ -404,7 +402,7 @@ void AddToStackList(WCoreWindow * frame)
WCoreWindow *trans = NULL; WCoreWindow *trans = NULL;
frame->screen_ptr->window_count++; 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); curtop = WMGetFromBag(scr->stacking_list, index);
/* first window in this level */ /* first window in this level */
@@ -560,7 +558,7 @@ void RemoveFromStackList(WCoreWindow * frame)
{ {
int index = frame->stacking->window_level; 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 "); wwarning("RemoveFromStackingList(): window not in list ");
return; return;
} }

View File

@@ -102,9 +102,6 @@ extern int wXkbEventBase;
#endif #endif
/* contexts */ /* contexts */
extern XContext wWinContext;
extern XContext wAppWinContext;
extern XContext wStackContext;
extern XContext wVEdgeContext; extern XContext wVEdgeContext;
#ifndef HAVE_INOTIFY #ifndef HAVE_INOTIFY
@@ -472,9 +469,9 @@ void StartUp(Bool defaultScreenOnly)
memset(&wKeyBindings, 0, sizeof(wKeyBindings)); memset(&wKeyBindings, 0, sizeof(wKeyBindings));
wWinContext = XUniqueContext(); w_global.context.client_win = XUniqueContext();
wAppWinContext = XUniqueContext(); w_global.context.app_win = XUniqueContext();
wStackContext = XUniqueContext(); w_global.context.stack = XUniqueContext();
wVEdgeContext = XUniqueContext(); wVEdgeContext = XUniqueContext();
/* _XA_VERSION = XInternAtom(dpy, "VERSION", False); */ /* _XA_VERSION = XInternAtom(dpy, "VERSION", False); */

View File

@@ -29,8 +29,6 @@
#include "WindowMaker.h" #include "WindowMaker.h"
#include "wcore.h" #include "wcore.h"
/****** Global Variables ******/
extern XContext wWinContext;
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
* wCoreCreateTopLevel-- * wCoreCreateTopLevel--
@@ -72,7 +70,7 @@ WCoreWindow *wCoreCreateTopLevel(WScreen *screen, int x, int y, int width, int h
core->descriptor.self = core; core->descriptor.self = core;
XClearWindow(dpy, core->window); 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; 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->screen_ptr = parent->screen_ptr;
core->descriptor.self = core; 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; return core;
} }
@@ -125,7 +123,7 @@ void wCoreDestroy(WCoreWindow * core)
if (core->stacking) if (core->stacking)
wfree(core->stacking); wfree(core->stacking);
XDeleteContext(dpy, core->window, wWinContext); XDeleteContext(dpy, core->window, w_global.context.client_win);
XDestroyWindow(dpy, core->window); XDestroyWindow(dpy, core->window);
wfree(core); wfree(core);
} }

View File

@@ -79,9 +79,6 @@ extern WShortKey wKeyBindings[WKBD_LAST];
extern Bool wShapeSupported; extern Bool wShapeSupported;
#endif #endif
/* contexts */
extern XContext wWinContext;
/***** Local Stuff *****/ /***** Local Stuff *****/
static WWindowState *windowState = NULL; static WWindowState *windowState = NULL;
static FocusMode getFocusMode(WWindow *wwin); static FocusMode getFocusMode(WWindow *wwin);
@@ -146,7 +143,7 @@ WWindow *wWindowFor(Window window)
if (window == None) if (window == None)
return NULL; return NULL;
if (XFindContext(dpy, window, wWinContext, (XPointer *) & desc) == XCNOENT) if (XFindContext(dpy, window, w_global.context.client_win, (XPointer *) & desc) == XCNOENT)
return NULL; return NULL;
if (desc->parent_type == WCLASS_WINDOW) if (desc->parent_type == WCLASS_WINDOW)
@@ -226,7 +223,7 @@ void wWindowDestroy(WWindow *wwin)
if (wwin->cmap_windows) if (wwin->cmap_windows)
XFree(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) if (wwin->frame)
wFrameWindowDestroy(wwin->frame); wFrameWindowDestroy(wwin->frame);
@@ -621,7 +618,7 @@ WWindow *wManageWindow(WScreen *scr, Window window)
else if (!wFetchName(dpy, window, &title)) else if (!wFetchName(dpy, window, &title))
title = NULL; title = NULL;
XSaveContext(dpy, window, wWinContext, (XPointer) & wwin->client_descriptor); XSaveContext(dpy, window, w_global.context.client_win, (XPointer) & wwin->client_descriptor);
#ifdef SHAPE #ifdef SHAPE
if (wShapeSupported) { 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->resizebar_texture, scr->window_title_color, &scr->title_font,
scr->w_depth, scr->w_visual, scr->w_colormap); 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.is_client_window_frame = 1;
wwin->frame->flags.justification = wPreferences.title_justification; wwin->frame->flags.justification = wPreferences.title_justification;