summaryrefslogtreecommitdiffhomepage
path: root/patch/focusadjacenttag.c
blob: 67dd76892a9ca58309e4bbd2b189591d324e926f (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
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
67
68
69
void
tagtoleft(const Arg *arg)
{
	unsigned int MASK = (1 << NUMTAGS) - 1;
	if (selmon->sel != NULL
	&& __builtin_popcount(selmon->tagset[selmon->seltags] & MASK) == 1
	&& selmon->tagset[selmon->seltags] > 1) {
		selmon->sel->tags >>= 1;
		focus(NULL);
		arrange(selmon);
	}
}

void
tagtoright(const Arg *arg)
{
	unsigned int MASK = (1 << NUMTAGS) - 1;
	if (selmon->sel != NULL
	&& __builtin_popcount(selmon->tagset[selmon->seltags] & MASK) == 1
	&& selmon->tagset[selmon->seltags] & (MASK >> 1)) {
		selmon->sel->tags <<= 1;
		focus(NULL);
		arrange(selmon);
	}
}

void
viewtoleft(const Arg *arg)
{
	unsigned int MASK = (1 << NUMTAGS) - 1;
	if (__builtin_popcount(selmon->tagset[selmon->seltags] & MASK) == 1
	&& selmon->tagset[selmon->seltags] > 1) {
		view(&((Arg) { .ui = selmon->tagset[selmon->seltags] >> 1 }));
	}
}

void
viewtoright(const Arg *arg)
{
	unsigned int MASK = (1 << NUMTAGS) - 1;
	if (__builtin_popcount(selmon->tagset[selmon->seltags] & MASK) == 1
	&& selmon->tagset[selmon->seltags] & (MASK >> 1)) {
		view(&((Arg) { .ui = selmon->tagset[selmon->seltags] << 1 }));
	}
}

void
tagandviewtoleft(const Arg *arg)
{
	unsigned int MASK = (1 << NUMTAGS) - 1;
	if (selmon->sel != NULL
	&& __builtin_popcount(selmon->tagset[selmon->seltags] & MASK) == 1
	&& selmon->tagset[selmon->seltags] > 1) {
		selmon->sel->tags >>= 1;
		view(&((Arg) { .ui = selmon->tagset[selmon->seltags] >> 1 }));
	}
}

void
tagandviewtoright(const Arg *arg)
{
	unsigned int MASK = (1 << NUMTAGS) - 1;
	if (selmon->sel != NULL
	&& __builtin_popcount(selmon->tagset[selmon->seltags] & MASK) == 1
	&& selmon->tagset[selmon->seltags] & (MASK >> 1)) {
		selmon->sel->tags <<= 1;
		view(&((Arg) { .ui = selmon->tagset[selmon->seltags] << 1 }));
	}
}