From b9f33162eaad31988e3595ddcd3efd97ee2da0aa Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Rework dummy variable usage in HandleButtonPress 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 --- src/events.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/events.c b/src/events.c index a8c8fec..9d82b81 100644 --- a/src/events.c +++ b/src/events.c @@ -1782,13 +1782,17 @@ HandleButtonPress(void) if (Tmp_win->list && RootFunction != 0 && (Event.xany.window == Tmp_win->list->w || Event.xany.window == Tmp_win->list->icon)) { + int x = 0; + int y = 0; + Tmp_win = Tmp_win->list->iconmgr->twm_win; + XTranslateCoordinates(dpy, Event.xany.window, Tmp_win->w, Event.xbutton.x, Event.xbutton.y, - &JunkX, &JunkY, &JunkChild); + &x, &y, &JunkChild); - Event.xbutton.x = JunkX; - Event.xbutton.y = JunkY - Tmp_win->title_height; + Event.xbutton.x = x; + Event.xbutton.y = y - Tmp_win->title_height; Event.xany.window = Tmp_win->w; Context = C_WINDOW; @@ -1844,6 +1848,8 @@ HandleButtonPress(void) * inside of a client that was getting button press events. */ XPointer context_data; + int x = 0; + int y = 0; XTranslateCoordinates(dpy, Scr->Root, Scr->Root, Event.xbutton.x, @@ -1863,10 +1869,10 @@ HandleButtonPress(void) XTranslateCoordinates(dpy, Scr->Root, Event.xany.window, Event.xbutton.x, - Event.xbutton.y, &JunkX, &JunkY, &JunkChild); + Event.xbutton.y, &x, &y, &JunkChild); - Event.xbutton.x = JunkX; - Event.xbutton.y = JunkY; + Event.xbutton.x = x; + Event.xbutton.y = y; Context = C_WINDOW; } -- cgit v1.2.3