From: Matthias Kruk Date: Sat, 13 Mar 2021 04:56:40 +0000 (+0900) Subject: Give more meaningful names to global two-letter variables X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=696a73406b137a1c85d357b0fdc4a3aa900ab9ae;p=dwm Give more meaningful names to global two-letter variables Without context, it's not obvious what sw or bl are supposed to mean. This commit renames these variables so the meaning can be gleaned from their names. --- diff --git a/dwm.c b/dwm.c index 9632c0c..7e30b3d 100755 --- a/dwm.c +++ b/dwm.c @@ -369,8 +369,10 @@ static unsigned long systrayorientation = _NET_SYSTEM_TRAY_ORIENTATION_HORZ; static const char broken[] = "broken"; static char stext[512]; static int screen; -static int sw, sh; /* X display screen geometry width, height */ -static int bh, blw = 0; /* bar geometry */ +static int screen_width; +static int screen_height; +static int bar_height; +static int bar_lwidth = 0; /* bar geometry */ static int (*xerrorxlib)(Display *, XErrorEvent *); static unsigned int numlockmask = 0; static void (*handler[LASTEvent]) (XEvent *) = { @@ -482,11 +484,11 @@ Bool applysizehints(struct client *c, int *x, int *y, int *w, int *h, Bool inter *h = MAX(1, *h); if(interact) { - if(*x > sw) { - *x = sw - client_get_width(c); + if(*x > screen_width) { + *x = screen_width - client_get_width(c); } - if(*y > sh) { - *y = sh - client_get_height(c); + if(*y > screen_height) { + *y = screen_height - client_get_height(c); } if(*x + *w + 2 * c->border.w < 0) { *x = 0; @@ -509,11 +511,11 @@ Bool applysizehints(struct client *c, int *x, int *y, int *w, int *h, Bool inter } } - if(*h < bh) { - *h = bh; + if(*h < bar_height) { + *h = bar_height; } - if(*w < bh) { - *w = bh; + if(*w < bar_height) { + *w = bar_height; } if(resizehints || c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) { @@ -639,7 +641,7 @@ void buttonpress(XEvent *e) if(i < LENGTH(tags)) { click = ClkTagBar; arg.ui = 1 << i; - } else if(ev->x < x + blw) { + } else if(ev->x < x + bar_lwidth) { click = ClkLtSymbol; } else if(ev->x > selmon->win_geom.w - TEXTW(stext)) { click = ClkStatusText; @@ -844,16 +846,17 @@ void configurenotify(XEvent *e) Bool dirty; if(ev->window == root) { - dirty = (sw != ev->width); - sw = ev->width; - sh = ev->height; + dirty = (screen_width != ev->width); + screen_width = ev->width; + screen_height = ev->height; if(updategeom() || dirty) { if(dc.drawable != 0) { XFreePixmap(dpy, dc.drawable); } - dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); + dc.drawable = XCreatePixmap(dpy, root, screen_width, + bar_height, DefaultDepth(dpy, screen)); XftDrawChange(dc.xft.drawable, dc.drawable); updatebars(); @@ -1047,7 +1050,8 @@ void drawbar(struct monitor *m) dc.geom.x += dc.geom.w; } - dc.geom.w = blw = TEXTW(m->ltsymbol); + dc.geom.w = TEXTW(m->ltsymbol); + bar_lwidth = dc.geom.w; drawtext(m->ltsymbol, dc.norm, False); dc.geom.x += dc.geom.w; x = dc.geom.x; @@ -1062,7 +1066,7 @@ void drawbar(struct monitor *m) drawtext(stext, dc.norm, False); - if((dc.geom.w = dc.geom.x - x) > bh) { + if((dc.geom.w = dc.geom.x - x) > bar_height) { dc.geom.x = x; if(m->sel) { @@ -1074,7 +1078,7 @@ void drawbar(struct monitor *m) } } - XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->win_geom.w, bh, 0, 0); + XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->win_geom.w, bar_height, 0, 0); XSync(dpy, False); return; @@ -1597,7 +1601,7 @@ void manage(Window w, XWindowAttributes *wa) /* only fix client y-offset, if the client center might cover the bar */ c->geom.y = MAX(c->geom.y, (c->mon->by == c->mon->geom.y && (c->geom.x + (c->geom.w / 2) >= c->mon->win_geom.x) && - (c->geom.x + (c->geom.w / 2) < c->mon->win_geom.x + c->mon->win_geom.w)) ? bh : c->mon->geom.y); + (c->geom.x + (c->geom.w / 2) < c->mon->win_geom.x + c->mon->win_geom.w)) ? bar_height : c->mon->geom.y); c->border.w = borderpx; wc.border_width = c->border.w; @@ -1620,7 +1624,7 @@ void manage(Window w, XWindowAttributes *wa) attach(c); attachstack(c); - XMoveResizeWindow(dpy, c->win, c->geom.x + 2 * sw, c->geom.y, c->geom.w, c->geom.h); /* some windows require this */ + XMoveResizeWindow(dpy, c->win, c->geom.x + 2 * screen_width, c->geom.y, c->geom.w, c->geom.h); /* some windows require this */ setclientstate(c, NormalState); if (c->mon == selmon) { @@ -1942,7 +1946,7 @@ void resizebarwin(struct monitor *m) w = m->win_geom.w - getsystraywidth(); - XMoveResizeWindow(dpy, m->barwin, m->win_geom.x, m->by, w, bh); + XMoveResizeWindow(dpy, m->barwin, m->win_geom.x, m->by, w, bar_height); return; } @@ -2298,9 +2302,9 @@ void setup(void) screen = DefaultScreen(dpy); root = RootWindow(dpy, screen); initfont(font); - sw = DisplayWidth(dpy, screen); - sh = DisplayHeight(dpy, screen); - bh = dc.geom.h = dc.font.height + 2; + screen_width = DisplayWidth(dpy, screen); + screen_height = DisplayHeight(dpy, screen); + bar_height = dc.geom.h = dc.font.height + 2; updategeom(); /* init atoms */ wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); @@ -2331,7 +2335,7 @@ void setup(void) dc.sel[ColBorder] = getcolor(selbordercolor, dc.xft.sel + ColBorder); dc.sel[ColBG] = getcolor(selbgcolor, dc.xft.sel + ColBG); dc.sel[ColFG] = getcolor(selfgcolor, dc.xft.sel + ColFG); - dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen)); + dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bar_height, DefaultDepth(dpy, screen)); dc.xft.drawable = XftDrawCreate(dpy, dc.drawable, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen)); dc.gc = XCreateGC(dpy, root, 0, NULL); XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); @@ -2713,7 +2717,7 @@ void updatebars(void) for(m = mons; m; m = m->next) { w = m->win_geom.w - getsystraywidth(); - m->barwin = XCreateWindow(dpy, root, m->win_geom.x, m->by, w, bh, 0, DefaultDepth(dpy, screen), + m->barwin = XCreateWindow(dpy, root, m->win_geom.x, m->by, w, bar_height, 0, DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); @@ -2728,9 +2732,9 @@ void updatebarpos(struct monitor *m) { m->win_geom.y = m->geom.y; m->win_geom.h = m->geom.h; - m->win_geom.h -= bh; + m->win_geom.h -= bar_height; m->by = m->topbar ? m->win_geom.y : m->win_geom.y + m->win_geom.h; - m->win_geom.y = m->topbar ? m->win_geom.y + bh : m->win_geom.y; + m->win_geom.y = m->topbar ? m->win_geom.y + bar_height : m->win_geom.y; return; } @@ -2820,10 +2824,10 @@ Bool updategeom(void) mons = createmon(); } - if(mons->geom.w != sw || mons->geom.h != sh) { + if(mons->geom.w != screen_width || mons->geom.h != screen_height) { dirty = True; - mons->geom.w = mons->win_geom.w = sw; - mons->geom.h = mons->win_geom.h = sh; + mons->geom.w = mons->win_geom.w = screen_width; + mons->geom.h = mons->win_geom.h = screen_height; updatebarpos(mons); } } @@ -2944,26 +2948,26 @@ void updatesystrayicongeom(struct client *i, int w, int h) return; } - i->geom.h = bh; + i->geom.h = bar_height; if(w == h) { - i->geom.w = bh; - } else if(h == bh) { + i->geom.w = bar_height; + } else if(h == bar_height) { i->geom.w = w; } else { - i->geom.w = (int) ((float)bh * ((float)w / (float)h)); + i->geom.w = (int) ((float)bar_height * ((float)w / (float)h)); } applysizehints(i, &(i->geom.x), &(i->geom.y), &(i->geom.w), &(i->geom.h), False); /* force icons into the systray dimenons if they don't want to */ - if(i->geom.h > bh) { + if(i->geom.h > bar_height) { if(i->geom.w == i->geom.h) { - i->geom.w = bh; + i->geom.w = bar_height; } else { - i->geom.w = (int) ((float)bh * ((float)i->geom.w / (float)i->geom.h)); + i->geom.w = (int) ((float)bar_height * ((float)i->geom.w / (float)i->geom.h)); } - i->geom.h = bh; + i->geom.h = bar_height; } return; @@ -3015,7 +3019,7 @@ void updatesystray(void) die("fatal: could not malloc() %u bytes\n", sizeof(*systray)); } - systray->win = XCreateSimpleWindow(dpy, root, x, selmon->by, w, bh, 0, 0, dc.sel[ColBG]); + systray->win = XCreateSimpleWindow(dpy, root, x, selmon->by, w, bar_height, 0, 0, dc.sel[ColBG]); wa.event_mask = ButtonPressMask | ExposureMask; wa.override_redirect = True; wa.background_pixmap = ParentRelative; @@ -3053,10 +3057,10 @@ void updatesystray(void) w = w ? w + systrayspacing : 1; x -= w; - XMoveResizeWindow(dpy, systray->win, x, selmon->by, w, bh); + XMoveResizeWindow(dpy, systray->win, x, selmon->by, w, bar_height); /* redraw background */ XSetForeground(dpy, dc.gc, dc.norm[ColBG]); - XFillRectangle(dpy, systray->win, dc.gc, 0, 0, w, bh); + XFillRectangle(dpy, systray->win, dc.gc, 0, 0, w, bar_height); XSync(dpy, False); return;