dwm-attachtop-6.2.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-attachtop-6.2.diff (2868B)
---
1 From 17acbdcb56d0d2f39507a3f67ef329c14a213ef6 Mon Sep 17 00:00:00 2001
2 From: MLquest8 <miskuzius@gmail.com>
3 Date: Thu, 18 Jun 2020 15:34:18 +0400
4 Subject: [PATCH] attachtop. Attaches new client below the last master/on top
5 of the stack. In case of nmaster = 1 behaves like attachaside.
6
7 ---
8 dwm.c | 29 +++++++++++++++++++++++++----
9 1 file changed, 25 insertions(+), 4 deletions(-)
10
11 diff --git a/dwm.c b/dwm.c
12 index 9fd0286..7ced982 100644
13 --- a/dwm.c
14 +++ b/dwm.c
15 @@ -49,7 +49,8 @@
16 #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
17 #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
18 * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
19 -#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
20 +#define ISVISIBLEONTAG(C, T) ((C->tags & T))
21 +#define ISVISIBLE(C) ISVISIBLEONTAG(C, C->mon->tagset[C->mon->seltags])
22 #define LENGTH(X) (sizeof X / sizeof X[0])
23 #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
24 #define WIDTH(X) ((X)->w + 2 * (X)->bw)
25 @@ -147,6 +148,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
26 static void arrange(Monitor *m);
27 static void arrangemon(Monitor *m);
28 static void attach(Client *c);
29 +static void attachtop(Client *c);
30 static void attachstack(Client *c);
31 static void buttonpress(XEvent *e);
32 static void checkotherwm(void);
33 @@ -407,6 +409,25 @@ attach(Client *c)
34 c->mon->clients = c;
35 }
36
37 +void
38 +attachtop(Client *c)
39 +{
40 + int n;
41 + Monitor *m = selmon;
42 + Client *below;
43 +
44 + for (n = 1, below = c->mon->clients;
45 + below && below->next && (below->isfloating || !ISVISIBLEONTAG(below, c->tags) || n != m->nmaster);
46 + n = below->isfloating || !ISVISIBLEONTAG(below, c->tags) ? n + 0 : n + 1, below = below->next);
47 + c->next = NULL;
48 + if (below) {
49 + c->next = below->next;
50 + below->next = c;
51 + }
52 + else
53 + c->mon->clients = c;
54 +}
55 +
56 void
57 attachstack(Client *c)
58 {
59 @@ -1063,7 +1084,7 @@ manage(Window w, XWindowAttributes *wa)
60 c->isfloating = c->oldstate = trans != None || c->isfixed;
61 if (c->isfloating)
62 XRaiseWindow(dpy, c->win);
63 - attach(c);
64 + attachtop(c);
65 attachstack(c);
66 XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
67 (unsigned char *) &(c->win), 1);
68 @@ -1418,7 +1439,7 @@ sendmon(Client *c, Monitor *m)
69 detachstack(c);
70 c->mon = m;
71 c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
72 - attach(c);
73 + attachtop(c);
74 attachstack(c);
75 focus(NULL);
76 arrange(NULL);
77 @@ -1900,7 +1921,7 @@ updategeom(void)
78 m->clients = c->next;
79 detachstack(c);
80 c->mon = mons;
81 - attach(c);
82 + attachtop(c);
83 attachstack(c);
84 }
85 if (m == selmon)
86 --
87 2.26.2
88