summaryrefslogtreecommitdiffstats
path: root/dwl.c
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2025-02-27 21:56:54 +0100
committerJoe <rbo@gmx.us>2025-02-27 21:56:54 +0100
commit48e0e4b3599f6770c00a667814c71c8a1ec84185 (patch)
tree4686f74d950f3d13952b07d3366425e48d205986 /dwl.c
parentup (diff)
downloaddwl-48e0e4b3599f6770c00a667814c71c8a1ec84185.tar.gz
dwl-48e0e4b3599f6770c00a667814c71c8a1ec84185.tar.bz2
dwl-48e0e4b3599f6770c00a667814c71c8a1ec84185.tar.xz
dwl-48e0e4b3599f6770c00a667814c71c8a1ec84185.tar.zst
dwl-48e0e4b3599f6770c00a667814c71c8a1ec84185.zip
movestacked
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/dwl.c b/dwl.c
index ff5ae97..a8021f8 100644
--- a/dwl.c
+++ b/dwl.c
@@ -340,6 +340,7 @@ static void locksession(struct wl_listener *listener, void *data);
static void mapnotify(struct wl_listener *listener, void *data);
static void maximizenotify(struct wl_listener *listener, void *data);
static void monocle(Monitor *m);
+static void movestack(const Arg *arg);
static void motionabsolute(struct wl_listener *listener, void *data);
static void motionnotify(uint32_t time, struct wlr_input_device *device, double sx,
double sy, double sx_unaccel, double sy_unaccel);
@@ -2057,6 +2058,48 @@ monocle(Monitor *m)
}
void
+movestack(const Arg *arg)
+{
+ Client *c, *sel = focustop(selmon);
+
+ if (!sel) {
+ return;
+ }
+
+ if (wl_list_length(&clients) <= 1) {
+ return;
+ }
+
+ if (arg->i > 0) {
+ wl_list_for_each(c, &sel->link, link) {
+ if (&c->link == &clients) {
+ c = wl_container_of(&clients, c, link);
+ break; /* wrap past the sentinel node */
+ }
+ if (VISIBLEON(c, selmon) || &c->link == &clients) {
+ break; /* found it */
+ }
+ }
+ } else {
+ wl_list_for_each_reverse(c, &sel->link, link) {
+ if (&c->link == &clients) {
+ c = wl_container_of(&clients, c, link);
+ break; /* wrap past the sentinel node */
+ }
+ if (VISIBLEON(c, selmon) || &c->link == &clients) {
+ break; /* found it */
+ }
+ }
+ /* backup one client */
+ c = wl_container_of(c->link.prev, c, link);
+ }
+
+ wl_list_remove(&sel->link);
+ wl_list_insert(&c->link, &sel->link);
+ arrange(selmon);
+}
+
+void
motionabsolute(struct wl_listener *listener, void *data)
{
/* This event is forwarded by the cursor when a pointer emits an _absolute_