simplified ISVISBLE and nexttiled
913333f5
1 file(s) · +19 −20
| 1 | - | /* TODO: cleanup nexttiled, ISVISIBLE, etc */ |
|
| 2 | 1 | /* See LICENSE file for copyright and license details. |
|
| 3 | 2 | * |
|
| 4 | 3 | * dynamic window manager is designed like any other X client as well. It is |
|
| 45 | 44 | #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) |
|
| 46 | 45 | #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) |
|
| 47 | 46 | #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH)) |
|
| 48 | - | #define ISVISIBLE(M, C) ((M) == (C->mon) && (C->tags & M->tagset[M->seltags])) |
|
| 47 | + | #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) |
|
| 49 | 48 | #define LENGTH(X) (sizeof X / sizeof X[0]) |
|
| 50 | 49 | #define MAX(A, B) ((A) > (B) ? (A) : (B)) |
|
| 51 | 50 | #define MIN(A, B) ((A) < (B) ? (A) : (B)) |
|
| 189 | 188 | static void maprequest(XEvent *e); |
|
| 190 | 189 | static void monocle(Monitor *m); |
|
| 191 | 190 | static void movemouse(const Arg *arg); |
|
| 192 | - | static Client *nexttiled(Monitor *m, Client *c); |
|
| 191 | + | static Client *nexttiled(Client *c); |
|
| 193 | 192 | static void propertynotify(XEvent *e); |
|
| 194 | 193 | static void quit(const Arg *arg); |
|
| 195 | 194 | static void resize(Client *c, int x, int y, int w, int h); |
|
| 550 | 549 | c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */ |
|
| 551 | 550 | if((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight))) |
|
| 552 | 551 | configure(c); |
|
| 553 | - | if(ISVISIBLE((c->mon), c)) |
|
| 552 | + | if(ISVISIBLE(c)) |
|
| 554 | 553 | XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); |
|
| 555 | 554 | } |
|
| 556 | 555 | else |
|
| 756 | 755 | ||
| 757 | 756 | void |
|
| 758 | 757 | focus(Client *c) { |
|
| 759 | - | if(!c || !ISVISIBLE((c->mon), c)) |
|
| 760 | - | for(c = selmon->stack; c && !ISVISIBLE(selmon, c); c = c->snext); |
|
| 758 | + | if(!c || !ISVISIBLE(c)) |
|
| 759 | + | for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); |
|
| 761 | 760 | if(selmon->sel && selmon->sel != c) { |
|
| 762 | 761 | grabbuttons(selmon->sel, False); |
|
| 763 | 762 | XSetWindowBorder(dpy, selmon->sel->win, dc.norm[ColBorder]); |
|
| 808 | 807 | if(!selmon->sel) |
|
| 809 | 808 | return; |
|
| 810 | 809 | if(arg->i > 0) { |
|
| 811 | - | for(c = selmon->sel->next; c && !ISVISIBLE(selmon, c); c = c->next); |
|
| 810 | + | for(c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next); |
|
| 812 | 811 | if(!c) |
|
| 813 | - | for(c = selmon->clients; c && !ISVISIBLE(selmon, c); c = c->next); |
|
| 812 | + | for(c = selmon->clients; c && !ISVISIBLE(c); c = c->next); |
|
| 814 | 813 | } |
|
| 815 | 814 | else { |
|
| 816 | 815 | for(i = selmon->clients; i != selmon->sel; i = i->next) |
|
| 817 | - | if(ISVISIBLE(selmon, i)) |
|
| 816 | + | if(ISVISIBLE(i)) |
|
| 818 | 817 | c = i; |
|
| 819 | 818 | if(!c) |
|
| 820 | 819 | for(; i; i = i->next) |
|
| 821 | - | if(ISVISIBLE(selmon, i)) |
|
| 820 | + | if(ISVISIBLE(i)) |
|
| 822 | 821 | c = i; |
|
| 823 | 822 | } |
|
| 824 | 823 | if(c) { |
|
| 1102 | 1101 | monocle(Monitor *m) { |
|
| 1103 | 1102 | Client *c; |
|
| 1104 | 1103 | ||
| 1105 | - | for(c = nexttiled(m, selmon->clients); c; c = nexttiled(m, c->next)) |
|
| 1104 | + | for(c = nexttiled(m->clients); c; c = nexttiled(c->next)) |
|
| 1106 | 1105 | resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw); |
|
| 1107 | 1106 | } |
|
| 1108 | 1107 | ||
| 1158 | 1157 | } |
|
| 1159 | 1158 | ||
| 1160 | 1159 | Client * |
|
| 1161 | - | nexttiled(Monitor *m, Client *c) { |
|
| 1160 | + | nexttiled(Client *c) { |
|
| 1162 | 1161 | // TODO: m handling |
|
| 1163 | - | for(; c && (c->isfloating || !ISVISIBLE(m, c)); c = c->next); |
|
| 1162 | + | for(; c && (c->isfloating || !ISVISIBLE(c)); c = c->next); |
|
| 1164 | 1163 | return c; |
|
| 1165 | 1164 | } |
|
| 1166 | 1165 | ||
| 1280 | 1279 | wc.stack_mode = Below; |
|
| 1281 | 1280 | wc.sibling = m->barwin; |
|
| 1282 | 1281 | for(c = m->stack; c; c = c->snext) |
|
| 1283 | - | if(!c->isfloating && ISVISIBLE(m, c)) { |
|
| 1282 | + | if(!c->isfloating && ISVISIBLE(c)) { |
|
| 1284 | 1283 | XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc); |
|
| 1285 | 1284 | wc.sibling = c->win; |
|
| 1286 | 1285 | } |
|
| 1432 | 1431 | showhide(Client *c) { |
|
| 1433 | 1432 | if(!c) |
|
| 1434 | 1433 | return; |
|
| 1435 | - | if(ISVISIBLE((c->mon), c)) { /* show clients top down */ |
|
| 1434 | + | if(ISVISIBLE(c)) { /* show clients top down */ |
|
| 1436 | 1435 | XMoveWindow(dpy, c->win, c->x, c->y); |
|
| 1437 | 1436 | if(!lt[c->mon->sellt]->arrange || c->isfloating) |
|
| 1438 | 1437 | resize(c, c->x, c->y, c->w, c->h); |
|
| 1504 | 1503 | unsigned int i, n; |
|
| 1505 | 1504 | Client *c; |
|
| 1506 | 1505 | ||
| 1507 | - | for(n = 0, c = nexttiled(m, m->clients); c; c = nexttiled(m, c->next), n++); |
|
| 1506 | + | for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); |
|
| 1508 | 1507 | if(n == 0) |
|
| 1509 | 1508 | return; |
|
| 1510 | 1509 | ||
| 1511 | 1510 | /* master */ |
|
| 1512 | - | c = nexttiled(m, m->clients); |
|
| 1511 | + | c = nexttiled(m->clients); |
|
| 1513 | 1512 | mw = m->mfact * m->ww; |
|
| 1514 | 1513 | resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw); |
|
| 1515 | 1514 | ||
| 1524 | 1523 | if(h < bh) |
|
| 1525 | 1524 | h = m->wh; |
|
| 1526 | 1525 | ||
| 1527 | - | for(i = 0, c = nexttiled(m, c->next); c; c = nexttiled(m, c->next), i++) { |
|
| 1526 | + | for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { |
|
| 1528 | 1527 | resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n) |
|
| 1529 | 1528 | ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw)); |
|
| 1530 | 1529 | if(h != m->wh) |
|
| 1883 | 1882 | ||
| 1884 | 1883 | if(!lt[selmon->sellt]->arrange || lt[selmon->sellt]->arrange == monocle || (selmon->sel && selmon->sel->isfloating)) |
|
| 1885 | 1884 | return; |
|
| 1886 | - | if(c == nexttiled(selmon, selmon->clients)) |
|
| 1887 | - | if(!c || !(c = nexttiled(selmon, c->next))) |
|
| 1885 | + | if(c == nexttiled(selmon->clients)) |
|
| 1886 | + | if(!c || !(c = nexttiled(c->next))) |
|
| 1888 | 1887 | return; |
|
| 1889 | 1888 | detach(c); |
|
| 1890 | 1889 | attach(c); |
|