| 145 |
145 |
|
void grabbuttons(Client *c, Bool focused); |
| 146 |
146 |
|
unsigned int idxoftag(const char *tag); |
| 147 |
147 |
|
void initfont(const char *fontstr); |
| 148 |
|
- |
Bool isarrange(void (*func)()); |
| 149 |
148 |
|
Bool isoccupied(unsigned int t); |
| 150 |
149 |
|
Bool isprotodel(Client *c); |
| 151 |
150 |
|
Bool isvisible(Client *c); |
|
| 198 |
197 |
|
int (*xerrorxlib)(Display *, XErrorEvent *); |
| 199 |
198 |
|
unsigned int bh, bpos; |
| 200 |
199 |
|
unsigned int blw = 0; |
| 201 |
|
- |
unsigned int ltidx = 0; /* default */ |
| 202 |
|
- |
unsigned int nlayouts = 0; |
| 203 |
|
- |
unsigned int nrules = 0; |
| 204 |
200 |
|
unsigned int numlockmask = 0; |
| 205 |
201 |
|
void (*handler[LASTEvent]) (XEvent *) = { |
| 206 |
202 |
|
[ButtonPress] = buttonpress, |
|
| 217 |
213 |
|
[UnmapNotify] = unmapnotify |
| 218 |
214 |
|
}; |
| 219 |
215 |
|
Atom wmatom[WMLast], netatom[NetLast]; |
|
216 |
+ |
Bool domwfact = True; |
|
217 |
+ |
Bool dozoom = True; |
| 220 |
218 |
|
Bool otherwm, readin; |
| 221 |
219 |
|
Bool running = True; |
| 222 |
220 |
|
Bool selscreen = True; |
|
| 226 |
224 |
|
Cursor cursor[CurLast]; |
| 227 |
225 |
|
Display *dpy; |
| 228 |
226 |
|
DC dc = {0}; |
|
227 |
+ |
Layout *layout = NULL; |
| 229 |
228 |
|
Window barwin, root; |
| 230 |
229 |
|
Regs *regs = NULL; |
| 231 |
230 |
|
|
|
| 246 |
245 |
|
snprintf(buf, sizeof buf, "%s:%s:%s", |
| 247 |
246 |
|
ch.res_class ? ch.res_class : "", |
| 248 |
247 |
|
ch.res_name ? ch.res_name : "", c->name); |
| 249 |
|
- |
for(i = 0; i < nrules; i++) |
|
248 |
+ |
for(i = 0; i < NRULES; i++) |
| 250 |
249 |
|
if(regs[i].propregex && !regexec(regs[i].propregex, buf, 1, &tmp, 0)) { |
| 251 |
250 |
|
c->isfloating = rules[i].isfloating; |
| 252 |
251 |
|
for(j = 0; regs[i].tagregex && j < NTAGS; j++) { |
|
| 273 |
272 |
|
unban(c); |
| 274 |
273 |
|
else |
| 275 |
274 |
|
ban(c); |
| 276 |
|
- |
layouts[ltidx].arrange(); |
|
275 |
+ |
layout->arrange(); |
| 277 |
276 |
|
focus(NULL); |
| 278 |
277 |
|
restack(); |
| 279 |
278 |
|
} |
|
| 334 |
333 |
|
if(CLEANMASK(ev->state) != MODKEY) |
| 335 |
334 |
|
return; |
| 336 |
335 |
|
if(ev->button == Button1) { |
| 337 |
|
- |
if(isarrange(floating) || c->isfloating) |
|
336 |
+ |
if((floating == layout->arrange) || c->isfloating) |
| 338 |
337 |
|
restack(); |
| 339 |
338 |
|
else |
| 340 |
339 |
|
togglefloating(NULL); |
| 341 |
340 |
|
movemouse(c); |
| 342 |
341 |
|
} |
| 343 |
342 |
|
else if(ev->button == Button2) { |
| 344 |
|
- |
if((ISTILE) && !c->isfixed && c->isfloating) |
|
343 |
+ |
if((floating != layout->arrange) && !c->isfixed && c->isfloating) |
| 345 |
344 |
|
togglefloating(NULL); |
| 346 |
345 |
|
else |
| 347 |
346 |
|
zoom(NULL); |
| 348 |
347 |
|
} |
| 349 |
348 |
|
else if(ev->button == Button3 && !c->isfixed) { |
| 350 |
|
- |
if(isarrange(floating) || c->isfloating) |
|
349 |
+ |
if((floating == layout->arrange) || c->isfloating) |
| 351 |
350 |
|
restack(); |
| 352 |
351 |
|
else |
| 353 |
352 |
|
togglefloating(NULL); |
|
| 401 |
400 |
|
|
| 402 |
401 |
|
if(regs) |
| 403 |
402 |
|
return; |
| 404 |
|
- |
nrules = sizeof rules / sizeof rules[0]; |
| 405 |
|
- |
regs = emallocz(nrules * sizeof(Regs)); |
| 406 |
|
- |
for(i = 0; i < nrules; i++) { |
|
403 |
+ |
regs = emallocz(NRULES * sizeof(Regs)); |
|
404 |
+ |
for(i = 0; i < NRULES; i++) { |
| 407 |
405 |
|
if(rules[i].prop) { |
| 408 |
406 |
|
reg = emallocz(sizeof(regex_t)); |
| 409 |
407 |
|
if(regcomp(reg, rules[i].prop, REG_EXTENDED)) |
|
| 464 |
462 |
|
c->ismax = False; |
| 465 |
463 |
|
if(ev->value_mask & CWBorderWidth) |
| 466 |
464 |
|
c->border = ev->border_width; |
| 467 |
|
- |
if(c->isfixed || c->isfloating || isarrange(floating)) { |
|
465 |
+ |
if(c->isfixed || c->isfloating || (floating == layout->arrange)) { |
| 468 |
466 |
|
if(ev->value_mask & CWX) |
| 469 |
467 |
|
c->x = ev->x; |
| 470 |
468 |
|
if(ev->value_mask & CWY) |
|
| 545 |
543 |
|
dc.x += dc.w; |
| 546 |
544 |
|
} |
| 547 |
545 |
|
dc.w = blw; |
| 548 |
|
- |
drawtext(layouts[ltidx].symbol, dc.norm); |
|
546 |
+ |
drawtext(layout->symbol, dc.norm); |
| 549 |
547 |
|
x = dc.x + dc.w; |
| 550 |
548 |
|
dc.w = textw(stext); |
| 551 |
549 |
|
dc.x = sw - dc.w; |
|
| 676 |
674 |
|
floating(void) { /* default floating layout */ |
| 677 |
675 |
|
Client *c; |
| 678 |
676 |
|
|
|
677 |
+ |
domwfact = dozoom = False; |
| 679 |
678 |
|
for(c = clients; c; c = c->next) |
| 680 |
679 |
|
if(isvisible(c)) |
| 681 |
680 |
|
resize(c, c->x, c->y, c->w, c->h, True); |
|
| 889 |
888 |
|
} |
| 890 |
889 |
|
|
| 891 |
890 |
|
Bool |
| 892 |
|
- |
isarrange(void (*func)()) |
| 893 |
|
- |
{ |
| 894 |
|
- |
return func == layouts[ltidx].arrange; |
| 895 |
|
- |
} |
| 896 |
|
- |
|
| 897 |
|
- |
Bool |
| 898 |
891 |
|
isoccupied(unsigned int t) { |
| 899 |
892 |
|
Client *c; |
| 900 |
893 |
|
|
|
| 932 |
925 |
|
void |
| 933 |
926 |
|
keypress(XEvent *e) { |
| 934 |
927 |
|
KEYS |
| 935 |
|
- |
unsigned int len = sizeof keys / sizeof keys[0]; |
| 936 |
928 |
|
unsigned int i; |
| 937 |
929 |
|
KeyCode code; |
| 938 |
930 |
|
KeySym keysym; |
|
| 940 |
932 |
|
|
| 941 |
933 |
|
if(!e) { /* grabkeys */ |
| 942 |
934 |
|
XUngrabKey(dpy, AnyKey, AnyModifier, root); |
| 943 |
|
- |
for(i = 0; i < len; i++) { |
|
935 |
+ |
for(i = 0; i < NKEYS; i++) { |
| 944 |
936 |
|
code = XKeysymToKeycode(dpy, keys[i].keysym); |
| 945 |
937 |
|
XGrabKey(dpy, code, keys[i].mod, root, True, |
| 946 |
938 |
|
GrabModeAsync, GrabModeAsync); |
|
| 955 |
947 |
|
} |
| 956 |
948 |
|
ev = &e->xkey; |
| 957 |
949 |
|
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); |
| 958 |
|
- |
for(i = 0; i < len; i++) |
|
950 |
+ |
for(i = 0; i < NKEYS; i++) |
| 959 |
951 |
|
if(keysym == keys[i].keysym |
| 960 |
952 |
|
&& CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)) |
| 961 |
953 |
|
{ |
|
| 1266 |
1258 |
|
drawbar(); |
| 1267 |
1259 |
|
if(!sel) |
| 1268 |
1260 |
|
return; |
| 1269 |
|
- |
if(sel->isfloating || isarrange(floating)) |
|
1261 |
+ |
if(sel->isfloating || (floating == layout->arrange)) |
| 1270 |
1262 |
|
XRaiseWindow(dpy, sel->win); |
| 1271 |
|
- |
if(!isarrange(floating)) { |
|
1263 |
+ |
if(floating != layout->arrange) { |
| 1272 |
1264 |
|
wc.stack_mode = Below; |
| 1273 |
1265 |
|
wc.sibling = barwin; |
| 1274 |
1266 |
|
if(!sel->isfloating) { |
|
| 1374 |
1366 |
|
unsigned int i; |
| 1375 |
1367 |
|
|
| 1376 |
1368 |
|
if(!arg) { |
| 1377 |
|
- |
if(++ltidx == nlayouts) |
| 1378 |
|
- |
ltidx = 0;; |
|
1369 |
+ |
if(++layout == &layouts[NLAYOUTS]) |
|
1370 |
+ |
layout = &layouts[0]; |
| 1379 |
1371 |
|
} |
| 1380 |
1372 |
|
else { |
| 1381 |
|
- |
for(i = 0; i < nlayouts; i++) |
|
1373 |
+ |
for(i = 0; i < NLAYOUTS; i++) |
| 1382 |
1374 |
|
if(!strcmp(arg, layouts[i].symbol)) |
| 1383 |
1375 |
|
break; |
| 1384 |
|
- |
if(i == nlayouts) |
|
1376 |
+ |
if(i == NLAYOUTS) |
| 1385 |
1377 |
|
return; |
| 1386 |
|
- |
ltidx = i; |
|
1378 |
+ |
layout = &layouts[i]; |
| 1387 |
1379 |
|
} |
| 1388 |
1380 |
|
if(sel) |
| 1389 |
1381 |
|
arrange(); |
|
| 1395 |
1387 |
|
setmwfact(const char *arg) { |
| 1396 |
1388 |
|
double delta; |
| 1397 |
1389 |
|
|
| 1398 |
|
- |
if(!(ISTILE)) |
|
1390 |
+ |
if(!domwfact) |
| 1399 |
1391 |
|
return; |
| 1400 |
1392 |
|
/* arg handling, manipulate mwfact */ |
| 1401 |
1393 |
|
if(NULL == arg) |
|
| 1476 |
1468 |
|
|
| 1477 |
1469 |
|
/* init layouts */ |
| 1478 |
1470 |
|
mwfact = MWFACT; |
| 1479 |
|
- |
nlayouts = sizeof layouts / sizeof layouts[0]; |
| 1480 |
|
- |
for(blw = i = 0; i < nlayouts; i++) { |
|
1471 |
+ |
layout = &layouts[0]; |
|
1472 |
+ |
for(blw = i = 0; i < NLAYOUTS; i++) { |
| 1481 |
1473 |
|
j = textw(layouts[i].symbol); |
| 1482 |
1474 |
|
if(j > blw) |
| 1483 |
1475 |
|
blw = j; |
|
| 1562 |
1554 |
|
unsigned int i, n, nx, ny, nw, nh, mw, th; |
| 1563 |
1555 |
|
Client *c, *mc; |
| 1564 |
1556 |
|
|
|
1557 |
+ |
domwfact = dozoom = True; |
| 1565 |
1558 |
|
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) |
| 1566 |
1559 |
|
n++; |
| 1567 |
1560 |
|
|
|
| 1627 |
1620 |
|
if(!sel || sel->isfixed) |
| 1628 |
1621 |
|
return; |
| 1629 |
1622 |
|
if((sel->ismax = !sel->ismax)) { |
| 1630 |
|
- |
if(isarrange(floating) || sel->isfloating) |
|
1623 |
+ |
if((floating == layout->arrange) || sel->isfloating) |
| 1631 |
1624 |
|
sel->wasfloating = True; |
| 1632 |
1625 |
|
else { |
| 1633 |
1626 |
|
togglefloating(NULL); |
|
| 1855 |
1848 |
|
zoom(const char *arg) { |
| 1856 |
1849 |
|
Client *c; |
| 1857 |
1850 |
|
|
| 1858 |
|
- |
if(!sel || !(ISTILE) || sel->isfloating) |
|
1851 |
+ |
if(!sel || !dozoom || sel->isfloating) |
| 1859 |
1852 |
|
return; |
| 1860 |
1853 |
|
if((c = sel) == nexttiled(clients)) |
| 1861 |
1854 |
|
if(!(c = nexttiled(c->next))) |