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 | 08b916e7ab8ea54ee6c38c485f11c9d6da898355 (patch) | |
tree | 82e22c352ed5f31fb1a2970a9f29c77b0e5ebbf7 | |
parent | 7b24db53fc606a94067d90e8c64d8e7c8c75c12b (diff) |
Rework dummy variable usage in ExecuteFunction
twm defines several "junk" variables to use with functions like
XQueryPointer or XGetGeometry. In some instances, the returned
values are actually used, which makes the code confusing and hard
to reason about. Use dedicated variables in those cases.
Signed-off-by: Tim Wiederhake <twied@gmx.net>
-rw-r--r-- | src/menus.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/menus.c b/src/menus.c index 1e78a1a..aa23a16 100644 --- a/src/menus.c +++ b/src/menus.c @@ -1217,6 +1217,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, int do_next_action = TRUE; int moving_icon = FALSE; Bool fromtitlebar = False; + unsigned bw = 0; RootFunction = 0; if (Cancel) @@ -1479,7 +1480,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, XGetGeometry(dpy, w, &JunkRoot, &origDragX, &origDragY, (unsigned int *) &DragWidth, (unsigned int *) &DragHeight, - &JunkBW, &JunkDepth); + &bw, &JunkDepth); origX = eventp->xbutton.x_root; origY = eventp->xbutton.y_root; @@ -1498,12 +1499,12 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, ConstMoveDir = MOVE_NONE; ConstMoveX = (int) ((unsigned) eventp->xbutton.x_root - (unsigned) DragX - - JunkBW); + bw); ConstMoveY = (int) ((unsigned) eventp->xbutton.y_root - (unsigned) DragY - - JunkBW); - width = (int) ((unsigned) DragWidth + 2 * JunkBW); - height = (int) ((unsigned) DragHeight + 2 * JunkBW); + bw); + width = (int) ((unsigned) DragWidth + 2 * bw); + height = (int) ((unsigned) DragHeight + 2 * bw); ConstMoveXL = ConstMoveX + width / 3; ConstMoveXR = ConstMoveX + 2 * (width / 3); ConstMoveYT = ConstMoveY + height / 3; @@ -1527,10 +1528,10 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, * MoveOutline's below. */ MoveOutline(rootw, - (int) ((unsigned) origDragX - JunkBW), - (int) ((unsigned) origDragY - JunkBW), - (int) ((unsigned) DragWidth + 2 * JunkBW), - (int) ((unsigned) DragHeight + 2 * JunkBW), + (int) ((unsigned) origDragX - bw), + (int) ((unsigned) origDragY - bw), + (int) ((unsigned) DragWidth + 2 * bw), + (int) ((unsigned) DragHeight + 2 * bw), tmp_win->frame_bw, moving_icon ? 0 : tmp_win->title_height); /* @@ -1660,13 +1661,13 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, case MOVE_VERT: ConstMoveY = (int) ((unsigned) eventp->xmotion.y_root - - (unsigned) DragY - JunkBW); + (unsigned) DragY - bw); break; case MOVE_HORIZ: ConstMoveX = (int) ((unsigned) eventp->xmotion.x_root - - (unsigned) DragX - JunkBW); + (unsigned) DragX - bw); break; } @@ -1675,8 +1676,8 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, xl = ConstMoveX; yt = ConstMoveY; - w2 = (int) ((unsigned) DragWidth + 2 * JunkBW); - h = (int) ((unsigned) DragHeight + 2 * JunkBW); + w2 = (int) ((unsigned) DragWidth + 2 * bw); + h = (int) ((unsigned) DragHeight + 2 * bw); if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE) { int xr = xl + w2; @@ -1707,16 +1708,16 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, if (!menuFromFrameOrWindowOrTitlebar) { xl = (int) ((unsigned) eventp->xmotion.x_root - - (unsigned) DragX - JunkBW); + (unsigned) DragX - bw); yt = (int) ((unsigned) eventp->xmotion.y_root - - (unsigned) DragY - JunkBW); + (unsigned) DragY - bw); } else { xl = (int) (eventp->xmotion.x_root - (DragWidth / 2)); yt = (int) (eventp->xmotion.y_root - (DragHeight / 2)); } - w2 = (int) ((unsigned) DragWidth + 2 * JunkBW); - h = (int) ((unsigned) DragHeight + 2 * JunkBW); + w2 = (int) ((unsigned) DragWidth + 2 * bw); + h = (int) ((unsigned) DragHeight + 2 * bw); if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE) { int xr = xl + w2; |