]> git.armaanb.net Git - dwm.git/commitdiff
Apply push patch
authorArmaan Bhojwani <me@armaanb.net>
Mon, 21 Jun 2021 15:21:07 +0000 (11:21 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Mon, 21 Jun 2021 15:22:17 +0000 (11:22 -0400)
config.h
dwm.c

index 5498936c7ac78f8ae8f22a95fec4853cedb2942d..f386a011d2036b3d89798393dd2d76bf33975349 100644 (file)
--- a/config.h
+++ b/config.h
@@ -69,6 +69,8 @@ static Key keys[] = {
        { MODKEY,           XK_b,      togglebar,      {0} },
        { MODKEY,           XK_j,      focusstack,     {.i = +1 } },
        { MODKEY,           XK_k,      focusstack,     {.i = -1 } },
+       { MODKEY|ShiftMask, XK_j,      pushdown,       {0} },
+       { MODKEY|ShiftMask, XK_k,      pushup,         {0} },
        { MODKEY,           XK_i,      incnmaster,     {.i = +1 } },
        { MODKEY,           XK_d,      incnmaster,     {.i = -1 } },
        { MODKEY,           XK_h,      setmfact,       {.f = -0.05} },
diff --git a/dwm.c b/dwm.c
index 2202d3b90be4c9ec6eadc722152eb7af1e172972..4b4d10d91d8fa65b18fc556e1201319ef96af4ad 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -188,7 +188,10 @@ static void motionnotify(XEvent *e);
 static void movemouse(const Arg *arg);
 static Client *nexttiled(Client *c);
 static void pop(Client *);
+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);
@@ -1214,6 +1217,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)
 {
@@ -1251,6 +1264,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)
 {