blob: ddd81ef5d879c0774f1b851431b8ad8c8abfc859 (
plain)
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
|
// shiftview all tags regardless of tags having open windows
void
shiftview(const Arg *arg)
{
Arg view_argument;
uint32_t destination_tag;
// arg->i represents the direction and distance passed from config.def.h (usually -1 and +1)
if(arg->i > 0){
// shift right (increase tag index), move the active tag bit to the left (0001) to (0010)
destination_tag = selmon->tagset[selmon->seltags] << arg->i;
}else{
// shift to the left
destination_tag = selmon->tagset[selmon->seltags] >> (-arg->i);
}
// TAGMASK defines the valid boundary for tags (111111111) for 9 tags
// if the shift pushed the active bit outside the bounds, destination_tag will become 0
if(!(destination_tag & TAGMASK)){
// If we went off to the right edge, wrap around to the first tag (000000001)
// If we went off to the left, wrap around to the last tag (bit 1 shifted left by TAGCOUNT - 1)
destination_tag = arg->i > 0 ? 1 : 1 << (TAGCOUNT - 1);
}
// pack the destination tag bitmask into the required dwl argument struct
view_argument.ui = destination_tag;
// pass the destination tag to dwl's view function
view(&view_argument);
}
|