new config + uselessgap
[azarus-dwm.git] / push.c
blob08fe29bc5fcadfeb3cd8ca8c75e5a769b0149290
1 Client *
2 nextc(Client *c, float f) {
3 if(!f)
4 return nexttiled(c);
6 for(; c && !ISVISIBLE(c); c = c->next);
7 return c;
10 static Client *
11 prevc(Client *c, float f) {
12 Client *p, *r;
14 for(p = selmon->clients, r = NULL; c && p && p != c; p = p->next)
15 if((f || !p->isfloating) && ISVISIBLE(p))
16 r = p;
17 return r;
20 static void
21 pushup(const Arg *arg) {
22 Client *sel = selmon->sel;
23 Client *c;
25 if(!sel || (sel->isfloating && !arg->f))
26 return;
27 if((c = prevc(sel, arg->f))) {
28 /* attach before c */
29 detach(sel);
30 sel->next = c;
31 if(selmon->clients == c)
32 selmon->clients = sel;
33 else {
34 for(c = selmon->clients; c->next != sel->next; c = c->next);
35 c->next = sel;
37 } else {
38 /* move to the end */
39 for(c = sel; c->next; c = c->next);
40 detach(sel);
41 sel->next = NULL;
42 c->next = sel;
44 focus(sel);
45 arrange(selmon);
48 static void
49 pushdown(const Arg *arg) {
50 Client *sel = selmon->sel;
51 Client *c;
53 if(!sel || (sel->isfloating && !arg->f))
54 return;
55 if((c = nextc(sel->next, arg->f))) {
56 /* attach after c */
57 detach(sel);
58 sel->next = c->next;
59 c->next = sel;
60 } else {
61 /* move to the front */
62 detach(sel);
63 attach(sel);
65 focus(sel);
66 arrange(selmon);