[hackers] [dwm] introduced NOBORDER macro to hide the nasty - 2 * c->bw in various calculations, moved tagset to config.def.h || Anselm R Garbe

From: <hg_AT_suckless.org>
Date: Wed, 27 Aug 2008 14:03:43 +0000 (UTC)

changeset: 1346:2765f1a08494
parent: 1344:ba02dda36aee
user: Anselm R Garbe <garbeam_AT_gmail.com>
date: Wed Aug 27 12:52:44 2008 +0100
files: config.def.h dwm.c
description:
introduced NOBORDER macro to hide the nasty - 2 * c->bw in various calculations, moved tagset to config.def.h

diff -r ba02dda36aee -r 2765f1a08494 config.def.h
--- a/config.def.h Mon Aug 25 09:44:23 2008 +0100
+++ b/config.def.h Wed Aug 27 12:52:44 2008 +0100
@@ -16,6 +16,7 @@
 
 /* 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 -r ba02dda36aee -r 2765f1a08494 dwm.c
--- a/dwm.c Mon Aug 25 09:44:23 2008 +0100
+++ b/dwm.c Wed Aug 27 12:52:44 2008 +0100
@@ -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 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 @@
         }
         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 @@
         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 @@
                                 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 @@
         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 @@
                         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 @@
         /* 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 @@
                 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;
         }
Received on Wed Aug 27 2008 - 14:03:43 UTC

This archive was generated by hypermail 2.2.0 : Wed Aug 27 2008 - 14:12:04 UTC