diff options
| -rw-r--r-- | dwm.c | 25 |
1 files changed, 18 insertions, 7 deletions
| @@ -41,7 +41,6 @@ | |||
| 41 | #endif | 41 | #endif |
| 42 | 42 | ||
| 43 | /* macros */ | 43 | /* macros */ |
| 44 | #define ADJUSTBORDER(C, BW) if((C)->bw != (BW)) XSetWindowBorder(dpy, (C)->win, (BW)); | ||
| 45 | #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) | 44 | #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) |
| 46 | #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) | 45 | #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) |
| 47 | #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH)) | 46 | #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH)) |
| @@ -129,6 +128,7 @@ typedef struct { | |||
| 129 | } Rule; | 128 | } Rule; |
| 130 | 129 | ||
| 131 | /* function declarations */ | 130 | /* function declarations */ |
| 131 | static void adjustborder(Client *c, unsigned int bw); | ||
| 132 | static void applyrules(Client *c); | 132 | static void applyrules(Client *c); |
| 133 | static void arrange(void); | 133 | static void arrange(void); |
| 134 | static void attach(Client *c); | 134 | static void attach(Client *c); |
| @@ -246,6 +246,16 @@ struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 | |||
| 246 | 246 | ||
| 247 | /* function implementations */ | 247 | /* function implementations */ |
| 248 | void | 248 | void |
| 249 | adjustborder(Client *c, unsigned int bw) { | ||
| 250 | XWindowChanges wc; | ||
| 251 | |||
| 252 | if(c->bw != bw) { | ||
| 253 | c->bw = wc.border_width = bw; | ||
| 254 | XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); | ||
| 255 | } | ||
| 256 | } | ||
| 257 | |||
| 258 | void | ||
| 249 | applyrules(Client *c) { | 259 | applyrules(Client *c) { |
| 250 | unsigned int i; | 260 | unsigned int i; |
| 251 | Rule *r; | 261 | Rule *r; |
| @@ -930,7 +940,7 @@ monocle(void) { | |||
| 930 | 940 | ||
| 931 | for(n = 0, c = nexttiled(clients); c && n < 2; c = nexttiled(c->next), n++); | 941 | for(n = 0, c = nexttiled(clients); c && n < 2; c = nexttiled(c->next), n++); |
| 932 | for(c = nexttiled(clients); c; c = nexttiled(c->next)) { | 942 | for(c = nexttiled(clients); c; c = nexttiled(c->next)) { |
| 933 | ADJUSTBORDER(c, (n == 1 ? 0 : borderpx)) | 943 | adjustborder(c, n == 1 ? 0 : borderpx); |
| 934 | resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints); | 944 | resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints); |
| 935 | } | 945 | } |
| 936 | } | 946 | } |
| @@ -1137,8 +1147,9 @@ resizemouse(const Arg *arg) { | |||
| 1137 | handler[ev.type](&ev); | 1147 | handler[ev.type](&ev); |
| 1138 | break; | 1148 | break; |
| 1139 | case MotionNotify: | 1149 | case MotionNotify: |
| 1140 | nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); | 1150 | nw = MAX(ev.xmotion.x - ocx - 2*c->bw + 1, 1); |
| 1141 | nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); | 1151 | nh = MAX(ev.xmotion.y - ocy - 2*c->bw + 1, 1); |
| 1152 | |||
| 1142 | if(snap && nw >= wx && nw <= wx + ww | 1153 | if(snap && nw >= wx && nw <= wx + ww |
| 1143 | && nh >= wy && nh <= wy + wh) { | 1154 | && nh >= wy && nh <= wy + wh) { |
| 1144 | if(!c->isfloating && lt[sellt]->arrange | 1155 | if(!c->isfloating && lt[sellt]->arrange |
| @@ -1334,7 +1345,7 @@ showhide(Client *c) { | |||
| 1334 | if(!c) | 1345 | if(!c) |
| 1335 | return; | 1346 | return; |
| 1336 | if(ISVISIBLE(c)) { /* show clients top down */ | 1347 | if(ISVISIBLE(c)) { /* show clients top down */ |
| 1337 | ADJUSTBORDER(c, borderpx) | 1348 | adjustborder(c, borderpx); |
| 1338 | XMoveWindow(dpy, c->win, c->x, c->y); | 1349 | XMoveWindow(dpy, c->win, c->x, c->y); |
| 1339 | if(!lt[sellt]->arrange || c->isfloating) | 1350 | if(!lt[sellt]->arrange || c->isfloating) |
| 1340 | resize(c, c->x, c->y, c->w, c->h, True); | 1351 | resize(c, c->x, c->y, c->w, c->h, True); |
| @@ -1398,7 +1409,7 @@ tile(void) { | |||
| 1398 | /* master */ | 1409 | /* master */ |
| 1399 | c = nexttiled(clients); | 1410 | c = nexttiled(clients); |
| 1400 | mw = mfact * ww; | 1411 | mw = mfact * ww; |
| 1401 | ADJUSTBORDER(c, (n == 1 ? 0 : borderpx)) | 1412 | adjustborder(c, n == 1 ? 0 : borderpx); |
| 1402 | resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints); | 1413 | resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints); |
| 1403 | 1414 | ||
| 1404 | if(--n == 0) | 1415 | if(--n == 0) |
| @@ -1413,7 +1424,7 @@ tile(void) { | |||
| 1413 | h = wh; | 1424 | h = wh; |
| 1414 | 1425 | ||
| 1415 | for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { | 1426 | for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { |
| 1416 | ADJUSTBORDER(c, borderpx) | 1427 | adjustborder(c, borderpx); |
| 1417 | resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n) | 1428 | resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n) |
| 1418 | ? wy + wh - y - 2 * c->bw : h - 2 * c->bw), resizehints); | 1429 | ? wy + wh - y - 2 * c->bw : h - 2 * c->bw), resizehints); |
| 1419 | if(h != wh) | 1430 | if(h != wh) |
