diff options
| author | gonzo <gonzo@toniatuh.com> | 2023-10-29 18:37:37 +0100 |
|---|---|---|
| committer | gonzo <gonzo@toniatuh.com> | 2023-10-29 18:37:37 +0100 |
| commit | 091f62154805381e35cf51501e2b86b04eb6d0e3 (patch) | |
| tree | 56d58037a2fb5284d5f6b336d9e513bf1050b5a5 | |
| parent | fa25b7b7c9f3af4708743410268454069562cd34 (diff) | |
| download | dwm-091f62154805381e35cf51501e2b86b04eb6d0e3.tar.gz | |
added push up and push down, xmonad style
| -rw-r--r-- | config.h | 3 | ||||
| -rw-r--r-- | dwm.c | 44 |
2 files changed, 47 insertions, 0 deletions
@@ -2,6 +2,7 @@ /* constants */ #define TERMINAL "xterm" +//#define TERMINAL "st" /* appearance */ static const unsigned int borderpx = 2; /* border pixel of windows */ @@ -91,7 +92,9 @@ static const Key keys[] = { { MODKEY, XK_c, togglescratch, {.ui = 1 } }, // spcalc { MODKEY, XK_s, togglesticky, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, + { MODKEY|ShiftMask, XK_j, pushdown, {0} }, { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY|ShiftMask, XK_k, pushup, {0} }, { MODKEY, XK_i, incnmaster, {.i = +1 } }, { MODKEY|ShiftMask, XK_i, incnmaster, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, @@ -190,7 +190,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); @@ -1249,6 +1252,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) { @@ -1287,6 +1300,37 @@ propertynotify(XEvent *e) } void +pushdown(const Arg *arg) { + Client *sel = selmon->sel, *c; + + if(!sel || sel->isfloating || sel == nexttiled(selmon->clients)) + return; + if((c = nexttiled(sel->next))) { + detach(sel); + sel->next = c->next; + c->next = sel; + } + focus(sel); + arrange(selmon); +} + +void +pushup(const Arg *arg) { + Client *sel = selmon->sel, *c; + + if(!sel || sel->isfloating) + return; + if((c = prevtiled(sel)) && c != nexttiled(selmon->clients)) { + detach(sel); + sel->next = c; + for(c = selmon->clients; c->next != sel->next; c = c->next); + c->next = sel; + } + focus(sel); + arrange(selmon); +} + +void quit(const Arg *arg) { running = 0; |
