sites

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

dwm-attachaside-6.4.diff (2784B)


      1 diff --git a/dwm.c b/dwm.c
      2 index f1d86b2..8b04e0b 100644
      3 --- a/dwm.c
      4 +++ b/dwm.c
      5 @@ -49,7 +49,8 @@
      6  #define CLEANMASK(mask)         (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
      7  #define INTERSECT(x,y,w,h,m)    (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
      8                                 * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
      9 -#define ISVISIBLE(C)            ((C->tags & C->mon->tagset[C->mon->seltags]))
     10 +#define ISVISIBLEONTAG(C, T)    ((C->tags & T))
     11 +#define ISVISIBLE(C)            ISVISIBLEONTAG(C, C->mon->tagset[C->mon->seltags])
     12  #define LENGTH(X)               (sizeof X / sizeof X[0])
     13  #define MOUSEMASK               (BUTTONMASK|PointerMotionMask)
     14  #define WIDTH(X)                ((X)->w + 2 * (X)->bw)
     15 @@ -147,6 +148,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
     16  static void arrange(Monitor *m);
     17  static void arrangemon(Monitor *m);
     18  static void attach(Client *c);
     19 +static void attachaside(Client *c);
     20  static void attachstack(Client *c);
     21  static void buttonpress(XEvent *e);
     22  static void checkotherwm(void);
     23 @@ -184,6 +186,7 @@ static void maprequest(XEvent *e);
     24  static void monocle(Monitor *m);
     25  static void motionnotify(XEvent *e);
     26  static void movemouse(const Arg *arg);
     27 +static Client *nexttagged(Client *c);
     28  static Client *nexttiled(Client *c);
     29  static void pop(Client *c);
     30  static void propertynotify(XEvent *e);
     31 @@ -408,6 +411,17 @@ attach(Client *c)
     32  	c->mon->clients = c;
     33  }
     34  
     35 +void
     36 +attachaside(Client *c) {
     37 +	Client *at = nexttagged(c);
     38 +	if(!at) {
     39 +		attach(c);
     40 +		return;
     41 +	}
     42 +	c->next = at->next;
     43 +	at->next = c;
     44 +}
     45 +
     46  void
     47  attachstack(Client *c)
     48  {
     49 @@ -1074,7 +1088,7 @@ manage(Window w, XWindowAttributes *wa)
     50  		c->isfloating = c->oldstate = trans != None || c->isfixed;
     51  	if (c->isfloating)
     52  		XRaiseWindow(dpy, c->win);
     53 -	attach(c);
     54 +	attachaside(c);
     55  	attachstack(c);
     56  	XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
     57  		(unsigned char *) &(c->win), 1);
     58 @@ -1202,6 +1216,16 @@ movemouse(const Arg *arg)
     59  	}
     60  }
     61  
     62 +Client *
     63 +nexttagged(Client *c) {
     64 +	Client *walked = c->mon->clients;
     65 +	for(;
     66 +		walked && (walked->isfloating || !ISVISIBLEONTAG(walked, c->tags));
     67 +		walked = walked->next
     68 +	);
     69 +	return walked;
     70 +}
     71 +
     72  Client *
     73  nexttiled(Client *c)
     74  {
     75 @@ -1427,7 +1451,7 @@ sendmon(Client *c, Monitor *m)
     76  	detachstack(c);
     77  	c->mon = m;
     78  	c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
     79 -	attach(c);
     80 +	attachaside(c);
     81  	attachstack(c);
     82  	focus(NULL);
     83  	arrange(NULL);
     84 @@ -1915,7 +1939,7 @@ updategeom(void)
     85  				m->clients = c->next;
     86  				detachstack(c);
     87  				c->mon = mons;
     88 -				attach(c);
     89 +				attachaside(c);
     90  				attachstack(c);
     91  			}
     92  			if (m == selmon)