diff options
author | Malfurious <m@lfurio.us> | 2022-02-12 10:08:02 -0500 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2023-06-03 22:05:34 -0400 |
commit | e95d3939f4756fe81f1555a839835bb91e61f28d (patch) | |
tree | db33d3c45311bb5cb2ca8be85aad00e9be069608 /dwm.c | |
parent | 5e386e97fcce76d5b460e3261abc29199b85b534 (diff) | |
download | dwm-e95d3939f4756fe81f1555a839835bb91e61f28d.tar.gz dwm-e95d3939f4756fe81f1555a839835bb91e61f28d.zip |
patch: push up/down
pushup and pushdown provide a way to move clients inside the clients
list.
Diffstat (limited to 'dwm.c')
-rw-r--r-- | dwm.c | 56 |
1 files changed, 56 insertions, 0 deletions
@@ -191,7 +191,10 @@ static void motionnotify(XEvent *e); static void movemouse(const Arg *arg); static Client *nexttiled(Client *c); static void pop(Client *c); +static Client *prevtiled(Client *c); static void propertynotify(XEvent *e); +static void pushdown(const Arg *arg); +static void pushup(const Arg *arg); static void quit(const Arg *arg); static Monitor *recttomon(int x, int y, int w, int h); static void resize(Client *c, int x, int y, int w, int h, int interact); @@ -1269,6 +1272,16 @@ pop(Client *c) arrange(c->mon); } +Client * +prevtiled(Client *c) { + Client *p, *r; + + for(p = selmon->clients, r = NULL; p && p != c; p = p->next) + if(!p->isfloating && ISVISIBLE(p)) + r = p; + return r; +} + void propertynotify(XEvent *e) { @@ -1307,6 +1320,49 @@ propertynotify(XEvent *e) } void +pushdown(const Arg *arg) { + Client *sel = selmon->sel, *c; + + if(!sel || sel->isfloating) + return; + if((c = nexttiled(sel->next))) { + detach(sel); + sel->next = c->next; + c->next = sel; + } else { + detach(sel); + attach(sel); + } + focus(sel); + arrange(selmon); +} + +void +pushup(const Arg *arg) { + Client *sel = selmon->sel, *c; + + if(!sel || sel->isfloating) + return; + if((c = prevtiled(sel))) { + detach(sel); + sel->next = c; + if(selmon->clients == c) + selmon->clients = sel; + else { + for(c = selmon->clients; c->next != sel->next; c = c->next); + c->next = sel; + } + } else { + for(c = sel; c->next; c = c->next); + detach(sel); + sel->next = NULL; + c->next = sel; + } + focus(sel); + arrange(selmon); +} + +void quit(const Arg *arg) { running = 0; |