summaryrefslogtreecommitdiffhomepage
path: root/patch/swaptags.c
blob: d2341efb6ca3805e80bf7d59eacc42f68d5e5685 (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
void
swaptags(const Arg *arg)
{
	Client *c;
	unsigned int newtag = arg->ui & TAGMASK;
	unsigned int curtag = selmon->tagset[selmon->seltags];

	if (newtag == curtag || !curtag || (curtag & (curtag-1)))
		return;

	#if TAGSYNC_PATCH
	Monitor *origselmon = selmon;
	for (selmon = mons; selmon; selmon = selmon->next) {
	#endif // TAGSYNC_PATCH

	for (c = selmon->clients; c != NULL; c = c->next) {
		if ((c->tags & newtag) || (c->tags & curtag))
			c->tags ^= curtag ^ newtag;

		if (!c->tags)
				c->tags = newtag;
	}

	#if TAGSYNC_PATCH
	}
	selmon = origselmon;
	#endif // TAGSYNC_PATCH

	view(&((Arg) { .ui = newtag }));
}