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