aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Leonhardt <equinox.salexander@gmail.com>
2026-09-13 20:04:02 +0200
committerAlexander Leonhardt <equinox.salexander@gmail.com>
2026-09-13 20:04:02 +0200
commitb9362d380e6c8d031e1c099349e5210ec1f83b16 (patch)
treefe64b42af903f68840b3cb3e223db3f12bb3b5cd
parent8274317473737359070d0873aad4e3415a39ebd5 (diff)
parentd9b114c4c715ff35d5d6bf2ec11cac27f5ce1b78 (diff)
downloaddwl-b9362d380e6c8d031e1c099349e5210ec1f83b16.tar.gz
dwl-b9362d380e6c8d031e1c099349e5210ec1f83b16.tar.bz2
dwl-b9362d380e6c8d031e1c099349e5210ec1f83b16.zip
Removed unused functions and added movestack
-rw-r--r--config.def.h2
-rw-r--r--dwl.c71
2 files changed, 46 insertions, 27 deletions
diff --git a/config.def.h b/config.def.h
index f005aac..8ceb071 100644
--- a/config.def.h
+++ b/config.def.h
@@ -147,6 +147,8 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
{ MODKEY, XKB_KEY_b, togglebar, {0} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_j, movestack, {.i = +1} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_k, movestack, {.i = -1} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_d, setmfact, {.f = -0.05f} },
diff --git a/dwl.c b/dwl.c
index f87b05a..364171b 100644
--- a/dwl.c
+++ b/dwl.c
@@ -333,7 +333,6 @@ static void drawbar(Monitor *m);
static void drawbars(void);
static void focusclient(Client *c, int lift);
static void focusmon(const Arg *arg);
-static void focusstack(const Arg *arg);
static void focusdir(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
@@ -354,6 +353,7 @@ static int menuread(int fd, uint32_t mask, void *data);
static void menuwinfeed(FILE *f);
static void menuwinaction(char *line);
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);
@@ -1885,31 +1885,6 @@ focusmon(const Arg *arg)
focusclient(focustop(selmon), 1);
}
-void
-focusstack(const Arg *arg)
-{
- /* Focus the next or previous client (in tiling order) on selmon */
- Client *c, *sel = focustop(selmon);
- if (!sel || (sel->isfullscreen && !client_has_children(sel)))
- return;
- if (arg->i > 0) {
- wl_list_for_each(c, &sel->link, link) {
- if (&c->link == &clients)
- continue; /* wrap past the sentinel node */
- if (VISIBLEON(c, selmon))
- break; /* found it */
- }
- } else {
- wl_list_for_each_reverse(c, &sel->link, link) {
- if (&c->link == &clients)
- continue; /* wrap past the sentinel node */
- if (VISIBLEON(c, selmon))
- break; /* found it */
- }
- }
- /* If only one client is visible on selmon, then c == sel */
- focusclient(c, 1);
-}
void focusdir(const Arg *arg)
{
@@ -2412,6 +2387,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_
@@ -3597,9 +3614,9 @@ void
updatetitle(struct wl_listener *listener, void *data)
{
Client *c = wl_container_of(listener, c, set_title);
+ const char *title = client_get_title(c);
if (c == focustop(c->mon)) {
drawbars();
- const char *title = client_get_title(c);
if (title && strstr(title,"[tmux]")) {
client_set_border_color(c, tmux_color);
}