diff options
| author | Malfurious <m@lfurio.us> | 2024-02-29 15:22:06 -0500 |
|---|---|---|
| committer | Matt Hunter <m@lfurio.us> | 2026-01-18 00:18:46 -0500 |
| commit | beed57c13b21878f27778d3e76dd60f656fe9092 (patch) | |
| tree | b95ad8aa8ba8ac5f076b40a0668dc9fb5bd3660a | |
| parent | 910acdbcce502f99c39fd3e1b5efa9d528b636d3 (diff) | |
| download | dwm-beed57c13b21878f27778d3e76dd60f656fe9092.tar.gz dwm-beed57c13b21878f27778d3e76dd60f656fe9092.zip | |
patch: push
pushup and pushdown provide a way to move clients inside the clients
list.
| -rw-r--r-- | config.def.h | 2 | ||||
| -rw-r--r-- | dwm.c | 56 |
2 files changed, 58 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h index e27c892..af11a0e 100644 --- a/config.def.h +++ b/config.def.h @@ -91,6 +91,8 @@ static const Key keys[] = { { MODKEY|ShiftMask, XK_l, setmfact, {.f = 5/3.0} }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY|ShiftMask, XK_j, pushdown, {0} }, + { MODKEY|ShiftMask, XK_k, pushup, {0} }, { MODKEY, XK_Return, zoom, {0} }, { MODKEY, XK_Tab, view, {0} }, { MODKEY, XK_q, killclient, {0} }, @@ -195,7 +195,10 @@ static void movemouse(const Arg *arg); static Client *nexttiled(Client *c); static void philcollins(Monitor *m); 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); @@ -1376,6 +1379,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) { @@ -1414,6 +1427,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; |
