summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZachIR <zachir@librem.one>2022-08-31 17:50:45 -0500
committerZachIR <zachir@librem.one>2022-08-31 17:50:45 -0500
commit55ee442c3cf8833f93626ab1a9a59c9e3f758778 (patch)
treeb051e6b6307b8df513c67ab1e782dc3782a0cb79
parent7e96775d12cd982725cec146529b212f8fe94bad (diff)
add push files
-rw-r--r--Makefile1
-rw-r--r--push.c63
-rw-r--r--push.h4
3 files changed, 68 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 1bdc7d6..8fa5630 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,7 @@ all: dwl
dwl: dwl.o util.o
$(CC) dwl.o util.o $(LDLIBS) $(LDFLAGS) $(DWLCFLAGS) -o $@
dwl.o: dwl.c config.mk config.h client.h xdg-shell-protocol.h wlr-layer-shell-unstable-v1-protocol.h idle-protocol.h
+dwl.o: push.c
util.o: util.c util.h
# wayland scanner rules to generate .h / .c files
diff --git a/push.c b/push.c
new file mode 100644
index 0000000..26ed462
--- /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);
+}
diff --git a/push.h b/push.h
new file mode 100644
index 0000000..59c0f80
--- /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);