Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
58 lines (55 sloc) 1.27 KB
diff --git a/dwm.c b/dwm.c
index 4cd20ea..d5d5d29 100644
--- a/dwm.c
+++ b/dwm.c
@@ -262,6 +262,9 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
static void bstack(Monitor *m);
+static void cycle(const Arg *arg);
+static int shifttag(int dist);
+static void tagcycle(const Arg *arg);
/* variables */
static const char broken[] = "broken";
@@ -2212,6 +2215,42 @@ bstack(Monitor *m) {
}
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-2011 dwm engineers, see LICENSE for details\n");