attachabove - dwm - dynamic window manager
 (HTM) git clone https://git.parazyd.org/dwm
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 5581ad51344486680d377831ab21dd1d0190b2d5
 (DIR) parent 64ec191cb2bf0410d2ad23665dac3712fe26f70b
 (HTM) Author: parazyd <parazyd@dyne.org>
       Date:   Sun, 24 Apr 2022 11:16:15 +0200
       
       attachabove
       
       Diffstat:
         M dwm.c                               |      20 +++++++++++++++++---
       
       1 file changed, 17 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/dwm.c b/dwm.c
       @@ -456,6 +456,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;
       @@ -1231,7 +1245,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);
       @@ -1637,7 +1651,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);
       @@ -2281,7 +2295,7 @@ updategeom(void)
                                        m->clients = c->next;
                                        detachstack(c);
                                        c->mon = mons;
       -                                attach(c);
       +                                attachabove(c);
                                        attachstack(c);
                                }
                                if (m == selmon)