summaryrefslogtreecommitdiff
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/dwm.c b/dwm.c
index 7b5c633..f22f802 100644
--- a/dwm.c
+++ b/dwm.c
@@ -127,6 +127,7 @@ struct Monitor {
Client *clients;
Client *sel;
Client *stack;
+ Client *tagmarked[32];
Monitor *next;
Window barwin;
const Layout *lt[2];
@@ -169,6 +170,7 @@ static void enternotify(XEvent *e);
static void expose(XEvent *e);
static void focus(Client *c);
static void focusin(XEvent *e);
+static void focusmaster(const Arg *arg);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
static Atom getatomprop(Client *c, Atom prop);
@@ -670,6 +672,10 @@ detach(Client *c)
{
Client **tc;
+ for (int i = 1; i < LENGTH(tags); i++)
+ if (c == c->mon->tagmarked[i])
+ c->mon->tagmarked[i] = NULL;
+
for (tc = &c->mon->clients; *tc && *tc != c; tc = &(*tc)->next);
*tc = c->next;
}
@@ -852,6 +858,34 @@ focusin(XEvent *e)
}
void
+focusmaster(const Arg *arg)
+{
+ Client *master;
+
+ if (selmon->nmaster > 1)
+ return;
+ if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
+ return;
+
+ master = nexttiled(selmon->clients);
+
+ if (!master)
+ return;
+
+ int i;
+ for (i = 0; !(selmon->tagset[selmon->seltags] & 1 << i); i++);
+ i++;
+
+ if (selmon->sel == master) {
+ if (selmon->tagmarked[i] && ISVISIBLE(selmon->tagmarked[i]))
+ focus(selmon->tagmarked[i]);
+ } else {
+ selmon->tagmarked[i] = selmon->sel;
+ focus(master);
+ }
+}
+
+void
focusmon(const Arg *arg)
{
Monitor *m;
@@ -1240,6 +1274,11 @@ nexttiled(Client *c)
void
pop(Client *c)
{
+ int i;
+ for (i = 0; !(selmon->tagset[selmon->seltags] & 1 << i); i++);
+ i++;
+
+ c->mon->tagmarked[i] = nexttiled(c->mon->clients);
detach(c);
attach(c);
focus(c);