mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2025-10-26 17:54:17 +00:00
Fix crash when moving beyond first/last clients
This commit is contained in:
parent
be20c2de0e
commit
f24e98a304
@ -2,8 +2,8 @@
|
|||||||
Allows you to move a window up and down the stack.
|
Allows you to move a window up and down the stack.
|
||||||
|
|
||||||
### Download
|
### Download
|
||||||
- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.5/movestack)
|
- [git branch](https://codeberg.org/nikitaivanov/dwl/src/branch/movestack)
|
||||||
- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/movestack/movestack.patch)
|
- [v0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/movestack/movestack.patch)
|
||||||
|
|
||||||
### Authors
|
### Authors
|
||||||
- [wochap](https://codeberg.org/wochap)
|
- [wochap](https://codeberg.org/wochap)
|
||||||
|
|||||||
@ -1,19 +1,18 @@
|
|||||||
From b051f50233033b399db324b29ab24227257ac141 Mon Sep 17 00:00:00 2001
|
From 08230817bd3926e29d9897657eb1852cb27d461f Mon Sep 17 00:00:00 2001
|
||||||
From: wochap <gean.marroquin@gmail.com>
|
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
|
||||||
Date: Tue, 5 Mar 2024 23:31:51 -0500
|
Date: Tue, 4 Feb 2025 23:21:19 +0100
|
||||||
Subject: [PATCH] apply NikitaIvanovV movestack patch
|
Subject: [PATCH] Allows you to move a window up and down the stack
|
||||||
|
|
||||||
source: https://github.com/djpohly/dwl/wiki/movestack
|
|
||||||
---
|
---
|
||||||
config.def.h | 2 ++
|
config.def.h | 2 ++
|
||||||
dwl.c | 35 +++++++++++++++++++++++++++++++++++
|
dwl.c | 43 +++++++++++++++++++++++++++++++++++++++++++
|
||||||
2 files changed, 37 insertions(+)
|
2 files changed, 45 insertions(+)
|
||||||
|
|
||||||
diff --git a/config.def.h b/config.def.h
|
diff --git a/config.def.h b/config.def.h
|
||||||
index db0babc..778a0dc 100644
|
index 22d2171..2c129f2 100644
|
||||||
--- a/config.def.h
|
--- a/config.def.h
|
||||||
+++ b/config.def.h
|
+++ b/config.def.h
|
||||||
@@ -122,6 +122,8 @@ static const Key keys[] = {
|
@@ -129,6 +129,8 @@ static const Key keys[] = {
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||||
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
||||||
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||||
@ -21,59 +20,68 @@ index db0babc..778a0dc 100644
|
|||||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_K, movestack, {.i = -1} },
|
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_K, movestack, {.i = -1} },
|
||||||
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||||
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
|
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
|
||||||
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05} },
|
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
|
||||||
diff --git a/dwl.c b/dwl.c
|
diff --git a/dwl.c b/dwl.c
|
||||||
index ef27a1d..69b9756 100644
|
index def2562..045d6fa 100644
|
||||||
--- a/dwl.c
|
--- a/dwl.c
|
||||||
+++ b/dwl.c
|
+++ b/dwl.c
|
||||||
@@ -279,6 +279,7 @@ static void maplayersurfacenotify(struct wl_listener *listener, void *data);
|
@@ -303,6 +303,7 @@ static void locksession(struct wl_listener *listener, void *data);
|
||||||
static void mapnotify(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 maximizenotify(struct wl_listener *listener, void *data);
|
||||||
static void monocle(Monitor *m);
|
static void monocle(Monitor *m);
|
||||||
+static void movestack(const Arg *arg);
|
+static void movestack(const Arg *arg);
|
||||||
static void motionabsolute(struct wl_listener *listener, void *data);
|
static void motionabsolute(struct wl_listener *listener, void *data);
|
||||||
static void motionnotify(uint32_t time);
|
static void motionnotify(uint32_t time, struct wlr_input_device *device, double sx,
|
||||||
static void motionrelative(struct wl_listener *listener, void *data);
|
double sy, double sx_unaccel, double sy_unaccel);
|
||||||
@@ -1603,6 +1604,40 @@ monocle(Monitor *m)
|
@@ -1786,6 +1787,48 @@ monocle(Monitor *m)
|
||||||
wlr_scene_node_raise_to_top(&c->scene->node);
|
wlr_scene_node_raise_to_top(&c->scene->node);
|
||||||
}
|
}
|
||||||
|
|
||||||
+void
|
+void
|
||||||
+movestack(const Arg *arg)
|
+movestack(const Arg *arg)
|
||||||
+{
|
+{
|
||||||
+ Client *c, *sel = focustop(selmon);
|
+ Client *c, *sel = focustop(selmon);
|
||||||
+
|
+
|
||||||
+ if (!sel) {
|
+ if (!sel) {
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if (wl_list_length(&clients) <= 1) {
|
+ if (wl_list_length(&clients) <= 1) {
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if (arg->i > 0) {
|
+ if (arg->i > 0) {
|
||||||
+ wl_list_for_each(c, &sel->link, link) {
|
+ wl_list_for_each(c, &sel->link, link) {
|
||||||
+ if (VISIBLEON(c, selmon) || &c->link == &clients) {
|
+ if (&c->link == &clients) {
|
||||||
+ break; /* found it */
|
+ c = wl_container_of(&clients, c, link);
|
||||||
+ }
|
+ break; /* wrap past the sentinel node */
|
||||||
+ }
|
+ }
|
||||||
+ } else {
|
+ if (VISIBLEON(c, selmon) || &c->link == &clients) {
|
||||||
+ wl_list_for_each_reverse(c, &sel->link, link) {
|
+ break; /* found it */
|
||||||
+ if (VISIBLEON(c, selmon) || &c->link == &clients) {
|
+ }
|
||||||
+ break; /* found it */
|
+ }
|
||||||
+ }
|
+ } else {
|
||||||
+ }
|
+ wl_list_for_each_reverse(c, &sel->link, link) {
|
||||||
+ /* backup one client */
|
+ if (&c->link == &clients) {
|
||||||
+ c = wl_container_of(c->link.prev, c, link);
|
+ 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_remove(&sel->link);
|
||||||
+ wl_list_insert(&c->link, &sel->link);
|
+ wl_list_insert(&c->link, &sel->link);
|
||||||
+ arrange(selmon);
|
+ arrange(selmon);
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
void
|
void
|
||||||
motionabsolute(struct wl_listener *listener, void *data)
|
motionabsolute(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
--
|
--
|
||||||
2.42.0
|
2.48.1
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user