equal
deleted
inserted
replaced
126 unsigned int tags; |
126 unsigned int tags; |
127 Bool isfloating; |
127 Bool isfloating; |
128 } Rule; |
128 } Rule; |
129 |
129 |
130 /* function declarations */ |
130 /* function declarations */ |
131 static void adjustborder(Client *c, unsigned int bw); |
|
132 static void applyrules(Client *c); |
131 static void applyrules(Client *c); |
133 static void arrange(void); |
132 static void arrange(void); |
134 static void attach(Client *c); |
133 static void attach(Client *c); |
135 static void attachstack(Client *c); |
134 static void attachstack(Client *c); |
136 static void buttonpress(XEvent *e); |
135 static void buttonpress(XEvent *e); |
244 /* compile-time check if all tags fit into an unsigned int bit array. */ |
243 /* compile-time check if all tags fit into an unsigned int bit array. */ |
245 struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 : 1]; }; |
244 struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 : 1]; }; |
246 |
245 |
247 /* function implementations */ |
246 /* function implementations */ |
248 void |
247 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 |
|
259 applyrules(Client *c) { |
248 applyrules(Client *c) { |
260 unsigned int i; |
249 unsigned int i; |
261 Rule *r; |
250 Rule *r; |
262 XClassHint ch = { 0 }; |
251 XClassHint ch = { 0 }; |
263 |
252 |
937 manage(ev->window, &wa); |
926 manage(ev->window, &wa); |
938 } |
927 } |
939 |
928 |
940 void |
929 void |
941 monocle(void) { |
930 monocle(void) { |
942 unsigned int n; |
|
943 Client *c; |
931 Client *c; |
944 |
932 |
945 for(n = 0, c = nexttiled(clients); c && n < 2; c = nexttiled(c->next), n++); |
|
946 for(c = nexttiled(clients); c; c = nexttiled(c->next)) { |
933 for(c = nexttiled(clients); c; c = nexttiled(c->next)) { |
947 adjustborder(c, n == 1 ? 0 : borderpx); |
|
948 resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints); |
934 resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints); |
949 } |
935 } |
950 } |
936 } |
951 |
937 |
952 void |
938 void |
1347 void |
1333 void |
1348 showhide(Client *c, unsigned int ntiled) { |
1334 showhide(Client *c, unsigned int ntiled) { |
1349 if(!c) |
1335 if(!c) |
1350 return; |
1336 return; |
1351 if(ISVISIBLE(c)) { /* show clients top down */ |
1337 if(ISVISIBLE(c)) { /* show clients top down */ |
1352 if(c->isfloating || ntiled > 1) /* avoid unnecessary border reverts */ |
|
1353 adjustborder(c, borderpx); |
|
1354 XMoveWindow(dpy, c->win, c->x, c->y); |
1338 XMoveWindow(dpy, c->win, c->x, c->y); |
1355 if(!lt[sellt]->arrange || c->isfloating) |
1339 if(!lt[sellt]->arrange || c->isfloating) |
1356 resize(c, c->x, c->y, c->w, c->h, True); |
1340 resize(c, c->x, c->y, c->w, c->h, True); |
1357 showhide(c->snext, ntiled); |
1341 showhide(c->snext, ntiled); |
1358 } |
1342 } |
1412 return; |
1396 return; |
1413 |
1397 |
1414 /* master */ |
1398 /* master */ |
1415 c = nexttiled(clients); |
1399 c = nexttiled(clients); |
1416 mw = mfact * ww; |
1400 mw = mfact * ww; |
1417 adjustborder(c, n == 1 ? 0 : borderpx); |
|
1418 resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints); |
1401 resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints); |
1419 |
1402 |
1420 if(--n == 0) |
1403 if(--n == 0) |
1421 return; |
1404 return; |
1422 |
1405 |
1427 h = wh / n; |
1410 h = wh / n; |
1428 if(h < bh) |
1411 if(h < bh) |
1429 h = wh; |
1412 h = wh; |
1430 |
1413 |
1431 for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { |
1414 for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { |
1432 adjustborder(c, borderpx); |
|
1433 resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n) |
1415 resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n) |
1434 ? wy + wh - y - 2 * c->bw : h - 2 * c->bw), resizehints); |
1416 ? wy + wh - y - 2 * c->bw : h - 2 * c->bw), resizehints); |
1435 if(h != wh) |
1417 if(h != wh) |
1436 y = c->y + HEIGHT(c); |
1418 y = c->y + HEIGHT(c); |
1437 } |
1419 } |
1711 die("dwm-"VERSION", © 2006-2009 dwm engineers, see LICENSE for details\n"); |
1693 die("dwm-"VERSION", © 2006-2009 dwm engineers, see LICENSE for details\n"); |
1712 else if(argc != 1) |
1694 else if(argc != 1) |
1713 die("usage: dwm [-v]\n"); |
1695 die("usage: dwm [-v]\n"); |
1714 |
1696 |
1715 if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) |
1697 if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) |
1716 fprintf(stderr, "warning: no locale support\n"); |
1698 fputs("warning: no locale support\n", stderr); |
1717 |
1699 |
1718 if(!(dpy = XOpenDisplay(0))) |
1700 if(!(dpy = XOpenDisplay(0))) |
1719 die("dwm: cannot open display\n"); |
1701 die("dwm: cannot open display\n"); |
1720 |
1702 |
1721 checkotherwm(); |
1703 checkotherwm(); |