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
|
From dcb7a4d91075a9d918d082eb948c61d26eb0bc02 Mon Sep 17 00:00:00 2001
From: "Devin J. Pohly" <djpohly@gmail.com>
Date: Thu, 4 Mar 2021 00:45:50 -0600
Subject: [PATCH 1/2] port dwm "push" patch to dwl
---
Makefile | 2 ++
dwl.c | 2 ++
push.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 67 insertions(+)
create mode 100644 push.c
diff --git a/Makefile b/Makefile
index a0d1cc37..1701b63e 100644
--- a/Makefile
+++ b/Makefile
@@ -49,6 +49,8 @@ config.h: | config.def.h
dwl.o: config.h client.h xdg-shell-protocol.h wlr-layer-shell-unstable-v1-protocol.h idle-protocol.h
+dwl.o: push.c
+
dwl: xdg-shell-protocol.o wlr-layer-shell-unstable-v1-protocol.o idle-protocol.o
clean:
diff --git a/dwl.c b/dwl.c
index 72f1046b..4cfd7d07 100644
--- a/dwl.c
+++ b/dwl.c
@@ -369,7 +369,9 @@ static Atom netatom[NetLast];
#endif
/* configuration, allows nested code to access above variables */
+#include "push.h"
#include "config.h"
+#include "push.c"
/* attempt to encapsulate suck into one file */
#include "client.h"
diff --git a/push.c b/push.c
new file mode 100644
index 00000000..26ed462f
--- /dev/null
+++ b/push.c
@@ -0,0 +1,63 @@
+static Client *
+nexttiled(Client *sel) {
+ Client *c;
+ wl_list_for_each(c, &sel->link, link) {
+ if (&c->link == &clients)
+ break; /* don't wrap */
+ if (!c->isfloating && VISIBLEON(c, selmon))
+ return c;
+ }
+ return NULL;
+}
+
+static Client *
+prevtiled(Client *sel) {
+ Client *c;
+ wl_list_for_each_reverse(c, &sel->link, link) {
+ if (&c->link == &clients)
+ break; /* don't wrap */
+ if (!c->isfloating && VISIBLEON(c, selmon))
+ return c;
+ }
+ return NULL;
+}
+
+static void
+pushup(const Arg *arg) {
+ Client *sel = selclient();
+ Client *c;
+
+ if(!sel || sel->isfloating)
+ return;
+ if((c = prevtiled(sel))) {
+ /* attach before c */
+ wl_list_remove(&sel->link);
+ wl_list_insert(c->link.prev, &sel->link);
+ } else {
+ /* move to the end */
+ wl_list_remove(&sel->link);
+ wl_list_insert(clients.prev, &sel->link);
+ }
+ focusclient(sel, 1);
+ arrange(selmon);
+}
+
+static void
+pushdown(const Arg *arg) {
+ Client *sel = selclient();
+ Client *c;
+
+ if(!sel || sel->isfloating)
+ return;
+ if((c = nexttiled(sel))) {
+ /* attach after c */
+ wl_list_remove(&sel->link);
+ wl_list_insert(&c->link, &sel->link);
+ } else {
+ /* move to the front */
+ wl_list_remove(&sel->link);
+ wl_list_insert(&clients, &sel->link);
+ }
+ focusclient(sel, 1);
+ arrange(selmon);
+}
From 156a13d9f9f9d8df16b184f5ec0c84e6e5b94df6 Mon Sep 17 00:00:00 2001
From: "Devin J. Pohly" <djpohly@gmail.com>
Date: Thu, 4 Mar 2021 13:52:58 -0600
Subject: [PATCH 2/2] add missing header
---
push.h | 4 ++++
1 file changed, 4 insertions(+)
create mode 100644 push.h
diff --git a/push.h b/push.h
new file mode 100644
index 00000000..59c0f80e
--- /dev/null
+++ b/push.h
@@ -0,0 +1,4 @@
+static Client *nexttiled(Client *sel);
+static Client *prevtiled(Client *sel);
+static void pushdown(const Arg *arg);
+static void pushup(const Arg *arg);
|