Fix shiftview behavior with scratchpads patch

Closes #80
This commit is contained in:
Dawid Potocki 2020-11-07 14:43:23 +13:00
parent ad08183a60
commit 5a4e8618d0
No known key found for this signature in database
GPG key ID: 01B6D127EC0E6BDF

View file

@ -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));
for (c = selmon->clients; c; c = c->next)
if (!(c->tags & SPTAGMASK))
tagmask = tagmask | c->tags;
else // right circular shift
nextseltags = curseltags >> (- i) | (curseltags << (LENGTH(tags) + i));
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));
// 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);
}
view(&shifted);
}
void