sites

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

dwm-attachbelow-6.3.diff (2983B)


      1 diff --git a/config.def.h b/config.def.h
      2 index 1c0b587..cb8053a 100644
      3 --- a/config.def.h
      4 +++ b/config.def.h
      5 @@ -35,6 +35,7 @@ static const Rule rules[] = {
      6  static const float mfact     = 0.55; /* factor of master area size [0.05..0.95] */
      7  static const int nmaster     = 1;    /* number of clients in master area */
      8  static const int resizehints = 1;    /* 1 means respect size hints in tiled resizals */
      9 +static const int attachbelow = 1;    /* 1 means attach after the currently active window */
     10  
     11  static const Layout layouts[] = {
     12  	/* symbol     arrange function */
     13 diff --git a/dwm.1 b/dwm.1
     14 index 13b3729..fb6e76c 100644
     15 --- a/dwm.1
     16 +++ b/dwm.1
     17 @@ -29,6 +29,9 @@ color. The tags of the focused window are indicated with a filled square in the
     18  top left corner.  The tags which are applied to one or more windows are
     19  indicated with an empty square in the top left corner.
     20  .P
     21 +The attach below patch makes newly spawned windows attach after the currently
     22 +selected window
     23 +.P
     24  dwm draws a small border around windows to indicate the focus state.
     25  .SH OPTIONS
     26  .TP
     27 diff --git a/dwm.c b/dwm.c
     28 index 4465af1..bd715a2 100644
     29 --- a/dwm.c
     30 +++ b/dwm.c
     31 @@ -147,6 +147,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
     32  static void arrange(Monitor *m);
     33  static void arrangemon(Monitor *m);
     34  static void attach(Client *c);
     35 +static void attachBelow(Client *c);
     36  static void attachstack(Client *c);
     37  static void buttonpress(XEvent *e);
     38  static void checkotherwm(void);
     39 @@ -405,6 +406,21 @@ attach(Client *c)
     40  	c->next = c->mon->clients;
     41  	c->mon->clients = c;
     42  }
     43 +void
     44 +attachBelow(Client *c)
     45 +{
     46 +	//If there is nothing on the monitor or the selected client is floating, attach as normal
     47 +	if(c->mon->sel == NULL || c->mon->sel->isfloating) {
     48 +		attach(c);
     49 +		return;
     50 +	}
     51 +
     52 +	//Set the new client's next property to the same as the currently selected clients next
     53 +	c->next = c->mon->sel->next;
     54 +	//Set the currently selected clients next property to the new client
     55 +	c->mon->sel->next = c;
     56 +
     57 +}
     58  
     59  void
     60  attachstack(Client *c)
     61 @@ -1062,7 +1078,10 @@ manage(Window w, XWindowAttributes *wa)
     62  		c->isfloating = c->oldstate = trans != None || c->isfixed;
     63  	if (c->isfloating)
     64  		XRaiseWindow(dpy, c->win);
     65 -	attach(c);
     66 +	if( attachbelow )
     67 +		attachBelow(c);
     68 +	else
     69 +		attach(c);
     70  	attachstack(c);
     71  	XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
     72  		(unsigned char *) &(c->win), 1);
     73 @@ -1417,7 +1436,10 @@ sendmon(Client *c, Monitor *m)
     74  	detachstack(c);
     75  	c->mon = m;
     76  	c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
     77 -	attach(c);
     78 +	if( attachbelow )
     79 +		attachBelow(c);
     80 +	else
     81 +		attach(c);
     82  	attachstack(c);
     83  	focus(NULL);
     84  	arrange(NULL);
     85 @@ -1897,7 +1919,10 @@ updategeom(void)
     86  					m->clients = c->next;
     87  					detachstack(c);
     88  					c->mon = mons;
     89 -					attach(c);
     90 +					if( attachbelow )
     91 +						attachBelow(c);
     92 +					else
     93 +						attach(c);
     94  					attachstack(c);
     95  				}
     96  				if (m == selmon)