about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--client.c17
-rw-r--r--dwm.h3
-rw-r--r--event.c4
-rw-r--r--layout.c41
4 files changed, 31 insertions, 34 deletions
diff --git a/client.c b/client.c
index f3d31cb..90399ae 100644
--- a/client.c
+++ b/client.c
@@ -129,8 +129,8 @@ detach(Client *c) {
 
 void
 focus(Client *c) {
-	if(c && !isvisible(c))
-		return;
+	if( !c && selscreen || c && !isvisible(c))
+		for(c = stack; c && !isvisible(c); c = c->snext);
 	if(sel && sel != c) {
 		grabbuttons(sel, False);
 		XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
@@ -153,14 +153,6 @@ focus(Client *c) {
 }
 
 void
-focustopvisible(void) {
-	Client *c;
-
-	for(c = stack; c && !isvisible(c); c = c->snext);
-	focus(c);
-}
-
-void
 killclient(const char *arg) {
 	XEvent ev;
 
@@ -230,8 +222,7 @@ manage(Window w, XWindowAttributes *wa) {
 	XMoveWindow(dpy, w, c->x + 2 * sw, c->y);
 	XMapWindow(dpy, w);
 	setclientstate(c, NormalState);
-	if(isvisible(c))
-		focus(c);
+	focus(c);
 	lt->arrange();
 }
 
@@ -401,7 +392,7 @@ unmanage(Client *c) {
 	detach(c);
 	detachstack(c);
 	if(sel == c)
-		focustopvisible();
+		focus(NULL);
 	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
 	setclientstate(c, WithdrawnState);
 	free(c->tags);
diff --git a/dwm.h b/dwm.h
index 769d1b1..2c1d41b 100644
--- a/dwm.h
+++ b/dwm.h
@@ -100,8 +100,7 @@ Window root, barwin;
 void attach(Client *c);			/* attaches c to global client list */
 void configure(Client *c);		/* send synthetic configure event */
 void detach(Client *c);			/* detaches c from global client list */
-void focus(Client *c);			/* focus c, c may be NULL */
-void focustopvisible(void);		/* focus top visible window on stack */
+void focus(Client *c);			/* focus c if visible && !NULL, or focus top visible */
 void killclient(const char *arg);	/* kill sel  nicely */
 void manage(Window w, XWindowAttributes *wa);	/* manage new client */
 void resize(Client *c, int x, int y,
diff --git a/event.c b/event.c
index 2773c6f..f9d2e0c 100644
--- a/event.c
+++ b/event.c
@@ -242,11 +242,11 @@ enternotify(XEvent *e) {
 
 	if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
 		return;
-	if((c = getclient(ev->window)) && isvisible(c))
+	if(c = getclient(ev->window))
 		focus(c);
 	else if(ev->window == root) {
 		selscreen = True;
-		focustopvisible();
+		focus(NULL);
 	}
 }
 
diff --git a/layout.c b/layout.c
index 4b4e908..de6aef6 100644
--- a/layout.c
+++ b/layout.c
@@ -14,6 +14,22 @@ static unsigned int masterw = MASTERWIDTH;
 static unsigned int nmaster = NMASTER;
 
 static void
+ban(Client *c) {
+	if (c->isbanned)
+		return;
+	XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
+	c->isbanned = True;
+}
+
+static void
+unban(Client *c) {
+	if (!c->isbanned)
+		return;
+	XMoveWindow(dpy, c->win, c->x, c->y);
+	c->isbanned = False;
+}
+
+static void
 tile(void) {
 	unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
 	Client *c;
@@ -28,9 +44,7 @@ tile(void) {
 
 	for(i = 0, c = clients; c; c = c->next)
 		if(isvisible(c)) {
-			if(c->isbanned)
-				XMoveWindow(dpy, c->win, c->x, c->y);
-			c->isbanned = False;
+			unban(c);
 			if(c->isfloating)
 				continue;
 			c->ismax = False;
@@ -60,12 +74,9 @@ tile(void) {
 			resize(c, nx, ny, nw, nh, False);
 			i++;
 		}
-		else {
-			c->isbanned = True;
-			XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
-		}
-	if(!sel || !isvisible(sel)) 
-		focustopvisible();
+		else
+			ban(c);
+	focus(NULL);
 	restack();
 }
 
@@ -77,20 +88,16 @@ void
 floating(void) {
 	Client *c;
 
-	for(c = clients; c; c = c->next) {
+	for(c = clients; c; c = c->next)
 		if(isvisible(c)) {
 			if(c->isbanned)
 				XMoveWindow(dpy, c->win, c->x, c->y);
 			c->isbanned = False;
 			resize(c, c->x, c->y, c->w, c->h, True);
 		}
-		else {
-			c->isbanned = True;
-			XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
-		}
-	}
-	if(!sel || !isvisible(sel))
-		focustopvisible();
+		else
+			ban(c);
+	focus(NULL);
 	restack();
 }
 
sktop> 2010-02-12 00:03:18 +0100 committer Andreas Rumpf <andreas@andreas-desktop> 2010-02-12 00:03:18 +0100 further progress on the new XML processing modules' href='/ahoang/Nim/commit/lib/pure/xmltreeparser.nim?h=devel&id=16c0beb27c372ce431b54bab9750bbaab254acfb'>16c0beb27 ^
f721ddd75 ^






f721ddd75 ^


16c0beb27 ^






40a5d6c3b ^
16c0beb27 ^
f721ddd75 ^



16c0beb27 ^
f721ddd75 ^

16c0beb27 ^
f721ddd75 ^



16c0beb27 ^
f721ddd75 ^






16c0beb27 ^

f721ddd75 ^
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138