]> git.mdlowis.com Git - proto/iwe.git/commitdiff
Applied attachabove patch to dwm cleanly
authorMike Lowis <mike.lowis@gentex.com>
Fri, 16 Sep 2016 12:47:19 +0000 (08:47 -0400)
committerMike Lowis <mike.lowis@gentex.com>
Fri, 16 Sep 2016 12:47:19 +0000 (08:47 -0400)
dwm/dwm.c
patches/dwm-attachabove-6.1.diff [new file with mode: 0644]

index 0362114f569855985b149f409fe3049b4f4090f0..413ec1fcc8aa5401e03f9c44e8625fdadd84a334 100644 (file)
--- a/dwm/dwm.c
+++ b/dwm/dwm.c
@@ -147,6 +147,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
 static void arrange(Monitor *m);
 static void arrangemon(Monitor *m);
 static void attach(Client *c);
+static void attachabove(Client *c);
 static void attachstack(Client *c);
 static void buttonpress(XEvent *e);
 static void checkotherwm(void);
@@ -405,6 +406,20 @@ attach(Client *c)
        c->mon->clients = c;
 }
 
+void
+attachabove(Client *c)
+{
+       if(c->mon->sel == NULL || c->mon->sel == c->mon->clients || c->mon->sel->isfloating) {
+               attach(c);
+               return;
+       }
+
+       Client *at;
+       for(at = c->mon->clients; at->next != c->mon->sel; at = at->next);
+       c->next = at->next;
+       at->next = c;
+}
+
 void
 attachstack(Client *c)
 {
@@ -1076,7 +1091,7 @@ manage(Window w, XWindowAttributes *wa)
                c->isfloating = c->oldstate = trans != None || c->isfixed;
        if (c->isfloating)
                XRaiseWindow(dpy, c->win);
-       attach(c);
+       attachabove(c);
        attachstack(c);
        XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
                        (unsigned char *) &(c->win), 1);
@@ -1434,7 +1449,7 @@ sendmon(Client *c, Monitor *m)
        detachstack(c);
        c->mon = m;
        c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
-       attach(c);
+       attachabove(c);
        attachstack(c);
        focus(NULL);
        arrange(NULL);
@@ -1891,7 +1906,7 @@ updategeom(void)
                                        m->clients = c->next;
                                        detachstack(c);
                                        c->mon = mons;
-                                       attach(c);
+                                       attachabove(c);
                                        attachstack(c);
                                }
                                if (m == selmon)
diff --git a/patches/dwm-attachabove-6.1.diff b/patches/dwm-attachabove-6.1.diff
new file mode 100644 (file)
index 0000000..8c28b3e
--- /dev/null
@@ -0,0 +1,60 @@
+diff --git a/dwm.c b/dwm.c
+index 0362114..413ec1f 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -147,6 +147,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
+ static void arrange(Monitor *m);
+ static void arrangemon(Monitor *m);
+ static void attach(Client *c);
++static void attachabove(Client *c);
+ static void attachstack(Client *c);
+ static void buttonpress(XEvent *e);
+ static void checkotherwm(void);
+@@ -406,6 +407,20 @@ attach(Client *c)
+ }
+ void
++attachabove(Client *c)
++{
++      if(c->mon->sel == NULL || c->mon->sel == c->mon->clients || c->mon->sel->isfloating) {
++              attach(c);
++              return;
++      }
++
++      Client *at;
++      for(at = c->mon->clients; at->next != c->mon->sel; at = at->next);
++      c->next = at->next;
++      at->next = c;
++}
++
++void
+ attachstack(Client *c)
+ {
+       c->snext = c->mon->stack;
+@@ -1076,7 +1091,7 @@ manage(Window w, XWindowAttributes *wa)
+               c->isfloating = c->oldstate = trans != None || c->isfixed;
+       if (c->isfloating)
+               XRaiseWindow(dpy, c->win);
+-      attach(c);
++      attachabove(c);
+       attachstack(c);
+       XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
+                       (unsigned char *) &(c->win), 1);
+@@ -1434,7 +1449,7 @@ sendmon(Client *c, Monitor *m)
+       detachstack(c);
+       c->mon = m;
+       c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
+-      attach(c);
++      attachabove(c);
+       attachstack(c);
+       focus(NULL);
+       arrange(NULL);
+@@ -1891,7 +1906,7 @@ updategeom(void)
+                                       m->clients = c->next;
+                                       detachstack(c);
+                                       c->mon = mons;
+-                                      attach(c);
++                                      attachabove(c);
+                                       attachstack(c);
+                               }
+                               if (m == selmon)