Add movestack patch

This commit is contained in:
Sravan Balaji
2024-10-06 08:33:01 -04:00
parent 339440ac43
commit 3d182ed166
6 changed files with 141 additions and 0 deletions

View File

@@ -14,6 +14,7 @@
- [[#foreign-toplevel-management][Foreign Toplevel Management]]
- [[#gapless-grid][Gapless Grid]]
- [[#ipc][IPC]]
- [[#move-stack][Move Stack]]
- [[#natural-scroll-trackpad][Natural Scroll Trackpad]]
- [[#numlock-capslock][Numlock Capslock]]
- [[#per-tag][Per Tag]]
@@ -152,6 +153,14 @@ Note to [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/pertag][p
#define IPC_PATCH 1
#+END_SRC
*** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/movestack][Move Stack]]
Allows you to move a window up and down the stack.
#+BEGIN_SRC c :tangle patches.def.h
#define MOVESTACK_PATCH 1
#+END_SRC
*** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/naturalscrolltrackpad][Natural Scroll Trackpad]]
Set natural scrolling only for trackpads.
@@ -439,6 +448,10 @@ static const Key keys[] = {
#endif // IPC_PATCH
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
#if MOVESTACK_PATCH
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_J, movestack, {.i = +1} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_K, movestack, {.i = -1} },
#endif // MOVESTACK_PATCH
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },

View File

@@ -172,6 +172,10 @@ static const Key keys[] = {
#endif // IPC_PATCH
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
#if MOVESTACK_PATCH
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_J, movestack, {.i = +1} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_K, movestack, {.i = -1} },
#endif // MOVESTACK_PATCH
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },

View File

@@ -165,6 +165,10 @@ static const Key keys[] = {
#endif // IPC_PATCH
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
#if MOVESTACK_PATCH
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_J, movestack, {.i = +1} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_K, movestack, {.i = -1} },
#endif // MOVESTACK_PATCH
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },

39
dwl.c
View File

@@ -388,6 +388,9 @@ 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);
#if MOVESTACK_PATCH
static void movestack(const Arg *arg);
#endif // MOVESTACK_PATCH
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);
@@ -2572,6 +2575,42 @@ monocle(Monitor *m)
wlr_scene_node_raise_to_top(&c->scene->node);
}
#if MOVESTACK_PATCH
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 (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);
}
#endif // MOVESTACK_PATCH
void
motionabsolute(struct wl_listener *listener, void *data)
{

View File

@@ -12,6 +12,8 @@
#define IPC_PATCH 1
#define MOVESTACK_PATCH 1
#define NATURALSCROLLTRACKPAD_PATCH 1
#define NUMLOCK_CAPSLOCK_PATCH 1

79
patches/movestack.patch Normal file
View File

@@ -0,0 +1,79 @@
From b051f50233033b399db324b29ab24227257ac141 Mon Sep 17 00:00:00 2001
From: wochap <gean.marroquin@gmail.com>
Date: Tue, 5 Mar 2024 23:31:51 -0500
Subject: [PATCH] apply NikitaIvanovV movestack patch
source: https://github.com/djpohly/dwl/wiki/movestack
---
config.def.h | 2 ++
dwl.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/config.def.h b/config.def.h
index db0babc..778a0dc 100644
--- a/config.def.h
+++ b/config.def.h
@@ -122,6 +122,8 @@ static const Key keys[] = {
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
+ { 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, XKB_KEY_h, setmfact, {.f = -0.05} },
diff --git a/dwl.c b/dwl.c
index ef27a1d..69b9756 100644
--- a/dwl.c
+++ b/dwl.c
@@ -279,6 +279,7 @@ static void maplayersurfacenotify(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);
static void motionrelative(struct wl_listener *listener, void *data);
@@ -1603,6 +1604,40 @@ monocle(Monitor *m)
wlr_scene_node_raise_to_top(&c->scene->node);
}
+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 (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)
{
--
2.42.0