comparison client.c @ 13:5cc5e55a132d

added protocol killing stuff
author Anselm R. Garbe <garbeam@wmii.de>
date Tue, 11 Jul 2006 16:14:22 +0200
parents 703255003abb
children 5c078b66347b
comparison
equal deleted inserted replaced
12:a2b399582afe 13:5cc5e55a132d
8 #include <X11/Xatom.h> 8 #include <X11/Xatom.h>
9 9
10 #include "util.h" 10 #include "util.h"
11 #include "wm.h" 11 #include "wm.h"
12 12
13 static void 13 void
14 update_client_name(Client *c) 14 update_name(Client *c)
15 { 15 {
16 XTextProperty name; 16 XTextProperty name;
17 int n; 17 int n;
18 char **list = NULL; 18 char **list = NULL;
19 19
36 } 36 }
37 XFree(name.value); 37 XFree(name.value);
38 } 38 }
39 39
40 void 40 void
41 focus(Client *c)
42 {
43 Client **l;
44 for(l=&stack; *l && *l != c; l=&(*l)->snext);
45 eassert(*l == c);
46 *l = c->snext;
47 c->snext = stack;
48 stack = c;
49 XRaiseWindow(dpy, c->win);
50 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
51 XFlush(dpy);
52 }
53
54 void
41 manage(Window w, XWindowAttributes *wa) 55 manage(Window w, XWindowAttributes *wa)
42 { 56 {
43 Client *c, **l; 57 Client *c, **l;
44 XSetWindowAttributes twa; 58 XSetWindowAttributes twa;
45 long msize; 59 long msize;
57 c->size.flags = PSize; 71 c->size.flags = PSize;
58 c->fixedsize = 72 c->fixedsize =
59 (c->size.flags & PMinSize && c->size.flags & PMaxSize 73 (c->size.flags & PMinSize && c->size.flags & PMaxSize
60 && c->size.min_width == c->size.max_width 74 && c->size.min_width == c->size.max_width
61 && c->size.min_height == c->size.max_height); 75 && c->size.min_height == c->size.max_height);
62 update_client_name(c); 76 update_name(c);
63 twa.override_redirect = 1; 77 twa.override_redirect = 1;
64 twa.background_pixmap = ParentRelative; 78 twa.background_pixmap = ParentRelative;
65 twa.event_mask = ExposureMask; 79 twa.event_mask = ExposureMask;
66 80
67 c->title = XCreateWindow(dpy, root, c->r[RFloat].x, c->r[RFloat].y, 81 c->title = XCreateWindow(dpy, root, c->r[RFloat].x, c->r[RFloat].y,
71 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); 85 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
72 86
73 for(l=&clients; *l; l=&(*l)->next); 87 for(l=&clients; *l; l=&(*l)->next);
74 c->next = *l; /* *l == nil */ 88 c->next = *l; /* *l == nil */
75 *l = c; 89 *l = c;
76 XMapRaised(dpy, c->win); 90 c->snext = stack;
77 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); 91 stack = c;
78 XFlush(dpy); 92 XMapWindow(dpy, c->win);
93 focus(c);
79 } 94 }
80 95
81 static int 96 static int
82 dummy_error_handler(Display *dpy, XErrorEvent *error) 97 dummy_error_handler(Display *dpy, XErrorEvent *error)
83 { 98 {
96 XDestroyWindow(dpy, c->title); 111 XDestroyWindow(dpy, c->title);
97 112
98 for(l=&clients; *l && *l != c; l=&(*l)->next); 113 for(l=&clients; *l && *l != c; l=&(*l)->next);
99 eassert(*l == c); 114 eassert(*l == c);
100 *l = c->next; 115 *l = c->next;
116 for(l=&stack; *l && *l != c; l=&(*l)->snext);
117 eassert(*l == c);
118 *l = c->snext;
101 free(c); 119 free(c);
102 120
103 XFlush(dpy); 121 XFlush(dpy);
104 XSetErrorHandler(error_handler); 122 XSetErrorHandler(error_handler);
105 XUngrabServer(dpy); 123 XUngrabServer(dpy);
106 /*flush_masked_events(EnterWindowMask); ? */ 124 flush_events(EnterWindowMask);
107 } 125 }
108 126
109 127
110 Client * 128 Client *
111 getclient(Window w) 129 getclient(Window w)
114 for(c = clients; c; c = c->next) 132 for(c = clients; c; c = c->next)
115 if(c->win == w) 133 if(c->win == w)
116 return c; 134 return c;
117 return NULL; 135 return NULL;
118 } 136 }
137