sites

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

dwm-attachaside-6.1.diff (2870B)


      1 diff --git a/dwm.c b/dwm.c
      2 index 0362114..be7e7a6 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 *);
     30  static void propertynotify(XEvent *e);
     31 @@ -406,6 +409,17 @@ attach(Client *c)
     32  }
     33  
     34  void
     35 +attachaside(Client *c) {
     36 +	Client *at = nexttagged(c);
     37 +	if(!at) {
     38 +		attach(c);
     39 +		return;
     40 + 	}
     41 +	c->next = at->next;
     42 +	at->next = c;
     43 +}
     44 +
     45 +void
     46  attachstack(Client *c)
     47  {
     48  	c->snext = c->mon->stack;
     49 @@ -1076,7 +1090,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 @@ -1210,6 +1224,16 @@ movemouse(const Arg *arg)
     59  }
     60  
     61  Client *
     62 +nexttagged(Client *c) {
     63 +	Client *walked = c->mon->clients;
     64 +	for(;
     65 +		walked && (walked->isfloating || !ISVISIBLEONTAG(walked, c->tags));
     66 +		walked = walked->next
     67 +	);
     68 +	return walked;
     69 +}
     70 +
     71 +Client *
     72  nexttiled(Client *c)
     73  {
     74  	for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
     75 @@ -1434,7 +1458,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 @@ -1891,7 +1915,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)