about summary refs log tree commit diff stats
path: root/client.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-11 16:14:22 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-11 16:14:22 +0200
commit33996500763b04119a6867dfa4040a4236c21a41 (patch)
tree7abc832f02c0478dd9b8e339c3ee7874d1bb7787 /client.c
parent272e15c4b7bdeeb258caadb7c62e70c49c12b16d (diff)
downloaddwm-33996500763b04119a6867dfa4040a4236c21a41.tar.gz
added protocol killing stuff
Diffstat (limited to 'client.c')
-rw-r--r--client.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/client.c b/client.c
index 8aca2e2..caa523c 100644
--- a/client.c
+++ b/client.c
@@ -10,8 +10,8 @@
 #include "util.h"
 #include "wm.h"
 
-static void
-update_client_name(Client *c)
+void
+update_name(Client *c)
 {
 	XTextProperty name;
 	int n;
@@ -38,6 +38,20 @@ update_client_name(Client *c)
 }
 
 void
+focus(Client *c)
+{
+	Client **l;
+	for(l=&stack; *l && *l != c; l=&(*l)->snext);
+	eassert(*l == c);
+	*l = c->snext;
+	c->snext = stack;
+	stack = c;
+	XRaiseWindow(dpy, c->win);
+	XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+	XFlush(dpy);
+}
+
+void
 manage(Window w, XWindowAttributes *wa)
 {
 	Client *c, **l;
@@ -59,7 +73,7 @@ manage(Window w, XWindowAttributes *wa)
 		(c->size.flags & PMinSize && c->size.flags & PMaxSize
 		 && c->size.min_width == c->size.max_width
 		 && c->size.min_height == c->size.max_height);
-	update_client_name(c);
+	update_name(c);
 	twa.override_redirect = 1;
 	twa.background_pixmap = ParentRelative;
 	twa.event_mask = ExposureMask;
@@ -73,9 +87,10 @@ manage(Window w, XWindowAttributes *wa)
 	for(l=&clients; *l; l=&(*l)->next);
 	c->next = *l; /* *l == nil */
 	*l = c;
-	XMapRaised(dpy, c->win);
-	XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
-	XFlush(dpy);
+	c->snext = stack;
+	stack = c;
+	XMapWindow(dpy, c->win);
+	focus(c);
 }
 
 static int
@@ -98,12 +113,15 @@ unmanage(Client *c)
 	for(l=&clients; *l && *l != c; l=&(*l)->next);
 	eassert(*l == c);
 	*l = c->next;
+	for(l=&stack; *l && *l != c; l=&(*l)->snext);
+	eassert(*l == c);
+	*l = c->snext;
 	free(c);
 
 	XFlush(dpy);
 	XSetErrorHandler(error_handler);
 	XUngrabServer(dpy);
-	/*flush_masked_events(EnterWindowMask); ? */
+	flush_events(EnterWindowMask);
 }
 
 
@@ -116,3 +134,4 @@ getclient(Window w)
 			return c;
 	return NULL;
 }
+