2019-12-15 21:10:30 +00:00
|
|
|
/** Function to shift the current view to the left/right
|
|
|
|
*
|
|
|
|
* @param: "arg->i" stores the number of tags to shift right (positive value)
|
|
|
|
* or left (negative value)
|
|
|
|
*/
|
|
|
|
void
|
2020-03-29 15:36:20 +00:00
|
|
|
shiftview(const Arg *arg)
|
|
|
|
{
|
2020-11-07 01:43:23 +00:00
|
|
|
Arg shifted;
|
2020-03-29 15:36:20 +00:00
|
|
|
Client *c;
|
2020-11-07 01:43:23 +00:00
|
|
|
unsigned int tagmask = 0;
|
2019-12-15 21:10:30 +00:00
|
|
|
|
2020-11-07 01:43:23 +00:00
|
|
|
for (c = selmon->clients; c; c = c->next)
|
|
|
|
if (!(c->tags & SPTAGMASK))
|
|
|
|
tagmask = tagmask | c->tags;
|
2019-12-15 21:10:30 +00:00
|
|
|
|
2020-11-07 01:43:23 +00:00
|
|
|
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));
|
2020-03-29 15:36:20 +00:00
|
|
|
|
2020-11-07 01:43:23 +00:00
|
|
|
view(&shifted);
|
2019-12-15 21:10:30 +00:00
|
|
|
}
|
2020-05-03 20:08:23 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
shifttag(const Arg *arg)
|
|
|
|
{
|
|
|
|
Arg a;
|
|
|
|
Client *c;
|
|
|
|
unsigned visible = 0;
|
|
|
|
int i = arg->i;
|
|
|
|
int count = 0;
|
|
|
|
int nextseltags, curseltags = selmon->tagset[selmon->seltags];
|
|
|
|
|
|
|
|
do {
|
|
|
|
if(i > 0) // left circular shift
|
|
|
|
nextseltags = (curseltags << i) | (curseltags >> (LENGTH(tags) - i));
|
|
|
|
|
|
|
|
else // right circular shift
|
2022-10-07 21:01:01 +00:00
|
|
|
nextseltags = (curseltags >> - i) | (curseltags << (LENGTH(tags) + i));
|
2020-05-03 20:08:23 +00:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
tag(&a);
|
|
|
|
}
|
|
|
|
}
|
2022-10-07 21:01:01 +00:00
|
|
|
|