diff options
Diffstat (limited to 'shiftview.c')
| -rw-r--r-- | shiftview.c | 30 |
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); +} |
