-
Notifications
You must be signed in to change notification settings - Fork 0
/
shiftview.c
66 lines (58 loc) · 1.83 KB
/
shiftview.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* Navigate to the next/prev tag */
void
shiftview(const Arg *arg)
{
Arg shifted;
Client *c;
unsigned int tagmask = 0;
// Uncomment this if you want to move between vacant tags.
// if (arg->i > 0) // left circular shift
// shifted.ui = (selmon->tagset[selmon->seltags] << arg->i)
// | (selmon->tagset[selmon->seltags] >> (LENGTH(tags) - arg->i));
// else // right circular shift
// shifted.ui = selmon->tagset[selmon->seltags] >> (- arg->i)
// | selmon->tagset[selmon->seltags] << (LENGTH(tags) + arg->i);
for (c = selmon->clients; c; c = c->next)
#if SCRATCHPADS_PATCH
if (!(c->tags & SPTAGMASK)) {
tagmask = tagmask | c->tags;
}
#else
tagmask = tagmask | c->tags;
#endif // SCRATCHPADS_PATCH
#if SCRATCHPADS_PATCH
shifted.ui = selmon->tagset[selmon->seltags] & ~SPTAGMASK;
#else
shifted.ui = selmon->tagset[selmon->seltags];
#endif // SCRATCHPADS_PATCH
if (arg->i > 0) // left circular shift
do {
shifted.ui = (shifted.ui << arg->i)
| (shifted.ui >> (LENGTH(tags) - arg->i));
#if SCRATCHPADS_PATCH
shifted.ui &= ~SPTAGMASK;
#endif // SCRATCHPADS_PATCH
} while (tagmask && !(shifted.ui & tagmask));
else // right circular shift
do {
shifted.ui = (shifted.ui >> (- arg->i)
| shifted.ui << (LENGTH(tags) + arg->i));
#if SCRATCHPADS_PATCH
shifted.ui &= ~SPTAGMASK;
#endif // SCRATCHPADS_PATCH
} while (tagmask && !(shifted.ui & tagmask));
view(&shifted);
}
/* Sends a window to the next/prev tag */
void
shifttag(const Arg *arg)
{
Arg shifted;
shifted.ui = selmon->tagset[selmon->seltags];
if (arg->i > 0) { /* left circular shift */
shifted.ui = ((shifted.ui << arg->i) | (shifted.ui >> (LENGTH(tags) - arg->i)));
} else { /* right circular shift */
shifted.ui = (shifted.ui >> (- arg->i) | shifted.ui << (LENGTH(tags) + arg->i));
}
tag(&shifted);
}