dwm-attachaside-20180126-db22360.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-attachaside-20180126-db22360.diff (2767B)
---
1 diff --git a/dwm.c b/dwm.c
2 index ec6a27c..7b6ce67 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 @@ -148,6 +149,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 @@ -407,6 +410,18 @@ 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 +
47 void
48 attachstack(Client *c)
49 {
50 @@ -1063,7 +1078,7 @@ manage(Window w, XWindowAttributes *wa)
51 c->isfloating = c->oldstate = trans != None || c->isfixed;
52 if (c->isfloating)
53 XRaiseWindow(dpy, c->win);
54 - attach(c);
55 + attachaside(c);
56 attachstack(c);
57 XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
58 (unsigned char *) &(c->win), 1);
59 @@ -1193,6 +1208,16 @@ movemouse(const Arg *arg)
60 }
61 }
62
63 + Client *
64 +nexttagged(Client *c) {
65 + Client *walked = c->mon->clients;
66 + for(;
67 + walked && (walked->isfloating || !ISVISIBLEONTAG(walked, c->tags));
68 + walked = walked->next
69 + );
70 + return walked;
71 +}
72 +
73 Client *
74 nexttiled(Client *c)
75 {
76 @@ -1418,7 +1443,7 @@ sendmon(Client *c, Monitor *m)
77 detachstack(c);
78 c->mon = m;
79 c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
80 - attach(c);
81 + attachaside(c);
82 attachstack(c);
83 focus(NULL);
84 arrange(NULL);
85 @@ -1899,6 +1924,7 @@ updategeom(void)
86 detachstack(c);
87 c->mon = mons;
88 attach(c);
89 + attachaside(c);
90 attachstack(c);
91 }
92 if (m == selmon)