dwm-stacker-6.6.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-stacker-6.6.diff (6616B)
---
1 From 4136d94fe37800370470f42bfb684523e2ccc28c Mon Sep 17 00:00:00 2001
2 From: thjbbvlt <thibault2@ik.me>
3 Date: Mon, 3 Nov 2025 11:33:05 +0100
4 Subject: [PATCH] stacker updated for version 6.6
5
6 ---
7 config.def.h | 14 +++++++--
8 dwm.c | 88 ++++++++++++++++++++++++++++++++++++++++------------
9 2 files changed, 80 insertions(+), 22 deletions(-)
10
11 diff --git a/config.def.h b/config.def.h
12 index 81c3fc0..4583f94 100644
13 --- a/config.def.h
14 +++ b/config.def.h
15 @@ -52,6 +52,14 @@ static const Layout layouts[] = {
16 { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
17 { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
18 { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
19 +#define STACKKEYS(MOD,ACTION) \
20 + { MOD, XK_j, ACTION##stack, {.i = INC(+1) } }, \
21 + { MOD, XK_k, ACTION##stack, {.i = INC(-1) } }, \
22 + { MOD, XK_grave, ACTION##stack, {.i = PREVSEL } }, \
23 + { MOD, XK_q, ACTION##stack, {.i = 0 } }, \
24 + { MOD, XK_a, ACTION##stack, {.i = 1 } }, \
25 + { MOD, XK_z, ACTION##stack, {.i = 2 } }, \
26 + { MOD, XK_x, ACTION##stack, {.i = -1 } },
27
28 /* helper for spawning shell commands in the pre dwm-5.0 fashion */
29 #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
30 @@ -66,8 +74,8 @@ static const Key keys[] = {
31 { MODKEY, XK_p, spawn, {.v = dmenucmd } },
32 { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
33 { MODKEY, XK_b, togglebar, {0} },
34 - { MODKEY, XK_j, focusstack, {.i = +1 } },
35 - { MODKEY, XK_k, focusstack, {.i = -1 } },
36 + STACKKEYS(MODKEY, focus)
37 + STACKKEYS(MODKEY|ShiftMask, push)
38 { MODKEY, XK_i, incnmaster, {.i = +1 } },
39 { MODKEY, XK_d, incnmaster, {.i = -1 } },
40 { MODKEY, XK_h, setmfact, {.f = -0.05} },
41 @@ -95,7 +103,7 @@ static const Key keys[] = {
42 TAGKEYS( XK_7, 6)
43 TAGKEYS( XK_8, 7)
44 TAGKEYS( XK_9, 8)
45 - { MODKEY|ShiftMask, XK_q, quit, {0} },
46 + { MODKEY|ShiftMask, XK_BackSpace, quit, {0} },
47 };
48
49 /* button definitions */
50 diff --git a/dwm.c b/dwm.c
51 index 4f345ee..3fdf66e 100644
52 --- a/dwm.c
53 +++ b/dwm.c
54 @@ -47,14 +47,20 @@
55 /* macros */
56 #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
57 #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
58 +#define GETINC(X) ((X) - 2000)
59 +#define INC(X) ((X) + 2000)
60 #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
61 * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
62 +#define ISINC(X) ((X) > 1000 && (X) < 3000)
63 #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
64 +#define MOD(N,M) ((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M))
65 #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
66 #define WIDTH(X) ((X)->w + 2 * (X)->bw)
67 #define HEIGHT(X) ((X)->h + 2 * (X)->bw)
68 +#define PREVSEL 3000
69 #define TAGMASK ((1 << LENGTH(tags)) - 1)
70 #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
71 +#define TRUNC(X,A,B) (MAX((A), MIN((X), (B))))
72
73 /* enums */
74 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
75 @@ -186,6 +192,7 @@ static void movemouse(const Arg *arg);
76 static Client *nexttiled(Client *c);
77 static void pop(Client *c);
78 static void propertynotify(XEvent *e);
79 +static void pushstack(const Arg *arg); /* patch stacker */
80 static void quit(const Arg *arg);
81 static Monitor *recttomon(int x, int y, int w, int h);
82 static void resize(Client *c, int x, int y, int w, int h, int interact);
83 @@ -205,6 +212,7 @@ static void setup(void);
84 static void seturgent(Client *c, int urg);
85 static void showhide(Client *c);
86 static void spawn(const Arg *arg);
87 +static int stackpos(const Arg *arg); /* patch stacker */
88 static void tag(const Arg *arg);
89 static void tagmon(const Arg *arg);
90 static void tile(Monitor *m);
91 @@ -837,27 +845,16 @@ focusmon(const Arg *arg)
92 void
93 focusstack(const Arg *arg)
94 {
95 - Client *c = NULL, *i;
96 + int i = stackpos(arg);
97 + Client *c, *p;
98
99 - if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
100 + if(i < 0)
101 return;
102 - if (arg->i > 0) {
103 - for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
104 - if (!c)
105 - for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
106 - } else {
107 - for (i = selmon->clients; i != selmon->sel; i = i->next)
108 - if (ISVISIBLE(i))
109 - c = i;
110 - if (!c)
111 - for (; i; i = i->next)
112 - if (ISVISIBLE(i))
113 - c = i;
114 - }
115 - if (c) {
116 - focus(c);
117 - restack(selmon);
118 - }
119 +
120 + for(p = NULL, c = selmon->clients; c && (i || !ISVISIBLE(c));
121 + i -= ISVISIBLE(c) ? 1 : 0, p = c, c = c->next);
122 + focus(c ? c : p);
123 + restack(selmon);
124 }
125
126 Atom
127 @@ -1254,6 +1251,29 @@ propertynotify(XEvent *e)
128 }
129 }
130
131 +void
132 +pushstack(const Arg *arg) {
133 + int i = stackpos(arg);
134 + Client *sel = selmon->sel, *c, *p;
135 +
136 + if(i < 0)
137 + return;
138 + else if(i == 0) {
139 + detach(sel);
140 + attach(sel);
141 + }
142 + else {
143 + for(p = NULL, c = selmon->clients; c; p = c, c = c->next)
144 + if(!(i -= (ISVISIBLE(c) && c != sel)))
145 + break;
146 + c = c ? c : p;
147 + detach(sel);
148 + sel->next = c->next;
149 + c->next = sel;
150 + }
151 + arrange(selmon);
152 +}
153 +
154 void
155 quit(const Arg *arg)
156 {
157 @@ -1665,6 +1685,36 @@ spawn(const Arg *arg)
158 }
159 }
160
161 +int
162 +stackpos(const Arg *arg) {
163 + int n, i;
164 + Client *c, *l;
165 +
166 + if(!selmon->clients)
167 + return -1;
168 +
169 + if(arg->i == PREVSEL) {
170 + for(l = selmon->stack; l && (!ISVISIBLE(l) || l == selmon->sel); l = l->snext);
171 + if(!l)
172 + return -1;
173 + for(i = 0, c = selmon->clients; c != l; i += ISVISIBLE(c) ? 1 : 0, c = c->next);
174 + return i;
175 + }
176 + else if(ISINC(arg->i)) {
177 + if(!selmon->sel)
178 + return -1;
179 + for(i = 0, c = selmon->clients; c != selmon->sel; i += ISVISIBLE(c) ? 1 : 0, c = c->next);
180 + for(n = i; c; n += ISVISIBLE(c) ? 1 : 0, c = c->next);
181 + return MOD(i + GETINC(arg->i), n);
182 + }
183 + else if(arg->i < 0) {
184 + for(i = 0, c = selmon->clients; c; i += ISVISIBLE(c) ? 1 : 0, c = c->next);
185 + return MAX(i + arg->i, 0);
186 + }
187 + else
188 + return arg->i;
189 +}
190 +
191 void
192 tag(const Arg *arg)
193 {
194 --
195 2.47.3
196