summaryrefslogtreecommitdiff
path: root/shiftview.c
diff options
context:
space:
mode:
authorChris Sobczak <chris@sobczak.family>2026-06-26 20:31:23 -0700
committerChris Sobczak <chris@sobczak.family>2026-06-26 20:31:23 -0700
commit1ea0c20cbed805445e8153659f6d11f4e8a4a227 (patch)
treec277368f46da504433ea0c3c588f1c721f0e1661 /shiftview.c
parent32fb3dce58a26c6126d2be96a0b526673ed9132c (diff)
parent8cd908a0a3fca2f870ed53f0b9a1ff79752f5a8d (diff)
Merge branch 'shiftview' into csobczak
Add shiftview functionality to csobczak dwl
Diffstat (limited to 'shiftview.c')
-rw-r--r--shiftview.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/shiftview.c b/shiftview.c
new file mode 100644
index 0000000..ddd81ef
--- /dev/null
+++ b/shiftview.c
@@ -0,0 +1,30 @@
+// shiftview all tags regardless of tags having open windows
+void
+shiftview(const Arg *arg)
+{
+ Arg view_argument;
+ uint32_t destination_tag;
+
+ // arg->i represents the direction and distance passed from config.def.h (usually -1 and +1)
+ if(arg->i > 0){
+ // shift right (increase tag index), move the active tag bit to the left (0001) to (0010)
+ destination_tag = selmon->tagset[selmon->seltags] << arg->i;
+ }else{
+ // shift to the left
+ destination_tag = selmon->tagset[selmon->seltags] >> (-arg->i);
+ }
+
+ // TAGMASK defines the valid boundary for tags (111111111) for 9 tags
+ // if the shift pushed the active bit outside the bounds, destination_tag will become 0
+ if(!(destination_tag & TAGMASK)){
+ // If we went off to the right edge, wrap around to the first tag (000000001)
+ // If we went off to the left, wrap around to the last tag (bit 1 shifted left by TAGCOUNT - 1)
+ destination_tag = arg->i > 0 ? 1 : 1 << (TAGCOUNT - 1);
+ }
+
+ // pack the destination tag bitmask into the required dwl argument struct
+ view_argument.ui = destination_tag;
+
+ // pass the destination tag to dwl's view function
+ view(&view_argument);
+}