diff options
| author | 0scar <qgt268@alumni.ku.dk> | 2023-03-12 15:26:36 +0000 |
|---|---|---|
| committer | 0scar <qgt268@alumni.ku.dk> | 2024-10-01 11:57:15 +0000 |
| commit | e67193d9b10627b010cd35790962915c4327d845 (patch) | |
| tree | 7e66f8d5fd6042741c592290d451a371f6ccde6f /dwl.c | |
| parent | fc34479ff679890c518a4c15e89f3894a6aa0a5f (diff) | |
Patch: movestack
Source: https://github.com/djpohly/dwl/wiki/movestack
Author: sam-barr (ss7m)
Patch: extend movestack to move clients to first or last
Diffstat (limited to 'dwl.c')
| -rw-r--r-- | dwl.c | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -3,6 +3,7 @@ */ #include <getopt.h> #include <libinput.h> +#include <limits.h> #include <linux/input-event-codes.h> #include <math.h> #include <signal.h> @@ -317,6 +318,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); @@ -2036,6 +2038,49 @@ monocle(Monitor *m) } void +movestack(const Arg *arg) +{ + Client *c, *sel = focustop(selmon); + + if (wl_list_length(&clients) <= 1) { + return; + } + + if (arg->i == 0) { + /* Put the selected client on top */ + wl_list_remove(&sel->link); + wl_list_insert(&clients, &sel->link); + arrange(selmon); + return; + } else if (arg->i == INT_MAX) { + /* Get the last element */ + wl_list_for_each_reverse(c, &clients, link) { + if (!VISIBLEON(c, selmon) || c->isfloating || c->isfullscreen) + continue; + break; + } + } else if (arg->i > 0) { + wl_list_for_each(c, &sel->link, link) { + if (VISIBLEON(c, selmon) || &c->link == &clients) { + break; /* found it */ + } + } + } else { + wl_list_for_each_reverse(c, &sel->link, link) { + 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_ |
