dwm-attachabove-6.1.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       dwm-attachabove-6.1.diff (1609B)
       ---
            1 diff --git a/dwm.c b/dwm.c
            2 index 0362114..413ec1f 100644
            3 --- a/dwm.c
            4 +++ b/dwm.c
            5 @@ -147,6 +147,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
            6  static void arrange(Monitor *m);
            7  static void arrangemon(Monitor *m);
            8  static void attach(Client *c);
            9 +static void attachabove(Client *c);
           10  static void attachstack(Client *c);
           11  static void buttonpress(XEvent *e);
           12  static void checkotherwm(void);
           13 @@ -406,6 +407,20 @@ attach(Client *c)
           14  }
           15  
           16  void
           17 +attachabove(Client *c)
           18 +{
           19 +        if(c->mon->sel == NULL || c->mon->sel == c->mon->clients || c->mon->sel->isfloating) {
           20 +                attach(c);
           21 +                return;
           22 +        }
           23 +
           24 +        Client *at;
           25 +        for(at = c->mon->clients; at->next != c->mon->sel; at = at->next);
           26 +        c->next = at->next;
           27 +        at->next = c;
           28 +}
           29 +
           30 +void
           31  attachstack(Client *c)
           32  {
           33          c->snext = c->mon->stack;
           34 @@ -1076,7 +1091,7 @@ manage(Window w, XWindowAttributes *wa)
           35                  c->isfloating = c->oldstate = trans != None || c->isfixed;
           36          if (c->isfloating)
           37                  XRaiseWindow(dpy, c->win);
           38 -        attach(c);
           39 +        attachabove(c);
           40          attachstack(c);
           41          XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
           42                          (unsigned char *) &(c->win), 1);
           43 @@ -1434,7 +1449,7 @@ sendmon(Client *c, Monitor *m)
           44          detachstack(c);
           45          c->mon = m;
           46          c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
           47 -        attach(c);
           48 +        attachabove(c);
           49          attachstack(c);
           50          focus(NULL);
           51          arrange(NULL);
           52 @@ -1891,7 +1906,7 @@ updategeom(void)
           53                                          m->clients = c->next;
           54                                          detachstack(c);
           55                                          c->mon = mons;
           56 -                                        attach(c);
           57 +                                        attachabove(c);
           58                                          attachstack(c);
           59                                  }
           60                                  if (m == selmon)