Compare commits

...

2 Commits

Author SHA1 Message Date
nate zhou
998808b303 sticky: update for 0.8 2026-03-23 14:16:54 +01:00
nate zhou
24fa6e04ce
shifttag: fix shifting to unoccupied with multiple tags 2026-03-23 20:24:42 +08:00
4 changed files with 130 additions and 97 deletions

View File

@ -1,13 +1,13 @@
From 6d3a0506f45243cf11f0f7ba06048f453576567c Mon Sep 17 00:00:00 2001 From 8dff34be15664705654e5e4d41f990f8eba8b79d Mon Sep 17 00:00:00 2001
From: nate zhou <gnuunixchad@outlook.com> From: nate zhou <gnuunixchad@outlook.com>
Date: Mon, 23 Mar 2026 01:16:06 +0800 Date: Mon, 23 Mar 2026 01:16:06 +0800
Subject: [PATCH] shifttag with filtering occupied/unoccupied tags support for Subject: [PATCH] shifttag with filtering occupied/unoccupied tags support for
bar patch bar patch
--- ---
config.def.h | 8 +++++ config.def.h | 8 ++++
shifttag.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++ shifttag.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 107 insertions(+) 2 files changed, 123 insertions(+)
create mode 100644 shifttag.c create mode 100644 shifttag.c
diff --git a/config.def.h b/config.def.h diff --git a/config.def.h b/config.def.h
@ -38,10 +38,10 @@ index 7da50d2..9fbcf2a 100644
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
diff --git a/shifttag.c b/shifttag.c diff --git a/shifttag.c b/shifttag.c
new file mode 100644 new file mode 100644
index 0000000..2615f4c index 0000000..5f1d5c2
--- /dev/null --- /dev/null
+++ b/shifttag.c +++ b/shifttag.c
@@ -0,0 +1,99 @@ @@ -0,0 +1,115 @@
+// "arg->i" stores the number of tags to shift right (positive value) +// "arg->i" stores the number of tags to shift right (positive value)
+// or left (negative value) +// or left (negative value)
+ +
@ -61,45 +61,61 @@ index 0000000..2615f4c
+find_next_tag(uint32_t current_tag, int direction, bool skip_unoccupied, bool skip_occupied) +find_next_tag(uint32_t current_tag, int direction, bool skip_unoccupied, bool skip_occupied)
+{ +{
+ uint32_t occupied = get_occupied_tags(selmon); + uint32_t occupied = get_occupied_tags(selmon);
+ uint32_t start = current_tag; + uint32_t result = 0;
+ uint32_t test_tag = current_tag; +
+ uint32_t new_tag = current_tag; + for (int i = 0; i < LENGTH(tags); i++) {
+ int count = 0; + uint32_t bit = 1 << i;
+
+ if (current_tag & bit) {
+ uint32_t new_bit = bit;
+ +
+ if (!skip_unoccupied && !skip_occupied) { + if (!skip_unoccupied && !skip_occupied) {
+ if (direction > 0) { + if (direction > 0) {
+ new_tag = (current_tag << 1) | (current_tag >> (LENGTH(tags) - 1)); + if (bit << 1 && (bit << 1) <= TAGMASK)
+ new_bit = bit << 1;
+ else
+ new_bit = 1;
+ } else { + } else {
+ new_tag = (current_tag >> 1) | (current_tag << (LENGTH(tags) - 1)); + if (bit >> 1)
+ } + new_bit = bit >> 1;
+ return new_tag & TAGMASK; + else
+ new_bit = 1 << (LENGTH(tags) - 1);
+ } + }
+ } else {
+ uint32_t test_bit = bit;
+ uint32_t start_bit = bit;
+ int count = 0;
+ +
+ do { + do {
+ if (direction > 0) { + if (direction > 0) {
+ if (test_tag << 1 && (test_tag << 1) <= TAGMASK) + if (test_bit << 1 && (test_bit << 1) <= TAGMASK)
+ test_tag = test_tag << 1; + test_bit = test_bit << 1;
+ else + else
+ test_tag = 1; + test_bit = 1;
+ } else { + } else {
+ if (test_tag >> 1) + if (test_bit >> 1)
+ test_tag = test_tag >> 1; + test_bit = test_bit >> 1;
+ else + else
+ test_tag = 1 << (LENGTH(tags) - 1); + test_bit = 1 << (LENGTH(tags) - 1);
+ } + }
+ +
+ int is_occupied = (occupied & test_tag) != 0; + int is_occupied = (occupied & test_bit) != 0;
+ int should_select = (skip_unoccupied && is_occupied) || + int should_select = (skip_unoccupied && is_occupied) ||
+ (skip_occupied && !is_occupied); + (skip_occupied && !is_occupied);
+ +
+ if (should_select) { + if (should_select) {
+ new_tag = test_tag; + new_bit = test_bit;
+ break; + break;
+ } + }
+ count++; + count++;
+ } while (test_tag != start && count < LENGTH(tags)); + } while (test_bit != start_bit && count < LENGTH(tags));
+ }
+ +
+ return new_tag; + result |= new_bit;
+ }
+ }
+
+ return result;
+} +}
+ +
+static void +static void

View File

@ -1,12 +1,12 @@
From 49b0da41f1f28a60cf216f5bffecc0ce1ea1ec9c Mon Sep 17 00:00:00 2001 From 2a4417a6344c9d4b83989d63df17d9cdb0f81aea Mon Sep 17 00:00:00 2001
From: nate zhou <gnuunixchad@outlook.com> From: nate zhou <gnuunixchad@outlook.com>
Date: Mon, 23 Mar 2026 00:50:54 +0800 Date: Mon, 23 Mar 2026 00:50:54 +0800
Subject: [PATCH] shifttag with filtering occupied/unoccupied tags support Subject: [PATCH] shifttag with filtering occupied/unoccupied tags support
--- ---
config.def.h | 8 +++++ config.def.h | 8 ++++
shifttag.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++ shifttag.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 107 insertions(+) 2 files changed, 123 insertions(+)
create mode 100644 shifttag.c create mode 100644 shifttag.c
diff --git a/config.def.h b/config.def.h diff --git a/config.def.h b/config.def.h
@ -37,10 +37,10 @@ index 8a6eda0..2377fa5 100644
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
diff --git a/shifttag.c b/shifttag.c diff --git a/shifttag.c b/shifttag.c
new file mode 100644 new file mode 100644
index 0000000..5aeee00 index 0000000..971216b
--- /dev/null --- /dev/null
+++ b/shifttag.c +++ b/shifttag.c
@@ -0,0 +1,99 @@ @@ -0,0 +1,115 @@
+// "arg->i" stores the number of tags to shift right (positive value) +// "arg->i" stores the number of tags to shift right (positive value)
+// or left (negative value) +// or left (negative value)
+ +
@ -60,45 +60,61 @@ index 0000000..5aeee00
+find_next_tag(uint32_t current_tag, int direction, bool skip_unoccupied, bool skip_occupied) +find_next_tag(uint32_t current_tag, int direction, bool skip_unoccupied, bool skip_occupied)
+{ +{
+ uint32_t occupied = get_occupied_tags(selmon); + uint32_t occupied = get_occupied_tags(selmon);
+ uint32_t start = current_tag; + uint32_t result = 0;
+ uint32_t test_tag = current_tag; +
+ uint32_t new_tag = current_tag; + for (int i = 0; i < TAGCOUNT; i++) {
+ int count = 0; + uint32_t bit = 1 << i;
+
+ if (current_tag & bit) {
+ uint32_t new_bit = bit;
+ +
+ if (!skip_unoccupied && !skip_occupied) { + if (!skip_unoccupied && !skip_occupied) {
+ if (direction > 0) { + if (direction > 0) {
+ new_tag = (current_tag << 1) | (current_tag >> (TAGCOUNT - 1)); + if (bit << 1 && (bit << 1) <= TAGMASK)
+ new_bit = bit << 1;
+ else
+ new_bit = 1;
+ } else { + } else {
+ new_tag = (current_tag >> 1) | (current_tag << (TAGCOUNT - 1)); + if (bit >> 1)
+ } + new_bit = bit >> 1;
+ return new_tag & TAGMASK; + else
+ new_bit = 1 << (TAGCOUNT - 1);
+ } + }
+ } else {
+ uint32_t test_bit = bit;
+ uint32_t start_bit = bit;
+ int count = 0;
+ +
+ do { + do {
+ if (direction > 0) { + if (direction > 0) {
+ if (test_tag << 1 && (test_tag << 1) <= TAGMASK) + if (test_bit << 1 && (test_bit << 1) <= TAGMASK)
+ test_tag = test_tag << 1; + test_bit = test_bit << 1;
+ else + else
+ test_tag = 1; + test_bit = 1;
+ } else { + } else {
+ if (test_tag >> 1) + if (test_bit >> 1)
+ test_tag = test_tag >> 1; + test_bit = test_bit >> 1;
+ else + else
+ test_tag = 1 << (TAGCOUNT - 1); + test_bit = 1 << (TAGCOUNT - 1);
+ } + }
+ +
+ int is_occupied = (occupied & test_tag) != 0; + int is_occupied = (occupied & test_bit) != 0;
+ int should_select = (skip_unoccupied && is_occupied) || + int should_select = (skip_unoccupied && is_occupied) ||
+ (skip_occupied && !is_occupied); + (skip_occupied && !is_occupied);
+ +
+ if (should_select) { + if (should_select) {
+ new_tag = test_tag; + new_bit = test_bit;
+ break; + break;
+ } + }
+ count++; + count++;
+ } while (test_tag != start && count < TAGCOUNT); + } while (test_bit != start_bit && count < TAGCOUNT);
+ }
+ +
+ return new_tag; + result |= new_bit;
+ }
+ }
+
+ return result;
+} +}
+ +
+static void +static void

View File

@ -4,7 +4,8 @@ Adds a toggleable function that makes a sticky client that is visible on all tag
Originally based on [dwm sticky patch](https://dwm.suckless.org/patches/sticky). Originally based on [dwm sticky patch](https://dwm.suckless.org/patches/sticky).
### Download ### Download
- [2024-07-26](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/sticky/sticky.patch) - [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/sticky/sticky.patch)
- [v0.7](https://codeberg.org/dwl/dwl-patches/raw/commit/898bc7a946c7be14034a665bd7a7b042632465ea/patches/sticky/sticky.patch)
- [v0.4](https://github.com/djpohly/dwl/compare/main...dm1tz:04-sticky.patch) - [v0.4](https://github.com/djpohly/dwl/compare/main...dm1tz:04-sticky.patch)
- [git branch](https://codeberg.org/Rutherther/dwl/src/branch/v0.7/sticky) - [git branch](https://codeberg.org/Rutherther/dwl/src/branch/v0.7/sticky)

View File

@ -1,17 +1,17 @@
From f113cdc0b4cecceaaf28679489852ae61a1aa3f5 Mon Sep 17 00:00:00 2001 From d36eee35fdc4b0e666fb04a580200e8c5d2b1f9e Mon Sep 17 00:00:00 2001
From: Rutherther <rutherther@proton.me> From: nate zhou <gnuunixchad@outlook.com>
Date: Fri, 19 Jul 2024 16:29:43 +0200 Date: Sat, 28 Feb 2026 22:55:33 +0800
Subject: [PATCH] sticky Subject: [PATCH] Update sticky patch to v0.8
--- ---
dwl.c | 27 +++++++++++++++++++++++++-- dwl.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-) 1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/dwl.c b/dwl.c diff --git a/dwl.c b/dwl.c
index 5bf995e..820f4af 100644 index 44f3ad9..05070ef 100644
--- a/dwl.c --- a/dwl.c
+++ b/dwl.c +++ b/dwl.c
@@ -73,7 +73,7 @@ @@ -74,7 +74,7 @@
#define MAX(A, B) ((A) > (B) ? (A) : (B)) #define MAX(A, B) ((A) > (B) ? (A) : (B))
#define MIN(A, B) ((A) < (B) ? (A) : (B)) #define MIN(A, B) ((A) < (B) ? (A) : (B))
#define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS) #define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS)
@ -20,7 +20,7 @@ index 5bf995e..820f4af 100644
#define LENGTH(X) (sizeof X / sizeof X[0]) #define LENGTH(X) (sizeof X / sizeof X[0])
#define END(A) ((A) + LENGTH(A)) #define END(A) ((A) + LENGTH(A))
#define TAGMASK ((1u << TAGCOUNT) - 1) #define TAGMASK ((1u << TAGCOUNT) - 1)
@@ -139,7 +139,7 @@ typedef struct { @@ -137,7 +137,7 @@ typedef struct {
#endif #endif
unsigned int bw; unsigned int bw;
uint32_t tags; uint32_t tags;
@ -29,15 +29,15 @@ index 5bf995e..820f4af 100644
uint32_t resize; /* configure serial of a pending resize */ uint32_t resize; /* configure serial of a pending resize */
} Client; } Client;
@@ -326,6 +326,7 @@ static void setcursor(struct wl_listener *listener, void *data); @@ -323,6 +323,7 @@ static void setcursor(struct wl_listener *listener, void *data);
static void setcursorshape(struct wl_listener *listener, void *data); static void setcursorshape(struct wl_listener *listener, void *data);
static void setfloating(Client *c, int floating); static void setfloating(Client *c, int floating);
static void setfullscreen(Client *c, int fullscreen); static void setfullscreen(Client *c, int fullscreen);
+static void setsticky(Client *c, int sticky); +static void setsticky(Client *c, int sticky);
static void setgamma(struct wl_listener *listener, void *data);
static void setlayout(const Arg *arg); static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg); static void setmfact(const Arg *arg);
@@ -339,6 +340,7 @@ static void tag(const Arg *arg); static void setmon(Client *c, Monitor *m, uint32_t newtags);
@@ -335,6 +336,7 @@ static void tag(const Arg *arg);
static void tagmon(const Arg *arg); static void tagmon(const Arg *arg);
static void tile(Monitor *m); static void tile(Monitor *m);
static void togglefloating(const Arg *arg); static void togglefloating(const Arg *arg);
@ -45,8 +45,8 @@ index 5bf995e..820f4af 100644
static void togglefullscreen(const Arg *arg); static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg); static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg); static void toggleview(const Arg *arg);
@@ -2351,6 +2353,17 @@ setgamma(struct wl_listener *listener, void *data) @@ -2368,6 +2370,17 @@ setfullscreen(Client *c, int fullscreen)
wlr_output_schedule_frame(m->wlr_output); printstatus();
} }
+void +void
@ -63,7 +63,7 @@ index 5bf995e..820f4af 100644
void void
setlayout(const Arg *arg) setlayout(const Arg *arg)
{ {
@@ -2738,6 +2751,16 @@ togglefullscreen(const Arg *arg) @@ -2760,6 +2773,16 @@ togglefullscreen(const Arg *arg)
setfullscreen(sel, !sel->isfullscreen); setfullscreen(sel, !sel->isfullscreen);
} }
@ -81,5 +81,5 @@ index 5bf995e..820f4af 100644
toggletag(const Arg *arg) toggletag(const Arg *arg)
{ {
-- --
2.45.2 2.53.0