diff --git a/patches/shifttag/shifttag-bar.patch b/patches/shifttag/shifttag-bar.patch index 863b8e6..df781b5 100644 --- a/patches/shifttag/shifttag-bar.patch +++ b/patches/shifttag/shifttag-bar.patch @@ -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 Date: Mon, 23 Mar 2026 01:16:06 +0800 Subject: [PATCH] shifttag with filtering occupied/unoccupied tags support for bar patch --- - config.def.h | 8 +++++ - shifttag.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 107 insertions(+) + config.def.h | 8 ++++ + shifttag.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 123 insertions(+) create mode 100644 shifttag.c 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]} }, diff --git a/shifttag.c b/shifttag.c new file mode 100644 -index 0000000..2615f4c +index 0000000..5f1d5c2 --- /dev/null +++ b/shifttag.c -@@ -0,0 +1,99 @@ +@@ -0,0 +1,115 @@ +// "arg->i" stores the number of tags to shift right (positive 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) +{ + uint32_t occupied = get_occupied_tags(selmon); -+ uint32_t start = current_tag; -+ uint32_t test_tag = current_tag; -+ uint32_t new_tag = current_tag; -+ int count = 0; ++ uint32_t result = 0; + -+ if (!skip_unoccupied && !skip_occupied) { -+ if (direction > 0) { -+ new_tag = (current_tag << 1) | (current_tag >> (LENGTH(tags) - 1)); -+ } else { -+ new_tag = (current_tag >> 1) | (current_tag << (LENGTH(tags) - 1)); ++ for (int i = 0; i < LENGTH(tags); i++) { ++ uint32_t bit = 1 << i; ++ ++ if (current_tag & bit) { ++ uint32_t new_bit = bit; ++ ++ if (!skip_unoccupied && !skip_occupied) { ++ if (direction > 0) { ++ if (bit << 1 && (bit << 1) <= TAGMASK) ++ new_bit = bit << 1; ++ else ++ new_bit = 1; ++ } else { ++ if (bit >> 1) ++ new_bit = bit >> 1; ++ else ++ new_bit = 1 << (LENGTH(tags) - 1); ++ } ++ } else { ++ uint32_t test_bit = bit; ++ uint32_t start_bit = bit; ++ int count = 0; ++ ++ do { ++ if (direction > 0) { ++ if (test_bit << 1 && (test_bit << 1) <= TAGMASK) ++ test_bit = test_bit << 1; ++ else ++ test_bit = 1; ++ } else { ++ if (test_bit >> 1) ++ test_bit = test_bit >> 1; ++ else ++ test_bit = 1 << (LENGTH(tags) - 1); ++ } ++ ++ int is_occupied = (occupied & test_bit) != 0; ++ int should_select = (skip_unoccupied && is_occupied) || ++ (skip_occupied && !is_occupied); ++ ++ if (should_select) { ++ new_bit = test_bit; ++ break; ++ } ++ count++; ++ } while (test_bit != start_bit && count < LENGTH(tags)); ++ } ++ ++ result |= new_bit; + } -+ return new_tag & TAGMASK; + } + -+ do { -+ if (direction > 0) { -+ if (test_tag << 1 && (test_tag << 1) <= TAGMASK) -+ test_tag = test_tag << 1; -+ else -+ test_tag = 1; -+ } else { -+ if (test_tag >> 1) -+ test_tag = test_tag >> 1; -+ else -+ test_tag = 1 << (LENGTH(tags) - 1); -+ } -+ -+ int is_occupied = (occupied & test_tag) != 0; -+ int should_select = (skip_unoccupied && is_occupied) || -+ (skip_occupied && !is_occupied); -+ -+ if (should_select) { -+ new_tag = test_tag; -+ break; -+ } -+ count++; -+ } while (test_tag != start && count < LENGTH(tags)); -+ -+ return new_tag; ++ return result; +} + +static void diff --git a/patches/shifttag/shifttag.patch b/patches/shifttag/shifttag.patch index 82ccf15..1220a8f 100644 --- a/patches/shifttag/shifttag.patch +++ b/patches/shifttag/shifttag.patch @@ -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 Date: Mon, 23 Mar 2026 00:50:54 +0800 Subject: [PATCH] shifttag with filtering occupied/unoccupied tags support --- - config.def.h | 8 +++++ - shifttag.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 107 insertions(+) + config.def.h | 8 ++++ + shifttag.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 123 insertions(+) create mode 100644 shifttag.c 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]} }, diff --git a/shifttag.c b/shifttag.c new file mode 100644 -index 0000000..5aeee00 +index 0000000..971216b --- /dev/null +++ b/shifttag.c -@@ -0,0 +1,99 @@ +@@ -0,0 +1,115 @@ +// "arg->i" stores the number of tags to shift right (positive 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) +{ + uint32_t occupied = get_occupied_tags(selmon); -+ uint32_t start = current_tag; -+ uint32_t test_tag = current_tag; -+ uint32_t new_tag = current_tag; -+ int count = 0; ++ uint32_t result = 0; + -+ if (!skip_unoccupied && !skip_occupied) { -+ if (direction > 0) { -+ new_tag = (current_tag << 1) | (current_tag >> (TAGCOUNT - 1)); -+ } else { -+ new_tag = (current_tag >> 1) | (current_tag << (TAGCOUNT - 1)); ++ for (int i = 0; i < TAGCOUNT; i++) { ++ uint32_t bit = 1 << i; ++ ++ if (current_tag & bit) { ++ uint32_t new_bit = bit; ++ ++ if (!skip_unoccupied && !skip_occupied) { ++ if (direction > 0) { ++ if (bit << 1 && (bit << 1) <= TAGMASK) ++ new_bit = bit << 1; ++ else ++ new_bit = 1; ++ } else { ++ if (bit >> 1) ++ new_bit = bit >> 1; ++ else ++ new_bit = 1 << (TAGCOUNT - 1); ++ } ++ } else { ++ uint32_t test_bit = bit; ++ uint32_t start_bit = bit; ++ int count = 0; ++ ++ do { ++ if (direction > 0) { ++ if (test_bit << 1 && (test_bit << 1) <= TAGMASK) ++ test_bit = test_bit << 1; ++ else ++ test_bit = 1; ++ } else { ++ if (test_bit >> 1) ++ test_bit = test_bit >> 1; ++ else ++ test_bit = 1 << (TAGCOUNT - 1); ++ } ++ ++ int is_occupied = (occupied & test_bit) != 0; ++ int should_select = (skip_unoccupied && is_occupied) || ++ (skip_occupied && !is_occupied); ++ ++ if (should_select) { ++ new_bit = test_bit; ++ break; ++ } ++ count++; ++ } while (test_bit != start_bit && count < TAGCOUNT); ++ } ++ ++ result |= new_bit; + } -+ return new_tag & TAGMASK; + } + -+ do { -+ if (direction > 0) { -+ if (test_tag << 1 && (test_tag << 1) <= TAGMASK) -+ test_tag = test_tag << 1; -+ else -+ test_tag = 1; -+ } else { -+ if (test_tag >> 1) -+ test_tag = test_tag >> 1; -+ else -+ test_tag = 1 << (TAGCOUNT - 1); -+ } -+ -+ int is_occupied = (occupied & test_tag) != 0; -+ int should_select = (skip_unoccupied && is_occupied) || -+ (skip_occupied && !is_occupied); -+ -+ if (should_select) { -+ new_tag = test_tag; -+ break; -+ } -+ count++; -+ } while (test_tag != start && count < TAGCOUNT); -+ -+ return new_tag; ++ return result; +} + +static void