From 79e5cec3645203c14799239fe056f19be340c70c Mon Sep 17 00:00:00 2001 From: Mike Small Date: Sat, 7 Nov 2020 14:40:05 -0500 Subject: [PATCH] Rename tmp_win to win, use reference in local function Trivial cleanup. Start eliminating tmp_ from variable names. What is temporary about the window object here? --- src/icons.cc | 164 +++++++++++++++++++++++++-------------------------- 1 file changed, 82 insertions(+), 82 deletions(-) diff --git a/src/icons.cc b/src/icons.cc index 74f1edb..274472c 100644 --- a/src/icons.cc +++ b/src/icons.cc @@ -60,7 +60,7 @@ roundUp (int v, int multiple) } static Coord -PlaceIcon(TwmWindow *tmp_win, int def_x, int def_y) +PlaceIcon(const TwmWindow& win, int def_x, int def_y) { // Try to place in a gap along the right side of the current screen. @@ -70,7 +70,7 @@ PlaceIcon(TwmWindow *tmp_win, int def_x, int def_y) int y = 0; using Span = pair; vector occupied; - cerr << "tmp_win: " << tmp_win->name << '\n'; + cerr << "win: " << win.name << '\n'; for (TwmWindow* pw = Scr->TwmRoot.next; pw; pw = pw->next) { // Iconified means it was iconified at some point. if (pw->iconified) { @@ -99,7 +99,7 @@ PlaceIcon(TwmWindow *tmp_win, int def_x, int def_y) } } } - const int h = tmp_win->icon_w_height ? tmp_win->icon_w_height : 64; + const int h = win.icon_w_height ? win.icon_w_height : 64; if (occupied.size() == 0) { y = Scr->MyDisplayHeight - h; @@ -121,7 +121,7 @@ PlaceIcon(TwmWindow *tmp_win, int def_x, int def_y) Coord icon_pos { def_x, def_y }; if (y) { - const int w = tmp_win->icon_w_width ? tmp_win->icon_w_width : 64; + const int w = win.icon_w_width ? win.icon_w_width : 64; const int offset = (icon_area_w - w) / 2; icon_pos.first = icon_area_x + (offset > 0 ? offset : icon_pad); icon_pos.second = y; @@ -130,17 +130,17 @@ PlaceIcon(TwmWindow *tmp_win, int def_x, int def_y) } void -IconUp (TwmWindow *tmp_win) +IconUp (TwmWindow *win) { } void -IconDown (TwmWindow *tmp_win) +IconDown (TwmWindow *win) { } void -CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) +CreateIconWindow(TwmWindow* win, int def_x, int def_y) { unsigned long event_mask; unsigned long valuemask; /* mask for create windows */ @@ -149,10 +149,10 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) int x; - FB(tmp_win->iconc.fore, tmp_win->iconc.back); + FB(win->iconc.fore, win->iconc.back); - tmp_win->forced = FALSE; - tmp_win->icon_not_ours = FALSE; + win->forced = FALSE; + win->icon_not_ours = FALSE; /* now go through the steps to get an icon window, if ForceIcon is * set, then no matter what else is defined, the bitmap from the @@ -163,10 +163,10 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) char *icon_name; Pixmap bm; - icon_name = LookInNameList(Scr->IconNames, tmp_win->full_name); + icon_name = LookInNameList(Scr->IconNames, win->full_name); if (icon_name == NULL) - icon_name = LookInList(Scr->IconNames, tmp_win->full_name, - &tmp_win->classh); + icon_name = LookInList(Scr->IconNames, win->full_name, + &win->classh); bm = None; if (icon_name != NULL) @@ -181,17 +181,17 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) if (bm != None) { XGetGeometry(dpy, bm, &JunkRoot, &JunkX, &JunkY, - (unsigned int *) &tmp_win->icon_width, (unsigned int *)&tmp_win->icon_height, + (unsigned int *) &win->icon_width, (unsigned int *)&win->icon_height, &JunkBW, &JunkDepth); - pm = XCreatePixmap(dpy, Scr->Root, tmp_win->icon_width, - tmp_win->icon_height, Scr->d_depth); + pm = XCreatePixmap(dpy, Scr->Root, win->icon_width, + win->icon_height, Scr->d_depth); /* the copy plane works on color ! */ XCopyPlane(dpy, bm, pm, Scr->NormalGC, - 0,0, tmp_win->icon_width, tmp_win->icon_height, 0, 0, 1 ); + 0,0, win->icon_width, win->icon_height, 0, 0, 1 ); - tmp_win->forced = TRUE; + win->forced = TRUE; } } @@ -199,20 +199,20 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) * that could mean that ForceIcon was not set, or that the window * was not in the Icons list, now check the WM hints for an icon */ - if (pm == None && tmp_win->wmhints && - tmp_win->wmhints->flags & IconPixmapHint) + if (pm == None && win->wmhints && + win->wmhints->flags & IconPixmapHint) { - XGetGeometry(dpy, tmp_win->wmhints->icon_pixmap, + XGetGeometry(dpy, win->wmhints->icon_pixmap, &JunkRoot, &JunkX, &JunkY, - (unsigned int *)&tmp_win->icon_width, (unsigned int *)&tmp_win->icon_height, &JunkBW, &JunkDepth); + (unsigned int *)&win->icon_width, (unsigned int *)&win->icon_height, &JunkBW, &JunkDepth); pm = XCreatePixmap(dpy, Scr->Root, - tmp_win->icon_width, tmp_win->icon_height, + win->icon_width, win->icon_height, Scr->d_depth); - XCopyPlane(dpy, tmp_win->wmhints->icon_pixmap, pm, Scr->NormalGC, - 0,0, tmp_win->icon_width, tmp_win->icon_height, 0, 0, 1 ); + XCopyPlane(dpy, win->wmhints->icon_pixmap, pm, Scr->NormalGC, + 0,0, win->icon_width, win->icon_height, 0, 0, 1 ); } /* if we still haven't got an icon, let's look in the Icon list @@ -223,10 +223,10 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) char *icon_name; Pixmap bm; - icon_name = LookInNameList(Scr->IconNames, tmp_win->full_name); + icon_name = LookInNameList(Scr->IconNames, win->full_name); if (icon_name == NULL) - icon_name = LookInList(Scr->IconNames, tmp_win->full_name, - &tmp_win->classh); + icon_name = LookInList(Scr->IconNames, win->full_name, + &win->classh); bm = None; if (icon_name != NULL) @@ -241,15 +241,15 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) if (bm != None) { XGetGeometry(dpy, bm, &JunkRoot, &JunkX, &JunkY, - (unsigned int *)&tmp_win->icon_width, (unsigned int *)&tmp_win->icon_height, + (unsigned int *)&win->icon_width, (unsigned int *)&win->icon_height, &JunkBW, &JunkDepth); - pm = XCreatePixmap(dpy, Scr->Root, tmp_win->icon_width, - tmp_win->icon_height, Scr->d_depth); + pm = XCreatePixmap(dpy, Scr->Root, win->icon_width, + win->icon_height, Scr->d_depth); /* the copy plane works on color ! */ XCopyPlane(dpy, bm, pm, Scr->NormalGC, - 0,0, tmp_win->icon_width, tmp_win->icon_height, 0, 0, 1 ); + 0,0, win->icon_width, win->icon_height, 0, 0, 1 ); } } @@ -257,21 +257,21 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) if (pm == None && Scr->UnknownPm != None) { - tmp_win->icon_width = Scr->UnknownWidth; - tmp_win->icon_height = Scr->UnknownHeight; + win->icon_width = Scr->UnknownWidth; + win->icon_height = Scr->UnknownHeight; - pm = XCreatePixmap(dpy, Scr->Root, tmp_win->icon_width, - tmp_win->icon_height, Scr->d_depth); + pm = XCreatePixmap(dpy, Scr->Root, win->icon_width, + win->icon_height, Scr->d_depth); /* the copy plane works on color ! */ XCopyPlane(dpy, Scr->UnknownPm, pm, Scr->NormalGC, - 0,0, tmp_win->icon_width, tmp_win->icon_height, 0, 0, 1 ); + 0,0, win->icon_width, win->icon_height, 0, 0, 1 ); } if (pm == None) { - tmp_win->icon_height = 0; - tmp_win->icon_width = 0; + win->icon_height = 0; + win->icon_width = 0; valuemask = 0; } else @@ -280,74 +280,74 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) attributes.background_pixmap = pm; } - tmp_win->icon_w_width = MyFont_TextWidth(&Scr->IconFont, - tmp_win->icon_name, strlen(tmp_win->icon_name)); + win->icon_w_width = MyFont_TextWidth(&Scr->IconFont, + win->icon_name, strlen(win->icon_name)); - tmp_win->icon_w_width += 6; - if (tmp_win->icon_w_width < tmp_win->icon_width) + win->icon_w_width += 6; + if (win->icon_w_width < win->icon_width) { - tmp_win->icon_x = (tmp_win->icon_width - tmp_win->icon_w_width)/2; - tmp_win->icon_x += 3; - tmp_win->icon_w_width = tmp_win->icon_width; + win->icon_x = (win->icon_width - win->icon_w_width)/2; + win->icon_x += 3; + win->icon_w_width = win->icon_width; } else { - tmp_win->icon_x = 3; + win->icon_x = 3; } - tmp_win->icon_y = tmp_win->icon_height + Scr->IconFont.height; - tmp_win->icon_w_height = tmp_win->icon_height + Scr->IconFont.height + 4; + win->icon_y = win->icon_height + Scr->IconFont.height; + win->icon_w_height = win->icon_height + Scr->IconFont.height + 4; event_mask = 0; - if (tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint) + if (win->wmhints && 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, - (unsigned int *)&tmp_win->icon_w_width, (unsigned int *)&tmp_win->icon_w_height, + win->icon_w = win->wmhints->icon_window; + if (win->forced || + XGetGeometry(dpy, win->icon_w, &JunkRoot, &JunkX, &JunkY, + (unsigned int *)&win->icon_w_width, (unsigned int *)&win->icon_w_height, &JunkBW, &JunkDepth) == 0) { - tmp_win->icon_w = None; - tmp_win->wmhints->flags &= ~IconWindowHint; + win->icon_w = None; + win->wmhints->flags &= ~IconWindowHint; } else { - tmp_win->icon_not_ours = TRUE; + win->icon_not_ours = TRUE; event_mask = EnterWindowMask | LeaveWindowMask; } } else { - tmp_win->icon_w = None; + win->icon_w = None; } - if (tmp_win->icon_w == None) + if (win->icon_w == None) { - tmp_win->icon_w = XCreateSimpleWindow(dpy, Scr->Root, + win->icon_w = XCreateSimpleWindow(dpy, Scr->Root, 0,0, - tmp_win->icon_w_width, tmp_win->icon_w_height, - BW, tmp_win->icon_border, tmp_win->iconc.back); + win->icon_w_width, win->icon_w_height, + BW, win->icon_border, win->iconc.back); event_mask = ExposureMask; } - XSelectInput (dpy, tmp_win->icon_w, + XSelectInput (dpy, win->icon_w, KeyPressMask | ButtonPressMask | ButtonReleaseMask | event_mask); - tmp_win->icon_bm_w = None; + win->icon_bm_w = None; if (pm != None && - (! (tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint))) + (! (win->wmhints && win->wmhints->flags & IconWindowHint))) { int y; y = 0; - if (tmp_win->icon_w_width == tmp_win->icon_width) + if (win->icon_w_width == win->icon_width) x = 0; else - x = (tmp_win->icon_w_width - tmp_win->icon_width)/2; + x = (win->icon_w_width - win->icon_width)/2; - tmp_win->icon_bm_w = XCreateWindow (dpy, tmp_win->icon_w, x, y, - (unsigned int)tmp_win->icon_width, - (unsigned int)tmp_win->icon_height, + win->icon_bm_w = XCreateWindow (dpy, win->icon_w, x, y, + (unsigned int)win->icon_width, + (unsigned int)win->icon_height, (unsigned int) 0, Scr->d_depth, (unsigned int) CopyFromParent, Scr->d_visual, valuemask, @@ -358,31 +358,31 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) * getting here means that I am going to make the icon visible */ Coord icon_pos; - if (tmp_win->wmhints && - tmp_win->wmhints->flags & IconPositionHint) + if (win->wmhints && + win->wmhints->flags & IconPositionHint) { - icon_pos = {tmp_win->wmhints->icon_x, tmp_win->wmhints->icon_y}; + icon_pos = {win->wmhints->icon_x, win->wmhints->icon_y}; } else { - icon_pos = PlaceIcon(tmp_win, def_x, def_y, &final_x, &final_y); + icon_pos = PlaceIcon(*win, def_x, def_y); } if (icon_pos.first > Scr->MyDisplayWidth) - icon_pos.first = Scr->MyDisplayWidth - tmp_win->icon_w_width - BW2; + icon_pos.first = Scr->MyDisplayWidth - win->icon_w_width - BW2; if (icon_pos.second > Scr->MyDisplayHeight) - icon_pos.second = Scr->MyDisplayHeight - tmp_win->icon_height + icon_pos.second = Scr->MyDisplayHeight - win->icon_height - Scr->IconFont.height - 4 - BW2; - XMoveWindow(dpy, tmp_win->icon_w, icon_pos.first, icon_pos.second); - tmp_win->iconified = TRUE; + XMoveWindow(dpy, win->icon_w, icon_pos.first, icon_pos.second); + win->iconified = TRUE; - XMapSubwindows(dpy, tmp_win->icon_w); - XSaveContext(dpy, tmp_win->icon_w, TwmContext, (caddr_t)tmp_win); - XSaveContext(dpy, tmp_win->icon_w, ScreenContext, (caddr_t)Scr); - XDefineCursor(dpy, tmp_win->icon_w, Scr->IconCursor); + XMapSubwindows(dpy, win->icon_w); + XSaveContext(dpy, win->icon_w, TwmContext, (caddr_t)win); + XSaveContext(dpy, win->icon_w, ScreenContext, (caddr_t)Scr); + XDefineCursor(dpy, win->icon_w, Scr->IconCursor); if (pm) XFreePixmap(dpy, pm); }