sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-attachabove-6.2-20200421.diff (1647B)


      1 diff --git a/local/src/dwm/dwm.c b/local/src/dwm/dwm.c
      2 index 83e44e0..94392b4 100644
      3 --- a/local/src/dwm/dwm.c
      4 +++ b/local/src/dwm/dwm.c
      5 @@ -164,6 +164,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 @@ -431,6 +432,20 @@ attach(Client *c)
     14  	c->mon->clients = c;
     15  }
     16  
     17 +void
     18 +attachabove(Client *c)
     19 +{
     20 +	if (c->mon->sel == NULL || c->mon->sel == c->mon->clients || c->mon->sel->isfloating) {
     21 +		attach(c);
     22 +		return;
     23 +	}
     24 +
     25 +	Client *at;
     26 +	for (at = c->mon->clients; at->next != c->mon->sel; at = at->next);
     27 +	c->next = at->next;
     28 +	at->next = c;
     29 +}
     30 +
     31  void
     32  attachstack(Client *c)
     33  {
     34 @@ -1272,7 +1287,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 @@ -1633,7 +1648,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 @@ -2122,7 +2137,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)