applied Gottox' windowarea patch

This commit is contained in:
arg@mig29 2006-11-16 14:40:57 +01:00
parent df1a0f9445
commit b003a35fde
4 changed files with 32 additions and 32 deletions

1
dwm.h
View File

@ -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 */

16
event.c
View File

@ -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;
}

7
main.c
View File

@ -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);

40
view.c
View File

@ -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++;