From ec11a3470c2775a75df00e3b69ee6ef60a467e34 Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Wed, 27 Aug 2008 12:52:44 +0100 Subject: introduced NOBORDER macro to hide the nasty - 2 * c->bw in various calculations, moved tagset to config.def.h --- config.def.h | 1 + dwm.c | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/config.def.h b/config.def.h index e45faef..706cfa9 100644 --- a/config.def.h +++ b/config.def.h @@ -16,6 +16,7 @@ static Bool readin = True; /* False means do not read stdin /* tagging */ static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +static unsigned int tagset[] = {1, 1}; /* after start, first tag is selected */ static Rule rules[] = { /* class instance title tags mask isfloating */ diff --git a/dwm.c b/dwm.c index 89bca14..077c61e 100644 --- a/dwm.c +++ b/dwm.c @@ -53,6 +53,7 @@ #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAXTAGLEN 16 #define MOUSEMASK (BUTTONMASK|PointerMotionMask) +#define NOBORDER(x) ((x) - 2 * c->bw) #define TAGMASK ((int)((1LL << LENGTH(tags)) - 1)) #define TEXTW(x) (textnw(x, strlen(x)) + dc.font.height) @@ -227,7 +228,6 @@ static void (*handler[LASTEvent]) (XEvent *) = { static Atom wmatom[WMLast], netatom[NetLast]; static Bool otherwm; static Bool running = True; -static unsigned int tagset[] = {1, 1}; /* after start, first tag is selected */ static Client *clients = NULL; static Client *sel = NULL; static Client *stack = NULL; @@ -880,9 +880,9 @@ manage(Window w, XWindowAttributes *wa) { } else { if(c->x + c->w + 2 * c->bw > sx + sw) - c->x = sx + sw - c->w - 2 * c->bw; + c->x = sx + sw - NOBORDER(c->w); if(c->y + c->h + 2 * c->bw > sy + sh) - c->y = sy + sh - c->h - 2 * c->bw; + c->y = sy + sh - NOBORDER(c->h); c->x = MAX(c->x, sx); /* only fix client y-offset, if the client center might cover the bar */ c->y = MAX(c->y, ((by == 0) && (c->x + (c->w / 2) >= wx) && (c->x + (c->w / 2) < wx + ww)) ? bh : sy); @@ -942,7 +942,7 @@ monocle(void) { Client *c; for(c = nexttiled(clients); c; c = nexttiled(c->next)) - resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints); + resize(c, wx, wy, NOBORDER(ww), NOBORDER(wh), resizehints); } void @@ -979,11 +979,11 @@ movemouse(const Arg *arg) { if(abs(wx - nx) < snap) nx = wx; else if(abs((wx + ww) - (nx + c->w + 2 * c->bw)) < snap) - nx = wx + ww - c->w - 2 * c->bw; + nx = wx + ww - NOBORDER(c->w); if(abs(wy - ny) < snap) ny = wy; else if(abs((wy + wh) - (ny + c->h + 2 * c->bw)) < snap) - ny = wy + wh - c->h - 2 * c->bw; + ny = wy + wh - NOBORDER(c->h); if(!c->isfloating && lt[sellt]->arrange && (abs(nx - c->x) > snap || abs(ny - c->y) > snap)) togglefloating(NULL); } @@ -1091,9 +1091,9 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) { if(w <= 0 || h <= 0) return; if(x > sx + sw) - x = sw - w - 2 * c->bw; + x = sw - NOBORDER(w); if(y > sy + sh) - y = sh - h - 2 * c->bw; + y = sh - NOBORDER(h); if(x + w + 2 * c->bw < sx) x = sx; if(y + h + 2 * c->bw < sy) @@ -1141,8 +1141,8 @@ resizemouse(const Arg *arg) { break; case MotionNotify: XSync(dpy, False); - nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); - nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); + nw = MAX(ev.xmotion.x - NOBORDER(ocx) + 1, 1); + nh = MAX(ev.xmotion.y - NOBORDER(ocy) + 1, 1); if(snap && nw >= wx && nw <= wx + ww && nh >= wy && nh <= wy + wh) { @@ -1430,7 +1430,7 @@ tile(void) { /* master */ c = nexttiled(clients); mw = mfact * ww; - resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints); + resize(c, wx, wy, NOBORDER(n == 1 ? ww : mw), NOBORDER(wh), resizehints); if(--n == 0) return; @@ -1444,8 +1444,8 @@ tile(void) { h = wh; for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { - resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n) - ? (wy + wh) - y : h) - 2 * c->bw, resizehints); + resize(c, x, y, NOBORDER(w), /* remainder */ ((i + 1 == n) + ? NOBORDER(wy + wh) - y : h), resizehints); if(h != wh) y = c->y + c->h + 2 * c->bw; } -- cgit v1.2.3-70-g09d2