commit 11ff2105d4ba67855d4a5520ad4151bdb9d8afe5
parent 8d696af2768ceeb17dcbd74cac8e910aba6ff333
Author: Miles Alan <m@milesalan.com>
Date: Wed, 29 Apr 2020 20:36:24 -0500
Add Pushup/down patch
Diffstat:
| M | config.def.h | | | 7 | +++---- |
| M | dwm.c | | | 72 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 files changed, 75 insertions(+), 4 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -111,10 +111,8 @@ static Key keys[] = {
{ 0, MODKEY, XK_j, focusstack, {.i = +1 } },
{ 0, MODKEY, XK_k, focusstack, {.i = -1 } },
- { 1, MODKEY|ShiftMask, XK_j, inplacerotate, {.i = +1} },
- { 1, MODKEY|ShiftMask, XK_k, inplacerotate, {.i = -1} },
- { 2, MODKEY|ShiftMask, XK_j, inplacerotate, {.i = +2} },
- { 2, MODKEY|ShiftMask, XK_k, inplacerotate, {.i = -2} },
+ { 0, MODKEY|ShiftMask, XK_j, pushdown, {.i = +1 } },
+ { 0, MODKEY|ShiftMask, XK_k, pushup, {.i = -1 } },
{ 0, MODKEY, XK_i, incnmaster, {.i = +1 } },
{ 0, MODKEY, XK_o, incnmaster, {.i = -1 } },
@@ -132,6 +130,7 @@ static Key keys[] = {
{ 1, MODKEY, XK_t, transfer, {0} },
{ 2, MODKEY, XK_t, transferall, {0} },
+
/* float */
{ 0, MODKEY, XK_space, setlayout, {0} },
/* monocle */
diff --git a/dwm.c b/dwm.c
@@ -258,6 +258,8 @@ static void bstack(Monitor *m);
static void bstackhoriz(Monitor *m);
static void clienttagpush(const Arg *arg);
static void shiftview(const Arg *arg);
+static void pushup(const Arg *arg);
+static void pushdown(const Arg *arg);
static pid_t getparentprocess(pid_t p);
static int isdescprocess(pid_t p, pid_t c);
@@ -2938,3 +2940,73 @@ transferall(const Arg *arg) {
selmon->nmaster = nstackclients;
arrange(selmon);
}
+
+static Client *
+nextc(Client *c, float f) {
+ if(!f)
+ return nexttiled(c);
+
+ for(; c && !ISVISIBLE(c); c = c->next);
+ return c;
+}
+
+static Client *
+prevc(Client *c, float f) {
+ Client *p, *r;
+
+ for(p = selmon->clients, r = NULL; c && p && p != c; p = p->next)
+ if((f || !p->isfloating) && ISVISIBLE(p))
+ r = p;
+ return r;
+}
+
+
+static void
+pushup(const Arg *arg) {
+ Client *sel = selmon->sel;
+ Client *c;
+
+ if(!sel || (sel->isfloating && !arg->f))
+ return;
+ if((c = prevc(sel, arg->f))) {
+ /* attach before c */
+ 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 {
+ /* move to the end */
+ for(c = sel; c->next; c = c->next);
+ detach(sel);
+ sel->next = NULL;
+ c->next = sel;
+ }
+ focus(sel);
+ arrange(selmon);
+}
+
+static void
+pushdown(const Arg *arg) {
+ Client *sel = selmon->sel;
+ Client *c;
+
+ if(!sel || (sel->isfloating && !arg->f))
+ return;
+ if((c = nextc(sel->next, arg->f))) {
+ /* attach after c */
+ detach(sel);
+ sel->next = c->next;
+ c->next = sel;
+ } else {
+ /* move to the front */
+ detach(sel);
+ attach(sel);
+ }
+ focus(sel);
+ arrange(selmon);
+}
+