Introduction
Introduction Statistics Contact Development Disclaimer Help
dwm-attachdirection-6.2.diff - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
dwm-attachdirection-6.2.diff (5911B)
---
1 From faa0d3a06229906b8cd30cdeb4360ee9608f74bd Mon Sep 17 00:00:00 2001
2 From: MLquest8 <[email protected]>
3 Date: Thu, 18 Jun 2020 15:14:56 +0400
4 Subject: [PATCH] attachdirection updated. Added attachtop option(5) that
5 attaches the newest client below the last master/on top of the stack.
6
7 ---
8 config.def.h | 1 +
9 dwm.c | 146 +++++++++++++++++++++++++++++++++++++++++++++++++--
10 2 files changed, 143 insertions(+), 4 deletions(-)
11
12 diff --git a/config.def.h b/config.def.h
13 index 1c0b587..d7c089b 100644
14 --- a/config.def.h
15 +++ b/config.def.h
16 @@ -35,6 +35,7 @@ static const Rule rules[] = {
17 static const float mfact = 0.55; /* factor of master area size [0.0…
18 static const int nmaster = 1; /* number of clients in master are…
19 static const int resizehints = 1; /* 1 means respect size hints in t…
20 +static const int attachdirection = 0; /* 0 default, 1 above, 2 aside…
21
22 static const Layout layouts[] = {
23 /* symbol arrange function */
24 diff --git a/dwm.c b/dwm.c
25 index 9fd0286..2c1b143 100644
26 --- a/dwm.c
27 +++ b/dwm.c
28 @@ -49,7 +49,8 @@
29 #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (Shif…
30 #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - …
31 * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - …
32 -#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->selt…
33 +#define ISVISIBLEONTAG(C, T) ((C->tags & T))
34 +#define ISVISIBLE(C) ISVISIBLEONTAG(C, C->mon->tagset[C->mon…
35 #define LENGTH(X) (sizeof X / sizeof X[0])
36 #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
37 #define WIDTH(X) ((X)->w + 2 * (X)->bw)
38 @@ -147,6 +148,11 @@ static int applysizehints(Client *c, int *x, int *y…
39 static void arrange(Monitor *m);
40 static void arrangemon(Monitor *m);
41 static void attach(Client *c);
42 +static void attachabove(Client *c);
43 +static void attachaside(Client *c);
44 +static void attachbelow(Client *c);
45 +static void attachbottom(Client *c);
46 +static void attachtop(Client *c);
47 static void attachstack(Client *c);
48 static void buttonpress(XEvent *e);
49 static void checkotherwm(void);
50 @@ -184,6 +190,7 @@ static void maprequest(XEvent *e);
51 static void monocle(Monitor *m);
52 static void motionnotify(XEvent *e);
53 static void movemouse(const Arg *arg);
54 +static Client *nexttagged(Client *c);
55 static Client *nexttiled(Client *c);
56 static void pop(Client *);
57 static void propertynotify(XEvent *e);
58 @@ -407,6 +414,73 @@ attach(Client *c)
59 c->mon->clients = c;
60 }
61
62 +void
63 +attachabove(Client *c)
64 +{
65 + if (c->mon->sel == NULL || c->mon->sel == c->mon->clients || c-…
66 + attach(c);
67 + return;
68 + }
69 +
70 + Client *at;
71 + for (at = c->mon->clients; at->next != c->mon->sel; at = at->ne…
72 + c->next = at->next;
73 + at->next = c;
74 +}
75 +
76 +void
77 +attachaside(Client *c) {
78 + Client *at = nexttagged(c);
79 + if(!at) {
80 + attach(c);
81 + return;
82 + }
83 + c->next = at->next;
84 + at->next = c;
85 +}
86 +
87 +void
88 +attachbelow(Client *c)
89 +{
90 + if(c->mon->sel == NULL || c->mon->sel == c || c->mon->sel->isfl…
91 + attach(c);
92 + return;
93 + }
94 + c->next = c->mon->sel->next;
95 + c->mon->sel->next = c;
96 +}
97 +
98 +void
99 +attachbottom(Client *c)
100 +{
101 + Client *below = c->mon->clients;
102 + for (; below && below->next; below = below->next);
103 + c->next = NULL;
104 + if (below)
105 + below->next = c;
106 + else
107 + c->mon->clients = c;
108 +}
109 +
110 +void
111 +attachtop(Client *c)
112 +{
113 + int n;
114 + Monitor *m = selmon;
115 + Client *below;
116 +
117 + for (n = 1, below = c->mon->clients;
118 + below && below->next && (below->isfloating || !ISVISIBL…
119 + n = below->isfloating || !ISVISIBLEONTAG(below, c->tags…
120 + c->next = NULL;
121 + if (below) {
122 + c->next = below->next;
123 + below->next = c;
124 + }
125 + else
126 + c->mon->clients = c;
127 +}
128 +
129 void
130 attachstack(Client *c)
131 {
132 @@ -1063,7 +1137,25 @@ manage(Window w, XWindowAttributes *wa)
133 c->isfloating = c->oldstate = trans != None || c->isfix…
134 if (c->isfloating)
135 XRaiseWindow(dpy, c->win);
136 - attach(c);
137 + switch(attachdirection){
138 + case 1:
139 + attachabove(c);
140 + break;
141 + case 2:
142 + attachaside(c);
143 + break;
144 + case 3:
145 + attachbelow(c);
146 + break;
147 + case 4:
148 + attachbottom(c);
149 + break;
150 + case 5:
151 + attachtop(c);
152 + break;
153 + default:
154 + attach(c);
155 + }
156 attachstack(c);
157 XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 3…
158 (unsigned char *) &(c->win), 1);
159 @@ -1193,6 +1285,16 @@ movemouse(const Arg *arg)
160 }
161 }
162
163 +Client *
164 +nexttagged(Client *c) {
165 + Client *walked = c->mon->clients;
166 + for(;
167 + walked && (walked->isfloating || !ISVISIBLEONTAG(walked…
168 + walked = walked->next
169 + );
170 + return walked;
171 +}
172 +
173 Client *
174 nexttiled(Client *c)
175 {
176 @@ -1418,7 +1520,25 @@ sendmon(Client *c, Monitor *m)
177 detachstack(c);
178 c->mon = m;
179 c->tags = m->tagset[m->seltags]; /* assign tags of target monit…
180 - attach(c);
181 + switch(attachdirection){
182 + case 1:
183 + attachabove(c);
184 + break;
185 + case 2:
186 + attachaside(c);
187 + break;
188 + case 3:
189 + attachbelow(c);
190 + break;
191 + case 4:
192 + attachbottom(c);
193 + break;
194 + case 5:
195 + attachtop(c);
196 + break;
197 + default:
198 + attach(c);
199 + }
200 attachstack(c);
201 focus(NULL);
202 arrange(NULL);
203 @@ -1900,7 +2020,25 @@ updategeom(void)
204 m->clients = c->next;
205 detachstack(c);
206 c->mon = mons;
207 - attach(c);
208 + switch(attachdirection){
209 + case 1:
210 + attachabove(c);
211 + break;
212 + case 2:
213 + attachaside(c);
214 + break;
215 + case 3:
216 + attachbelow(c);
217 + break;
218 + case 4:
219 + attachbottom(c);
220 + break;
221 + case 5:
222 + attachtop(c);
223 + break;
224 + default:
225 + attach(c);
226 + }
227 attachstack(c);
228 }
229 if (m == selmon)
230 --
231 2.26.2
232
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.