summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2020-11-07 07:13:17 -0500
committerLuke Smith <luke@lukesmith.xyz>2020-11-07 07:13:17 -0500
commite29effe9c39f9ad02be23861f8501c2c29a34ad5 (patch)
treeaf083d99a6efb3aee37f54baf970b950777f7096
parentbc040702d9cd576a055f87dab7db92528fadfef2 (diff)
parent231e403ad0f0217e805db1a233ad75ba2e5d0efc (diff)
Merge branch 'master' of github.com:LukeSmithxyz/dwm
-rw-r--r--shiftview.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/shiftview.c b/shiftview.c
index a52ccd7..3d2706b 100644
--- a/shiftview.c
+++ b/shiftview.c
@@ -6,33 +6,29 @@
void
shiftview(const Arg *arg)
{
- Arg a;
+ Arg shifted;
Client *c;
- unsigned visible = 0;
- int i = arg->i;
- int count = 0;
- int nextseltags, curseltags = selmon->tagset[selmon->seltags];
+ unsigned int tagmask = 0;
- do {
- if(i > 0) // left circular shift
- nextseltags = (curseltags << i) | (curseltags >> (LENGTH(tags) - i));
-
- else // right circular shift
- nextseltags = curseltags >> (- i) | (curseltags << (LENGTH(tags) + i));
+ for (c = selmon->clients; c; c = c->next)
+ if (!(c->tags & SPTAGMASK))
+ tagmask = tagmask | c->tags;
- // 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);
+ shifted.ui = selmon->tagset[selmon->seltags] & ~SPTAGMASK;
+ if (arg->i > 0) /* left circular shift */
+ do {
+ shifted.ui = (shifted.ui << arg->i)
+ | (shifted.ui >> (LENGTH(tags) - arg->i));
+ shifted.ui &= ~SPTAGMASK;
+ } while (tagmask && !(shifted.ui & tagmask));
+ else /* right circular shift */
+ do {
+ shifted.ui = (shifted.ui >> (- arg->i)
+ | shifted.ui << (LENGTH(tags) + arg->i));
+ shifted.ui &= ~SPTAGMASK;
+ } while (tagmask && !(shifted.ui & tagmask));
- if (count < 10) {
- a.i = nextseltags;
- view(&a);
- }
+ view(&shifted);
}
void