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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
diff --git c/config.def.h w/config.def.h
index 176294a..19600a6 100644
--- c/config.def.h
+++ w/config.def.h
@@ -79,7 +79,8 @@ static const Key keys[] = {
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
- { MODKEY, XK_Return, zoom, {0} },
+ { MODKEY, XK_Return, focusmaster, {0} },
+ { MODKEY|ShiftMask, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, /* tatami */
diff --git c/dwm.c w/dwm.c
index 55925bd..c68b29a 100644
--- c/dwm.c
+++ w/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];
@@ -167,6 +168,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);
@@ -667,6 +669,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;
}
@@ -826,6 +832,34 @@ focusin(XEvent *e)
setfocus(selmon->sel);
}
+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)
{
@@ -1217,6 +1251,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);
|