-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03-dwm-6.0-cycle.diff
57 lines (54 loc) · 1.23 KB
/
03-dwm-6.0-cycle.diff
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
Homepage: http://hg.punctweb.ro
--- a/dwm.c 2013-02-11 22:11:39.156773230 +0200
+++ b/dwm.c 2013-02-11 22:11:39.158773230 +0200
@@ -266,6 +266,9 @@ static void bstack(Monitor *m);
static Client *prevtiled(Client *c);
static void pushup(const Arg *arg);
static void pushdown(const Arg *arg);
+static void cycle(const Arg *arg);
+static int shifttag(int dist);
+static void tagcycle(const Arg *arg);
/* variables */
static const char broken[] = "broken";
@@ -2302,6 +2305,42 @@ pushdown(const Arg *arg) {
}
int
+shifttag(int dist) {
+ int i, curtags;
+ int seltag = 0;
+ int numtags = LENGTH(tags);
+
+ curtags = selmon->tagset[selmon->seltags];
+ for(i = 0; i < LENGTH(tags); i++) {
+ if((curtags & (1 << i)) != 0) {
+ seltag = i;
+ break;
+ }
+ }
+
+ seltag += dist;
+ if(seltag < 0)
+ seltag = numtags - (-seltag) % numtags;
+ else
+ seltag %= numtags;
+
+ return 1 << seltag;
+}
+
+void
+cycle(const Arg *arg) {
+ const Arg a = { .i = shifttag(arg->i) };
+ view(&a);
+}
+
+void
+tagcycle(const Arg *arg) {
+ const Arg a = { .i = shifttag(arg->i) };
+ tag(&a);
+ view(&a);
+}
+
+int
main(int argc, char *argv[]) {
if(argc == 2 && !strcmp("-v", argv[1]))
die("dwm-"VERSION", © 2006-2012 dwm engineers, see LICENSE for details\n");