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 13:02:22 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-11 13:02:22 +0200
commit005362043d8b0bbf856f301c231d4f10c519b8c4 (patch)
tree3901197bc7ec4ad48613683c34516c2fa8c6542e /client.c
parent16c67f32d62849792c8e6d4fdec22a1896f9c279 (diff)
downloaddwm-005362043d8b0bbf856f301c231d4f10c519b8c4.tar.gz
changed how manage client works
Diffstat (limited to 'client.c')
-rw-r--r--client.c45
1 files changed, 33 insertions, 12 deletions
diff --git a/client.c b/client.c
index 62f4d98..8aca2e2 100644
--- a/client.c
+++ b/client.c
@@ -3,6 +3,7 @@
  * See LICENSE file for license details.
  */
 
+#include <stdlib.h>
 #include <string.h>
 #include <X11/Xatom.h>
 
@@ -36,10 +37,10 @@ update_client_name(Client *c)
 	XFree(name.value);
 }
 
-Client *
-create_client(Window w, XWindowAttributes *wa)
+void
+manage(Window w, XWindowAttributes *wa)
 {
-	Client *c;
+	Client *c, **l;
 	XSetWindowAttributes twa;
 	long msize;
 
@@ -68,24 +69,44 @@ create_client(Window w, XWindowAttributes *wa)
 			DefaultDepth(dpy, screen), CopyFromParent,
 			DefaultVisual(dpy, screen),
 			CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
+
+	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);
+}
 
-#if 0
-	for(t=&client, i=0; *t; t=&(*t)->next, i++);
-	c->next = *t; /* *t == nil */
-	*t = c;
-#endif
-	return c;
+static int
+dummy_error_handler(Display *dpy, XErrorEvent *error)
+{
+	return 0;
 }
 
 void
-manage(Client *c)
+unmanage(Client *c)
 {
-	XMapRaised(dpy, c->win);
-	XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+	Client **l;
+
+	XGrabServer(dpy);
+	XSetErrorHandler(dummy_error_handler);
+
+	XUnmapWindow(dpy, c->win);
+	XDestroyWindow(dpy, c->title);
+
+	for(l=&clients; *l && *l != c; l=&(*l)->next);
+	eassert(*l == c);
+	*l = c->next;
+	free(c);
+
 	XFlush(dpy);
+	XSetErrorHandler(error_handler);
+	XUngrabServer(dpy);
+	/*flush_masked_events(EnterWindowMask); ? */
 }
 
+
 Client *
 getclient(Window w)
 {
a id='n234' href='#n234'>234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311