about summary refs log tree commit diff stats
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
parent16c67f32d62849792c8e6d4fdec22a1896f9c279 (diff)
downloaddwm-005362043d8b0bbf856f301c231d4f10c519b8c4.tar.gz
changed how manage client works
-rw-r--r--client.c45
-rw-r--r--event.c14
-rw-r--r--wm.c9
-rw-r--r--wm.h5
4 files changed, 44 insertions, 29 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)
 {
diff --git a/event.c b/event.c
index 909012d..870ed4a 100644
--- a/event.c
+++ b/event.c
@@ -159,12 +159,8 @@ maprequest(XEvent *e)
 		return;
 	}
 
-	/*if(!client_of_win(ev->window))*/
-		/*manage(create_client(ev->window, &wa));*/
-	XMapRaised(dpy, ev->window);
-	XMoveResizeWindow(dpy, ev->window, rect.x, rect.y, rect.width, rect.height - barrect.height);
-	XSetInputFocus(dpy, ev->window, RevertToPointerRoot, CurrentTime);
-	XFlush(dpy);
+	if(!getclient(ev->window))
+		manage(ev->window, &wa);
 }
 
 static void
@@ -185,11 +181,9 @@ propertynotify(XEvent *e)
 static void
 unmapnotify(XEvent *e)
 {
-#if 0
 	Client *c;
 	XUnmapEvent *ev = &e->xunmap;
 
-	if((c = client_of_win(ev->window)))
-		destroy_client(c);
-#endif
+	if((c = getclient(ev->window)))
+		unmanage(c);
 }
diff --git a/wm.c b/wm.c
index 8c5814f..ef4721d 100644
--- a/wm.c
+++ b/wm.c
@@ -20,19 +20,18 @@ Atom net_atom[NetLast];
 Cursor cursor[CurLast];
 XRectangle rect, barrect;
 Bool running = True;
-Client *clients = NULL;
 
 char *bartext, tag[256];
 int screen, sel_screen;
 
-/* draw structs */
 Brush brush = {0};
+Client *clients = NULL;
 
 enum { WM_PROTOCOL_DELWIN = 1 };
 
 static Bool other_wm_running;
-static int (*x_error_handler) (Display *, XErrorEvent *);
 static char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
+static int (*x_error_handler) (Display *, XErrorEvent *);
 
 static void
 usage()
@@ -56,7 +55,7 @@ scan_wins()
 			if(wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
 				continue;
 			if(wa.map_state == IsViewable)
-				manage(create_client(wins[i], &wa));
+				manage(wins[i], &wa);
 		}
 	}
 	if(wins)
@@ -69,7 +68,7 @@ scan_wins()
  * Other types of errors call Xlib's default error handler, which
  * calls exit().
  */
-static int
+int
 error_handler(Display *dpy, XErrorEvent *error)
 {
 	if(error->error_code == BadWindow
diff --git a/wm.h b/wm.h
index 9ea74fe..68c30da 100644
--- a/wm.h
+++ b/wm.h
@@ -65,8 +65,8 @@ extern void run(char *arg);
 extern void quit(char *arg);
 
 /* client.c */
-extern Client *create_client(Window w, XWindowAttributes *wa);
-extern void manage(Client *c);
+extern void manage(Window w, XWindowAttributes *wa);
+void unmanage(Client *c);
 extern Client * getclient(Window w);
 
 /* key.c */
@@ -74,3 +74,4 @@ extern void update_keys();
 extern void keypress(XEvent *e);
 
 /* wm.c */
+extern int error_handler(Display *dpy, XErrorEvent *error);
it.com> 2013-03-09 19:51:08 +0100 committer hut <hut@lavabit.com> 2013-03-09 19:51:58 +0100 setup.py: added _findall function' href='/akspecs/ranger/commit/setup.py?id=3cd8a402504b75c1ab63223ae0c583d2f803f11a'>3cd8a402 ^
c0f2fc72 ^
3cd8a402 ^
76791a70 ^





d1a1173d ^






d1a1173d ^
e6b847b3 ^
225aa78f ^
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