Introduction
Introduction Statistics Contact Development Disclaimer Help
shift-tools.c - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
shift-tools.c (2437B)
---
1 void
2 shift(unsigned int *tag, int i)
3 {
4 if (i > 0) /* left circular shift */
5 *tag = ((*tag << i) | (*tag >> (LENGTH(tags) - i)));
6 else /* right circular shift */
7 *tag = (*tag >> (- i) | *tag << (LENGTH(tags) + i));
8 }
9
10 /* send a window to the next/prev tag */
11 void
12 shifttag(const Arg *arg)
13 {
14 Arg shifted = { .ui = selmon->tagset[selmon->seltags] };
15
16 if (!selmon->clients)
17 return;
18
19 shift(&shifted.ui, arg->i);
20 tag(&shifted);
21 }
22
23 /* send a window to the next/prev tag that has a client, else it moves i…
24 * the next/prev one. */
25 void
26 shifttagclients(const Arg *arg)
27 {
28 Arg shifted = { .ui = selmon->tagset[selmon->seltags] };
29 Client *c;
30 unsigned int tagmask = 0;
31
32 for (c = selmon->clients; c; c = c->next)
33 tagmask = tagmask | c->tags;
34
35 do
36 shift(&shifted.ui, arg->i);
37 while (tagmask && !(shifted.ui & tagmask));
38
39 tag(&shifted);
40 }
41
42 /* view the next/prev tag */
43 void
44 shiftview(const Arg *arg)
45 {
46 Arg shifted = { .ui = selmon->tagset[selmon->seltags] };
47
48 shift(&shifted.ui, arg->i);
49 view(&shifted);
50 }
51
52 /* view the next/prev tag that has a client, else view the next/prev tag…
53 void
54 shiftviewclients(const Arg *arg)
55 {
56 Arg shifted = { .ui = selmon->tagset[selmon->seltags] };
57 Client *c;
58 unsigned int tagmask = 0;
59
60 for (c = selmon->clients; c; c = c->next)
61 tagmask = tagmask | c->tags;
62
63 do
64 shift(&shifted.ui, arg->i);
65 while (tagmask && !(shifted.ui & tagmask));
66
67 view(&shifted);
68 }
69
70 /* move the active window to the next/prev tag and view it's new tag */
71 void
72 shiftboth(const Arg *arg)
73 {
74 Arg shifted = { .ui = selmon->tagset[selmon->seltags] };
75
76 shift(&shifted.ui, arg->i);
77 tag(&shifted);
78 view(&shifted);
79 }
80
81 /* swaptags: https://dwm.suckless.org/patches/swaptags, used below */
82 void
83 swaptags(const Arg *arg)
84 {
85 Client *c;
86 unsigned int newtag = arg->ui & TAGMASK;
87 unsigned int curtag = selmon->tagset[selmon->seltags];
88
89 if (newtag == curtag || !curtag || (curtag & (curtag-1)))
90 return;
91
92 for (c = selmon->clients; c != NULL; c = c->next) {
93 if ((c->tags & newtag) || (c->tags & curtag))
94 c->tags ^= curtag ^ newtag;
95 if (!c->tags)
96 c->tags = newtag;
97 }
98
99 //uncomment to 'view' the new swaped tag
100 //selmon->tagset[selmon->seltags] = newtag;
101
102 focus(NULL);
103 arrange(selmon);
104 }
105
106 /* swaps "tags" (all the clients on it) with the next/prev tag */
107 void
108 shiftswaptags(const Arg *arg)
109 {
110 Arg shifted = { .ui = selmon->tagset[selmon->seltags] };
111
112 shift(&shifted.ui, arg->i);
113 swaptags(&shifted);
114 }
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.