diff options
author | Tim Wiederhake <twied@gmx.net> | 2024-01-20 16:07:00 +0100 |
---|---|---|
committer | Tim Wiederhake <twied@gmx.net> | 2024-01-20 16:07:00 +0100 |
commit | 6ea386bd98a737a9f54e2ca4216adf45868fd6e4 (patch) | |
tree | a4846effd0834fd410a786651b0256e2aecd2b6d | |
parent | 08b916e7ab8ea54ee6c38c485f11c9d6da898355 (diff) |
Remove global variables JunkRoot, JunkChild
Replace with a local variable following the naming scheme from
Identify() in src/menus.c.
Signed-off-by: Tim Wiederhake <twied@gmx.net>
-rw-r--r-- | src/add_window.c | 9 | ||||
-rw-r--r-- | src/cursor.c | 5 | ||||
-rw-r--r-- | src/events.c | 19 | ||||
-rw-r--r-- | src/icons.c | 12 | ||||
-rw-r--r-- | src/menus.c | 30 | ||||
-rw-r--r-- | src/session.c | 3 | ||||
-rw-r--r-- | src/twm.c | 5 | ||||
-rw-r--r-- | src/twm.h | 2 | ||||
-rw-r--r-- | src/util.c | 9 |
9 files changed, 54 insertions, 40 deletions
diff --git a/src/add_window.c b/src/add_window.c index 1f5abe1..e451bfe 100644 --- a/src/add_window.c +++ b/src/add_window.c @@ -162,6 +162,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) Bool width_ever_changed_by_user; Bool height_ever_changed_by_user; char *name; + Window wdummy = None; #ifdef DEBUG fprintf(stderr, "AddWindow: w = 0x%lx\n", (unsigned long) w); @@ -440,7 +441,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) XGrabServer(dpy); if (!XQueryPointer(dpy, Scr->Root, &root, - &JunkChild, &JunkX, &JunkY, + &wdummy, &JunkX, &JunkY, &AddingX, &AddingY, &mask)) mask = 0; @@ -567,7 +568,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) continue; } - XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild, + XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask); @@ -662,7 +663,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) * using multiple GXxor lines so that we don't need to * grab the server. */ - XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild, + XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask); @@ -765,7 +766,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) * reparented, so we'll get a DestroyNotify for it. We won't have * gotten one for anything up to here, however. */ - if (XGetGeometry(dpy, tmp_win->w, &JunkRoot, &JunkX, &JunkY, + if (XGetGeometry(dpy, tmp_win->w, &wdummy, &JunkX, &JunkY, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth) == 0) { free(tmp_win); XUngrabServer(dpy); diff --git a/src/cursor.c b/src/cursor.c index 84d3f0c..9cc26c7 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -149,6 +149,7 @@ NewBitmapCursor(Cursor *cp, char *source, char *mask) int sx, sy, mx, my; unsigned int sw, sh, mw, mh; Pixmap spm, mpm; + Window wdummy = None; spm = GetBitmap(source); if ((hotx = HotX) < 0) @@ -159,8 +160,8 @@ NewBitmapCursor(Cursor *cp, char *source, char *mask) /* make sure they are the same size */ - XGetGeometry(dpy, spm, &JunkRoot, &sx, &sy, &sw, &sh, &JunkBW, &JunkDepth); - XGetGeometry(dpy, mpm, &JunkRoot, &mx, &my, &mw, &mh, &JunkBW, &JunkDepth); + XGetGeometry(dpy, spm, &wdummy, &sx, &sy, &sw, &sh, &JunkBW, &JunkDepth); + XGetGeometry(dpy, mpm, &wdummy, &mx, &my, &mw, &mh, &JunkBW, &JunkDepth); if (sw != mw || sh != mh) { twmWarning("cursor bitmaps \"%s\" and \"%s\" not the same size\n", source, mask); diff --git a/src/events.c b/src/events.c index 9d82b81..54f5bff 100644 --- a/src/events.c +++ b/src/events.c @@ -735,6 +735,7 @@ HandlePropertyNotify(void) char *name = NULL; XSetWindowAttributes attributes; /* attributes for create windows */ Pixmap pm; + Window wdummy = None; /* watch for standard colormap changes */ if (Event.xproperty.window == Scr->Root) { @@ -821,7 +822,7 @@ HandlePropertyNotify(void) // to a default icon */ int icon_x = 0, icon_y = 0; - XGetGeometry(dpy, Tmp_win->icon_w, &JunkRoot, + XGetGeometry(dpy, Tmp_win->icon_w, &wdummy, &icon_x, &icon_y, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth); XSelectInput(dpy, Tmp_win->icon_w, None); @@ -841,7 +842,7 @@ HandlePropertyNotify(void) * Try to find out where it is; if we succeed, move the new * window to where the old one is. */ - if (XGetGeometry(dpy, Tmp_win->icon_w, &JunkRoot, &icon_x, + if (XGetGeometry(dpy, Tmp_win->icon_w, &wdummy, &icon_x, &icon_y, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth)) { /* @@ -899,7 +900,7 @@ HandlePropertyNotify(void) (Tmp_win->wmhints->flags & IconPixmapHint)) { unsigned long valuemask; /* mask for create windows */ - if (!XGetGeometry(dpy, Tmp_win->wmhints->icon_pixmap, &JunkRoot, + if (!XGetGeometry(dpy, Tmp_win->wmhints->icon_pixmap, &wdummy, &JunkX, &JunkY, (unsigned int *) &Tmp_win->icon_width, (unsigned int *) &Tmp_win->icon_height, &JunkBW, @@ -1016,12 +1017,14 @@ RedoIconName(void) void HandleClientMessage(void) { + Window wdummy = None; + if (Event.xclient.message_type == _XA_WM_CHANGE_STATE) { if (Tmp_win != NULL) { if (Event.xclient.data.l[0] == IconicState && !Tmp_win->icon) { XEvent button; - XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild, + XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, &(button.xmotion.x_root), &(button.xmotion.y_root), &JunkX, &JunkY, &JunkMask); @@ -1466,10 +1469,11 @@ void HandleMotionNotify(void) { XPointer context_data; + Window wdummy = None; if (ResizeWindow != (Window) 0) { XQueryPointer(dpy, Event.xany.window, - &(Event.xmotion.root), &JunkChild, + &(Event.xmotion.root), &wdummy, &(Event.xmotion.x_root), &(Event.xmotion.y_root), &(Event.xmotion.x), &(Event.xmotion.y), &JunkMask); @@ -1697,6 +1701,7 @@ HandleButtonPress(void) { unsigned int modifier; Cursor cur; + Window wdummy = None; /* too much code relies on this assumption */ if (Event.xbutton.button > MAX_BUTTONS) @@ -1789,7 +1794,7 @@ HandleButtonPress(void) XTranslateCoordinates(dpy, Event.xany.window, Tmp_win->w, Event.xbutton.x, Event.xbutton.y, - &x, &y, &JunkChild); + &x, &y, &wdummy); Event.xbutton.x = x; Event.xbutton.y = y - Tmp_win->title_height; @@ -1869,7 +1874,7 @@ HandleButtonPress(void) XTranslateCoordinates(dpy, Scr->Root, Event.xany.window, Event.xbutton.x, - Event.xbutton.y, &x, &y, &JunkChild); + Event.xbutton.y, &x, &y, &wdummy); Event.xbutton.x = x; Event.xbutton.y = y; diff --git a/src/icons.c b/src/icons.c index 296d3e3..4e406af 100644 --- a/src/icons.c +++ b/src/icons.c @@ -163,6 +163,7 @@ IconUp(TwmWindow *tmp_win) int x, y; int defx, defy; struct IconRegion *ir; + Window wdummy = None; /* * If the client specified a particular location, let's use it (this might @@ -176,7 +177,7 @@ IconUp(TwmWindow *tmp_win) unsigned width = 0; unsigned height = 0; - if (!XGetGeometry(dpy, tmp_win->icon_w, &JunkRoot, &defx, &defy, + if (!XGetGeometry(dpy, tmp_win->icon_w, &wdummy, &defx, &defy, &width, &height, &JunkBW, &JunkDepth)) return; @@ -319,6 +320,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) XSetWindowAttributes attributes; /* attributes for create windows */ Pixmap pm = None; /* tmp pixmap variable */ int final_x, final_y; + Window wdummy = None; FB(tmp_win->iconc.fore, tmp_win->iconc.back); @@ -349,7 +351,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) } if (bm != None) { - XGetGeometry(dpy, bm, &JunkRoot, &JunkX, &JunkY, + XGetGeometry(dpy, bm, &wdummy, &JunkX, &JunkY, (unsigned int *) &tmp_win->icon_width, (unsigned int *) &tmp_win->icon_height, &JunkBW, &JunkDepth); @@ -375,7 +377,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) tmp_win->wmhints->flags & IconPixmapHint) { XGetGeometry(dpy, tmp_win->wmhints->icon_pixmap, - &JunkRoot, &JunkX, &JunkY, + &wdummy, &JunkX, &JunkY, (unsigned int *) &tmp_win->icon_width, (unsigned int *) &tmp_win->icon_height, &JunkBW, &JunkDepth); @@ -413,7 +415,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) } if (bm != None) { - XGetGeometry(dpy, bm, &JunkRoot, &JunkX, &JunkY, + XGetGeometry(dpy, bm, &wdummy, &JunkX, &JunkY, (unsigned int *) &tmp_win->icon_width, (unsigned int *) &tmp_win->icon_height, &JunkBW, &JunkDepth); @@ -475,7 +477,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) if (tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint) { tmp_win->icon_w = tmp_win->wmhints->icon_window; if (tmp_win->forced || - XGetGeometry(dpy, tmp_win->icon_w, &JunkRoot, &JunkX, &JunkY, + XGetGeometry(dpy, tmp_win->icon_w, &wdummy, &JunkX, &JunkY, (unsigned int *) &tmp_win->icon_w_width, (unsigned int *) &tmp_win->icon_w_height, &JunkBW, &JunkDepth) == 0) { diff --git a/src/menus.c b/src/menus.c index aa23a16..4ab2a30 100644 --- a/src/menus.c +++ b/src/menus.c @@ -469,6 +469,7 @@ UpdateMenu(void) int done; MenuItem *badItem = NULL; XPointer context_data; + Window wdummy = None; fromMenu = TRUE; @@ -506,7 +507,7 @@ UpdateMenu(void) continue; done = FALSE; - XQueryPointer(dpy, ActiveMenu->w, &JunkRoot, &JunkChild, + XQueryPointer(dpy, ActiveMenu->w, &wdummy, &wdummy, &x_root, &y_root, &x, &y, &JunkMask); /* if we haven't received the enter notify yet, wait */ @@ -1119,16 +1120,17 @@ resizeFromCenter(Window w, TwmWindow *tmp_win) { int lastx, lasty, bw2; XEvent event; + Window wdummy = None; bw2 = tmp_win->frame_bw * 2; AddingW = tmp_win->attr.width + bw2; AddingH = tmp_win->attr.height + tmp_win->title_height + bw2; - XGetGeometry(dpy, w, &JunkRoot, &origDragX, &origDragY, + XGetGeometry(dpy, w, &wdummy, &origDragX, &origDragY, (unsigned int *) &DragWidth, (unsigned int *) &DragHeight, &JunkBW, &JunkDepth); XWarpPointer(dpy, None, w, 0, 0, 0, 0, DragWidth / 2, DragHeight / 2); - XQueryPointer(dpy, Scr->Root, &JunkRoot, - &JunkChild, &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask); + XQueryPointer(dpy, Scr->Root, &wdummy, + &wdummy, &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask); lastx = -10000; lasty = -10000; MenuStartResize(tmp_win, origDragX, origDragY, DragWidth, DragHeight); @@ -1161,7 +1163,7 @@ resizeFromCenter(Window w, TwmWindow *tmp_win) * using multiple GXxor lines so that we don't need to * grab the server. */ - XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild, + XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask); if (lastx != AddingX || lasty != AddingY) { @@ -1218,6 +1220,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, int moving_icon = FALSE; Bool fromtitlebar = False; unsigned bw = 0; + Window wdummy = None; RootFunction = 0; if (Cancel) @@ -1471,14 +1474,14 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, XTranslateCoordinates(dpy, w, tmp_win->frame, eventp->xbutton.x, eventp->xbutton.y, - &DragX, &DragY, &JunkChild); + &DragX, &DragY, &wdummy); w = tmp_win->frame; } DragWindow = None; - XGetGeometry(dpy, w, &JunkRoot, &origDragX, &origDragY, + XGetGeometry(dpy, w, &wdummy, &origDragX, &origDragY, (unsigned int *) &DragWidth, (unsigned int *) &DragHeight, &bw, &JunkDepth); @@ -1513,7 +1516,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, XWarpPointer(dpy, None, w, 0, 0, 0, 0, DragWidth / 2, DragHeight / 2); - XQueryPointer(dpy, w, &JunkRoot, &JunkChild, + XQueryPointer(dpy, w, &wdummy, &wdummy, &JunkX, &JunkY, &DragX, &DragY, &JunkMask); } last_time = eventp->xbutton.time; @@ -1599,7 +1602,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, CurrentDragY = origY = Event.xbutton.y_root; XTranslateCoordinates(dpy, rootw, tmp_win->frame, - origX, origY, &DragX, &DragY, &JunkChild); + origX, origY, &DragX, &DragY, &wdummy); continue; } @@ -1628,7 +1631,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, if (Event.type != MotionNotify) continue; - XQueryPointer(dpy, rootw, &(eventp->xmotion.root), &JunkChild, + XQueryPointer(dpy, rootw, &(eventp->xmotion.root), &wdummy, &(eventp->xmotion.x_root), &(eventp->xmotion.y_root), &JunkX, &JunkY, &JunkMask); @@ -1654,7 +1657,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, eventp->xmotion.y_root > ConstMoveYB) ConstMoveDir = MOVE_VERT; - XQueryPointer(dpy, DragWindow, &JunkRoot, &JunkChild, + XQueryPointer(dpy, DragWindow, &wdummy, &wdummy, &JunkX, &JunkY, &DragX, &DragY, &JunkMask); break; @@ -2520,13 +2523,14 @@ Identify(TwmWindow *t) Window junk; int px, py, dummy; unsigned udummy; + Window wdummy = None; n = 0; snprintf(Info[n++], INFO_SIZE, "Twm version: %s", Version); Info[n++][0] = '\0'; if (t) { - XGetGeometry(dpy, t->w, &JunkRoot, &JunkX, &JunkY, + XGetGeometry(dpy, t->w, &wdummy, &JunkX, &JunkY, &wwidth, &wheight, &bw, &depth); (void) XTranslateCoordinates(dpy, t->w, Scr->Root, 0, 0, &x, &y, &junk); snprintf(Info[n++], INFO_SIZE, @@ -2565,7 +2569,7 @@ Identify(TwmWindow *t) XUnmapWindow(dpy, Scr->InfoWindow); width += 10; /* some padding */ - if (XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild, &px, &py, + if (XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, &px, &py, &dummy, &dummy, &udummy)) { px -= (width / 2); py -= (height / 3); diff --git a/src/session.c b/src/session.c index 2c2787a..ce601ac 100644 --- a/src/session.c +++ b/src/session.c @@ -330,8 +330,9 @@ WriteWinConfigEntry(FILE *configFile, TwmWindow *theWindow, if (theWindow->icon_w) { int icon_x, icon_y; + Window wdummy = None; - XGetGeometry(dpy, theWindow->icon_w, &JunkRoot, &icon_x, + XGetGeometry(dpy, theWindow->icon_w, &wdummy, &icon_x, &icon_y, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth); if (!write_short(configFile, (short) icon_x)) @@ -138,8 +138,6 @@ int ParseError; /* error parsing the .twmrc file */ int HandlingEvents = FALSE; /* are we handling events yet? */ -Window JunkRoot; /* junk window */ -Window JunkChild; /* junk window */ int JunkX; /* junk variable */ int JunkY; /* junk variable */ unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask; @@ -823,8 +821,9 @@ RestoreWithdrawnLocation(TwmWindow *tmp) int gravx, gravy; unsigned int bw; XWindowChanges xwc; + Window wdummy = None; - if (XGetGeometry(dpy, tmp->w, &JunkRoot, &xwc.x, &xwc.y, + if (XGetGeometry(dpy, tmp->w, &wdummy, &xwc.x, &xwc.y, &JunkWidth, &JunkHeight, &bw, &JunkDepth)) { unsigned mask; @@ -372,8 +372,6 @@ extern int ParseError; extern int HandlingEvents; -extern Window JunkRoot; -extern Window JunkChild; extern int JunkX; extern int JunkY; extern unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask; @@ -209,6 +209,7 @@ Zoom(Window wf, Window wt) long dx, dy, dw, dh; long z; int j; + Window wdummy = None; if (!Scr->DoZoom || Scr->ZoomCount < 1) return; @@ -216,8 +217,8 @@ Zoom(Window wf, Window wt) if (wf == None || wt == None) return; - XGetGeometry(dpy, wf, &JunkRoot, &fx, &fy, &fw, &fh, &JunkBW, &JunkDepth); - XGetGeometry(dpy, wt, &JunkRoot, &tx, &ty, &tw, &th, &JunkBW, &JunkDepth); + XGetGeometry(dpy, wf, &wdummy, &fx, &fy, &fw, &fh, &JunkBW, &JunkDepth); + XGetGeometry(dpy, wt, &wdummy, &tx, &ty, &tw, &th, &JunkBW, &JunkDepth); dx = ((long) (tx - fx)); /* going from -> to */ dy = ((long) (ty - fy)); /* going from -> to */ @@ -278,8 +279,10 @@ ExpandFilename(const char *name) void GetUnknownIcon(const char *name) { + Window wdummy = None; + if ((Scr->UnknownPm = GetBitmap(name)) != None) { - XGetGeometry(dpy, Scr->UnknownPm, &JunkRoot, &JunkX, &JunkY, + XGetGeometry(dpy, Scr->UnknownPm, &wdummy, &JunkX, &JunkY, (unsigned int *) &Scr->UnknownWidth, (unsigned int *) &Scr->UnknownHeight, &JunkBW, &JunkDepth); } |