summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2022-03-09 15:16:07 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2022-03-09 15:16:07 +0530
commita5f4a24c2bc1a7097d0871e4e14e63f24ca0912d (patch)
tree8c89046656bea289989ac004ff97fffb00d67d61
parent1fd97439fdba3b8f20b1b82a4ec680f416ab195b (diff)
Applied adjacenttag-skipvacant patch
-rw-r--r--config.h4
-rwxr-xr-xdwmbin80312 -> 80640 bytes
-rw-r--r--dwm.c93
-rw-r--r--dwm.obin75832 -> 77256 bytes
4 files changed, 97 insertions, 0 deletions
diff --git a/config.h b/config.h
index d980c89..19971e6 100644
--- a/config.h
+++ b/config.h
@@ -100,6 +100,10 @@ static Key keys[] = {
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
+ { MODKEY, XK_Right, viewnext, {0} },
+ { MODKEY, XK_Left, viewprev, {0} },
+ { MODKEY|ShiftMask, XK_Right, tagtonext, {0} },
+ { MODKEY|ShiftMask, XK_Left, tagtoprev, {0} },
{ MODKEY, XK_minus, setgaps, {.i = -1 } },
{ MODKEY, XK_equal, setgaps, {.i = +1 } },
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
diff --git a/dwm b/dwm
index af57c08..075a8d3 100755
--- a/dwm
+++ b/dwm
Binary files differ
diff --git a/dwm.c b/dwm.c
index 80639aa..20c2696 100644
--- a/dwm.c
+++ b/dwm.c
@@ -238,8 +238,10 @@ static void maprequest(XEvent *e);
static void monocle(Monitor *m);
static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg);
+static unsigned int nexttag(void);
static Client *nexttiled(Client *c);
static void pop(Client *);
+static unsigned int prevtag(void);
static void propertynotify(XEvent *e);
static void quit(const Arg *arg);
static Monitor *recttomon(int x, int y, int w, int h);
@@ -270,6 +272,8 @@ static void spawn(const Arg *arg);
static Monitor *systraytomon(Monitor *m);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
+static void tagtonext(const Arg *arg);
+static void tagtoprev(const Arg *arg);
static void tile(Monitor *);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
@@ -293,6 +297,8 @@ static void updatetitle(Client *c);
static void updatewindowtype(Client *c);
static void updatewmhints(Client *c);
static void view(const Arg *arg);
+static void viewnext(const Arg *arg);
+static void viewprev(const Arg *arg);
static Client *wintoclient(Window w);
static Monitor *wintomon(Window w);
static Client *wintosystrayicon(Window w);
@@ -1480,6 +1486,29 @@ movemouse(const Arg *arg)
}
}
+unsigned int
+nexttag(void)
+{
+ unsigned int seltag = selmon->tagset[selmon->seltags];
+ unsigned int usedtags = 0;
+ Client *c = selmon->clients;
+
+ if (!c)
+ return seltag;
+
+ /* skip vacant tags */
+ do {
+ usedtags |= c->tags;
+ c = c->next;
+ } while (c);
+
+ do {
+ seltag = seltag == (1 << (LENGTH(tags) - 1)) ? 1 : seltag << 1;
+ } while (!(seltag & usedtags));
+
+ return seltag;
+}
+
Client *
nexttiled(Client *c)
{
@@ -1496,6 +1525,28 @@ pop(Client *c)
arrange(c->mon);
}
+unsigned int
+prevtag(void)
+{
+ unsigned int seltag = selmon->tagset[selmon->seltags];
+ unsigned int usedtags = 0;
+ Client *c = selmon->clients;
+ if (!c)
+ return seltag;
+
+ /* skip vacant tags */
+ do {
+ usedtags |= c->tags;
+ c = c->next;
+ } while (c);
+
+ do {
+ seltag = seltag == 1 ? (1 << (LENGTH(tags) - 1)) : seltag >> 1;
+ } while (!(seltag & usedtags));
+
+ return seltag;
+}
+
void
propertynotify(XEvent *e)
{
@@ -2053,6 +2104,36 @@ tagmon(const Arg *arg)
}
void
+tagtonext(const Arg *arg)
+{
+ unsigned int tmp;
+
+ if (selmon->sel == NULL)
+ return;
+
+ if ((tmp = nexttag()) == selmon->tagset[selmon->seltags])
+ return;
+
+ tag(&(const Arg){.ui = tmp });
+ view(&(const Arg){.ui = tmp });
+}
+
+void
+tagtoprev(const Arg *arg)
+{
+ unsigned int tmp;
+
+ if (selmon->sel == NULL)
+ return;
+
+ if ((tmp = prevtag()) == selmon->tagset[selmon->seltags])
+ return;
+
+ tag(&(const Arg){.ui = tmp });
+ view(&(const Arg){.ui = tmp });
+}
+
+void
tile(Monitor *m)
{
unsigned int i, n, h, mw, my, ty;
@@ -2733,6 +2814,18 @@ swallowingclient(Window w)
return NULL;
}
+void
+viewnext(const Arg *arg)
+{
+ view(&(const Arg){.ui = nexttag()});
+}
+
+void
+viewprev(const Arg *arg)
+{
+ view(&(const Arg){.ui = prevtag()});
+}
+
Client *
wintoclient(Window w)
{
diff --git a/dwm.o b/dwm.o
index 56cb640..353bec8 100644
--- a/dwm.o
+++ b/dwm.o
Binary files differ