about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--dwm.h1
-rw-r--r--event.c16
-rw-r--r--main.c7
-rw-r--r--view.c40
4 files changed, 32 insertions, 32 deletions
diff --git a/dwm.h b/dwm.h
index f9c4094..37151f9 100644
--- a/dwm.h
+++ b/dwm.h
@@ -96,6 +96,7 @@ extern const char *tags[];			/* all tags */
 extern char stext[1024];			/* status text */
 extern int bx, by, bw, bh, bmw;			/* bar geometry, bar mode label width */
 extern int screen, sx, sy, sw, sh;		/* screen geometry */
+extern int wax, way, wah, waw;			/* windowarea geometry */
 extern unsigned int master, ntags, numlockmask;	/* master percent, number of tags, dynamic lock mask */
 extern void (*handler[LASTEvent])(XEvent *);	/* event handler */
 extern void (*arrange)(void);			/* arrange function, indicates mode  */
diff --git a/event.c b/event.c
index e3bdea4..23dcf55 100644
--- a/event.c
+++ b/event.c
@@ -48,14 +48,14 @@ movemouse(Client *c) {
 			XSync(dpy, False);
 			c->x = ocx + (ev.xmotion.x - x1);
 			c->y = ocy + (ev.xmotion.y - y1);
-			if(abs(sx + c->x) < SNAP)
-				c->x = sx;
-			else if(abs((sx + sw) - (c->x + c->w)) < SNAP)
-				c->x = sw - c->w - 2 * BORDERPX;
-			if(abs((sy + bh) - c->y) < SNAP)
-				c->y = sy + bh;
-			else if(abs((sy + sh) - (c->y + c->h)) < SNAP)
-				c->y = sh - c->h - 2 * BORDERPX;
+			if(abs(wax + c->x) < SNAP)
+				c->x = wax;
+			else if(abs((wax + waw) - (c->x + c->w)) < SNAP)
+				c->x = wax + waw - c->w - 2 * BORDERPX;
+			if(abs(way - c->y) < SNAP)
+				c->y = way;
+			else if(abs((way + wah) - (c->y + c->h)) < SNAP)
+				c->y = way + wah - c->h - 2 * BORDERPX;
 			resize(c, False, TopLeft);
 			break;
 		}
diff --git a/main.c b/main.c
index 1e58176..0f22c44 100644
--- a/main.c
+++ b/main.c
@@ -18,7 +18,7 @@
 
 char stext[1024];
 Bool *seltag;
-int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh;
+int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh, wax, way, waw, wah;
 unsigned int master, ntags, numlockmask;
 Atom wmatom[WMLast], netatom[NetLast];
 Bool running = True;
@@ -142,6 +142,11 @@ setup(void) {
 	XDefineCursor(dpy, barwin, cursor[CurNormal]);
 	XMapRaised(dpy, barwin);
 	strcpy(stext, "dwm-"VERSION);
+	/* windowarea */
+	wax = sx;
+	way = bh;
+	wah = sh - bh;
+	waw = sw;
 	/* pixmap for everything */
 	dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
 	dc.gc = XCreateGC(dpy, root, 0, 0);
diff --git a/view.c b/view.c
index 0c9ea6f..bd43da9 100644
--- a/view.c
+++ b/view.c
@@ -49,10 +49,10 @@ togglemax(Client *c) {
 		return;
 
 	if((c->ismax = !c->ismax)) {
-		c->rx = c->x; c->x = sx;
-		c->ry = c->y; c->y = bh;
-		c->rw = c->w; c->w = sw - 2 * BORDERPX;
-		c->rh = c->h; c->h = sh - bh - 2 * BORDERPX;
+		c->rx = c->x; c->x = wax;
+		c->ry = c->y; c->y = way;
+		c->rw = c->w; c->w = waw - 2 * BORDERPX;
+		c->rh = c->h; c->h = wah - 2 * BORDERPX;
 	}
 	else {
 		c->x = c->rx;
@@ -99,17 +99,13 @@ dofloat(void) {
 
 void
 dotile(void) {
-	unsigned int i, n, mpx, stackw, stackh, th;
+	unsigned int i, n, mpx, stackw, th;
 	Client *c;
 
 	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
 		n++;
-	mpx = (sw * master) / 1000;
-	stackw = sw - mpx;
-	stackh = sh - bh;
-	th = stackh;
-	if(n > 1)
-		th /= (n - 1);
+	mpx = (waw * master) / 1000;
+	stackw = waw - mpx;
 
 	for(i = 0, c = clients; c; c = c->next)
 		if(isvisible(c)) {
@@ -118,28 +114,26 @@ dotile(void) {
 				continue;
 			}
 			c->ismax = False;
-			c->x = sx;
-			c->y = sy + bh;
+			c->x = wax;
+			c->y = way;
 			if(n == 1) { /* only 1 window */
-				c->w = sw - 2 * BORDERPX;
-				c->h = sh - 2 * BORDERPX - bh;
+				c->w = waw - 2 * BORDERPX;
+				c->h = wah - 2 * BORDERPX;
 			}
 			else if(i == 0) { /* master window */
-				c->w = mpx - 2 * BORDERPX;
-				c->h = sh - bh - 2 * BORDERPX;
+				c->w = waw - stackw - 2 * BORDERPX;
+				c->h = wah - 2 * BORDERPX;
+				th = wah / (n - 1);
 			}
 			else {  /* tile window */
 				c->x += mpx;
 				c->w = stackw - 2 * BORDERPX;
 				if(th > bh) {
-					c->y = sy + (i - 1) * th + bh;
-					if(i + 1 == n)
-						c->h = sh - c->y - 2 * BORDERPX;
-					else
-						c->h = th - 2 * BORDERPX;
+					c->y = way + (i - 1) * th;
+					c->h = th - 2 * BORDERPX;
 				}
 				else /* fallback if th < bh */
-					c->h = stackh - 2 * BORDERPX;
+					c->h = wah - 2 * BORDERPX;
 			}
 			resize(c, False, TopLeft);
 			i++;
id='n355' href='#n355'>355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388