summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2020-03-29 11:36:20 -0400
committerLuke Smith <luke@lukesmith.xyz>2020-03-29 11:36:20 -0400
commit06cc0e0de9eea23452d51ddeddf420b89728cea7 (patch)
treeb6272cbf793bc440a57ceab32c976420e8bd8f61
parentc765d2e6785217fd8726dac71b30d96d1a046b35 (diff)
only cycle through active tags
-rw-r--r--shiftview.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/shiftview.c b/shiftview.c
index e82053a..b592a67 100644
--- a/shiftview.c
+++ b/shiftview.c
@@ -4,16 +4,33 @@
* or left (negative value)
*/
void
-shiftview(const Arg *arg) {
- Arg shifted;
+shiftview(const Arg *arg)
+{
+ Arg a;
+ Client *c;
+ unsigned visible = 0;
+ int i = arg->i;
+ int count = 0;
+ int nextseltags, curseltags = selmon->tagset[selmon->seltags];
- if(arg->i > 0) // left circular shift
- shifted.ui = (selmon->tagset[selmon->seltags] << arg->i)
- | (selmon->tagset[selmon->seltags] >> (LENGTH(tags) - arg->i));
+ do {
+ if(i > 0) // left circular shift
+ nextseltags = (curseltags << i) | (curseltags >> (LENGTH(tags) - i));
- else // right circular shift
- shifted.ui = selmon->tagset[selmon->seltags] >> (- arg->i)
- | selmon->tagset[selmon->seltags] << (LENGTH(tags) + arg->i);
+ else // right circular shift
+ nextseltags = curseltags >> (- i) | (curseltags << (LENGTH(tags) + i));
- view(&shifted);
+ // Check if tag is visible
+ for (c = selmon->clients; c && !visible; c = c->next)
+ if (nextseltags & c->tags) {
+ visible = 1;
+ break;
+ }
+ i += arg->i;
+ } while (!visible && ++count < 10);
+
+ if (count < 10) {
+ a.i = nextseltags;
+ view(&a);
+ }
}