dwm-attachabove-20160713-56a31dc.diff (1609B)
1 diff --git a/dwm.c b/dwm.c 2 index b2bc9bd..5a380e6 100644 3 --- a/dwm.c 4 +++ b/dwm.c 5 @@ -148,6 +148,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 @@ -408,6 +409,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 @@ -1079,7 +1094,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 @@ -1437,7 +1452,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 @@ -1890,7 +1905,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)