comparison client.c @ 10:703255003abb

changed how manage client works
author Anselm R. Garbe <garbeam@wmii.de>
date Tue, 11 Jul 2006 13:02:22 +0200
parents d567f430a81d
children 5cc5e55a132d
comparison
equal deleted inserted replaced
9:d567f430a81d 10:703255003abb
1 /* 1 /*
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details. 3 * See LICENSE file for license details.
4 */ 4 */
5 5
6 #include <stdlib.h>
6 #include <string.h> 7 #include <string.h>
7 #include <X11/Xatom.h> 8 #include <X11/Xatom.h>
8 9
9 #include "util.h" 10 #include "util.h"
10 #include "wm.h" 11 #include "wm.h"
34 } 35 }
35 } 36 }
36 XFree(name.value); 37 XFree(name.value);
37 } 38 }
38 39
39 Client * 40 void
40 create_client(Window w, XWindowAttributes *wa) 41 manage(Window w, XWindowAttributes *wa)
41 { 42 {
42 Client *c; 43 Client *c, **l;
43 XSetWindowAttributes twa; 44 XSetWindowAttributes twa;
44 long msize; 45 long msize;
45 46
46 c = emallocz(sizeof(Client)); 47 c = emallocz(sizeof(Client));
47 c->win = w; 48 c->win = w;
66 c->title = XCreateWindow(dpy, root, c->r[RFloat].x, c->r[RFloat].y, 67 c->title = XCreateWindow(dpy, root, c->r[RFloat].x, c->r[RFloat].y,
67 c->r[RFloat].width, barrect.height, 0, 68 c->r[RFloat].width, barrect.height, 0,
68 DefaultDepth(dpy, screen), CopyFromParent, 69 DefaultDepth(dpy, screen), CopyFromParent,
69 DefaultVisual(dpy, screen), 70 DefaultVisual(dpy, screen),
70 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); 71 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
71 XFlush(dpy);
72 72
73 #if 0 73 for(l=&clients; *l; l=&(*l)->next);
74 for(t=&client, i=0; *t; t=&(*t)->next, i++); 74 c->next = *l; /* *l == nil */
75 c->next = *t; /* *t == nil */ 75 *l = c;
76 *t = c;
77 #endif
78 return c;
79 }
80
81 void
82 manage(Client *c)
83 {
84 XMapRaised(dpy, c->win); 76 XMapRaised(dpy, c->win);
85 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); 77 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
86 XFlush(dpy); 78 XFlush(dpy);
87 } 79 }
80
81 static int
82 dummy_error_handler(Display *dpy, XErrorEvent *error)
83 {
84 return 0;
85 }
86
87 void
88 unmanage(Client *c)
89 {
90 Client **l;
91
92 XGrabServer(dpy);
93 XSetErrorHandler(dummy_error_handler);
94
95 XUnmapWindow(dpy, c->win);
96 XDestroyWindow(dpy, c->title);
97
98 for(l=&clients; *l && *l != c; l=&(*l)->next);
99 eassert(*l == c);
100 *l = c->next;
101 free(c);
102
103 XFlush(dpy);
104 XSetErrorHandler(error_handler);
105 XUngrabServer(dpy);
106 /*flush_masked_events(EnterWindowMask); ? */
107 }
108
88 109
89 Client * 110 Client *
90 getclient(Window w) 111 getclient(Window w)
91 { 112 {
92 Client *c; 113 Client *c;