-
Notifications
You must be signed in to change notification settings - Fork 0
/
dwm-attachbelow-toggleable-6.2.diff
199 lines (178 loc) · 5.9 KB
/
dwm-attachbelow-toggleable-6.2.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
From ee036687ed9e1bb973b9e34694a57cf5dd67652d Mon Sep 17 00:00:00 2001
From: Jonathan Hodgson <git@jonathanh.co.uk>
Date: Mon, 6 May 2019 18:34:40 +0100
Subject: [PATCH 1/4] Adds attach below option
---
config.def.h | 1 +
dwm.c | 31 ++++++++++++++++++++++++++++---
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1c0b587..51ad933 100644
--- a/config.def.h
+++ b/config.def.h
@@ -35,6 +35,7 @@ static const Rule rules[] = {
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
+static const int attachbelow = 1; /* 1 means attach at the end */
static const Layout layouts[] = {
/* symbol arrange function */
diff --git a/dwm.c b/dwm.c
index 4465af1..bd715a2 100644
--- a/dwm.c
+++ b/dwm.c
@@ -147,6 +147,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
static void arrange(Monitor *m);
static void arrangemon(Monitor *m);
static void attach(Client *c);
+static void attachBelow(Client *c);
static void attachstack(Client *c);
static void buttonpress(XEvent *e);
static void checkotherwm(void);
@@ -405,6 +406,21 @@ attach(Client *c)
c->next = c->mon->clients;
c->mon->clients = c;
}
+void
+attachBelow(Client *c)
+{
+ //If there is nothing on the monitor or the selected client is floating, attach as normal
+ if(c->mon->sel == NULL || c->mon->sel == c || c->mon->sel->isfloating) {
+ attach(c);
+ return;
+ }
+
+ //Set the new client's next property to the same as the currently selected clients next
+ c->next = c->mon->sel->next;
+ //Set the currently selected clients next property to the new client
+ c->mon->sel->next = c;
+
+}
void
attachstack(Client *c)
@@ -1062,7 +1078,10 @@ manage(Window w, XWindowAttributes *wa)
c->isfloating = c->oldstate = trans != None || c->isfixed;
if (c->isfloating)
XRaiseWindow(dpy, c->win);
- attach(c);
+ if( attachbelow )
+ attachBelow(c);
+ else
+ attach(c);
attachstack(c);
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
(unsigned char *) &(c->win), 1);
@@ -1417,7 +1436,10 @@ sendmon(Client *c, Monitor *m)
detachstack(c);
c->mon = m;
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
- attach(c);
+ if( attachbelow )
+ attachBelow(c);
+ else
+ attach(c);
attachstack(c);
focus(NULL);
arrange(NULL);
@@ -1897,7 +1919,10 @@ updategeom(void)
m->clients = c->next;
detachstack(c);
c->mon = mons;
- attach(c);
+ if( attachbelow )
+ attachBelow(c);
+ else
+ attach(c);
attachstack(c);
}
if (m == selmon)
--
2.21.0
From e212c1d8cbdcc56c33c717131dfa7c1689e27e9f Mon Sep 17 00:00:00 2001
From: Jonathan Hodgson <git@jonathanh.co.uk>
Date: Mon, 6 May 2019 19:27:57 +0100
Subject: [PATCH 2/4] fixes comment
---
config.def.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config.def.h b/config.def.h
index 51ad933..cb8053a 100644
--- a/config.def.h
+++ b/config.def.h
@@ -35,7 +35,7 @@ static const Rule rules[] = {
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
-static const int attachbelow = 1; /* 1 means attach at the end */
+static const int attachbelow = 1; /* 1 means attach after the currently active window */
static const Layout layouts[] = {
/* symbol arrange function */
--
2.21.0
From 7568ea3f8756e7e82b30c4943556ae646a445d1c Mon Sep 17 00:00:00 2001
From: Jonathan Hodgson <git@jonathanh.co.uk>
Date: Mon, 6 May 2019 20:00:30 +0100
Subject: [PATCH 3/4] Makes changes to man page to reflect attach below patch
---
dwm.1 | 3 +++
1 file changed, 3 insertions(+)
diff --git a/dwm.1 b/dwm.1
index 13b3729..fb6e76c 100644
--- a/dwm.1
+++ b/dwm.1
@@ -29,6 +29,9 @@ color. The tags of the focused window are indicated with a filled square in the
top left corner. The tags which are applied to one or more windows are
indicated with an empty square in the top left corner.
.P
+The attach below patch makes newly spawned windows attach after the currently
+selected window
+.P
dwm draws a small border around windows to indicate the focus state.
.SH OPTIONS
.TP
--
2.21.0
From 362b95a5b9f91673f27f3e3343b5738df3c9d6e9 Mon Sep 17 00:00:00 2001
From: Jonathan Hodgson <git@jonathanh.co.uk>
Date: Sun, 2 Jun 2019 15:11:57 +0100
Subject: [PATCH 4/4] Allows attach below to be toggled
---
config.def.h | 2 +-
dwm.c | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/config.def.h b/config.def.h
index cb8053a..b4d35aa 100644
--- a/config.def.h
+++ b/config.def.h
@@ -35,7 +35,7 @@ static const Rule rules[] = {
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
-static const int attachbelow = 1; /* 1 means attach after the currently active window */
+static int attachbelow = 1; /* 1 means attach after the currently active window */
static const Layout layouts[] = {
/* symbol arrange function */
diff --git a/dwm.c b/dwm.c
index bd715a2..5d88653 100644
--- a/dwm.c
+++ b/dwm.c
@@ -148,6 +148,7 @@ static void arrange(Monitor *m);
static void arrangemon(Monitor *m);
static void attach(Client *c);
static void attachBelow(Client *c);
+static void toggleAttachBelow();
static void attachstack(Client *c);
static void buttonpress(XEvent *e);
static void checkotherwm(void);
@@ -422,6 +423,11 @@ attachBelow(Client *c)
}
+void toggleAttachBelow()
+{
+ attachbelow = !attachbelow;
+}
+
void
attachstack(Client *c)
{
--
2.21.0