2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
9 #include <X11/keysym.h>
14 static void configurerequest(XEvent *e);
15 static void destroynotify(XEvent *e);
16 static void enternotify(XEvent *e);
17 static void leavenotify(XEvent *e);
18 static void expose(XEvent *e);
19 static void keypress(XEvent *e);
20 static void keymapnotify(XEvent *e);
21 static void maprequest(XEvent *e);
22 static void propertynotify(XEvent *e);
23 static void unmapnotify(XEvent *e);
25 void (*handler[LASTEvent]) (XEvent *) = {
26 [ConfigureRequest] = configurerequest,
27 [DestroyNotify] = destroynotify,
28 [EnterNotify] = enternotify,
29 [LeaveNotify] = leavenotify,
31 [KeyPress] = keypress,
32 [KeymapNotify] = keymapnotify,
33 [MapRequest] = maprequest,
34 [PropertyNotify] = propertynotify,
35 [UnmapNotify] = unmapnotify
39 flush_masked_events(long even_mask)
43 while(XCheckMaskEvent(dpy, even_mask, &ev)) n++;
48 configurerequest(XEvent *e)
51 XConfigureRequestEvent *ev = &e->xconfigurerequest;
56 c = client_of_win(ev->window);
57 ev->value_mask &= ~CWSibling;
59 gravitate_client(c, True);
61 if(ev->value_mask & CWX)
63 if(ev->value_mask & CWY)
65 if(ev->value_mask & CWWidth)
66 c->rect.width = ev->width;
67 if(ev->value_mask & CWHeight)
68 c->rect.height = ev->height;
69 if(ev->value_mask & CWBorderWidth)
70 c->border = ev->border_width;
72 gravitate_client(c, False);
75 if(c->sel->area->floating)
78 frect=&c->sel->revert;
80 if(c->rect.width >= screen->rect.width && c->rect.height >= screen->rect.height) {
81 frect->y = wc.y = -height_of_bar();
82 frect->x = wc.x = -def.border;
85 frect->y = wc.y = c->rect.y - height_of_bar();
86 frect->x = wc.x = c->rect.x - def.border;
88 frect->width = wc.width = c->rect.width + 2 * def.border;
89 frect->height = wc.height = c->rect.height + def.border
93 wc.stack_mode = ev->detail;
94 if(c->sel->area->view != screen->sel)
95 wc.x += 2 * screen->rect.width;
96 if(c->sel->area->floating) {
97 XConfigureWindow(dpy, c->framewin, ev->value_mask, &wc);
105 wc.width = ev->width;
106 wc.height = ev->height;
110 wc.y = height_of_bar();
111 wc.width = c->sel->rect.width - 2 * def.border;
112 wc.height = c->sel->rect.height - def.border - height_of_bar();
117 wc.stack_mode = Above;
118 ev->value_mask &= ~CWStackMode;
119 ev->value_mask |= CWBorderWidth;
120 XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
127 destroynotify(XEvent *e)
131 XDestroyWindowEvent *ev = &e->xdestroywindow;
133 if((c = client_of_win(ev->window)))
139 enternotify(XEvent *e)
142 XCrossingEvent *ev = &e->xcrossing;
145 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
148 if((c = client_of_win(ev->window))) {
151 if(a->mode == Colmax)
155 else if(ev->window == root) {
163 leavenotify(XEvent *e)
165 XCrossingEvent *ev = &e->xcrossing;
167 if((ev->window == root) && !ev->same_screen) {
176 XExposeEvent *ev = &e->xexpose;
179 if(ev->window == barwin)
188 XKeyEvent *ev = &e->xkey;
195 ev->state &= valid_mask;
196 if((f = frame_of_win(ev->window))) {
198 n = XLookupString(ev, buf, sizeof(buf), &k, 0);
199 if(IsFunctionKey(k) || IsKeypadKey(k) || IsMiscFunctionKey(k)
200 || IsPFKey(k) || IsPrivateKeypadKey(k))
203 blitz_kpress_input(&f->tagbar, ev->state, k, buf);
206 key(root, ev->state, (KeyCode) ev->keycode);
211 keymapnotify(XEvent *e)
219 maprequest(XEvent *e)
221 XMapRequestEvent *ev = &e->xmaprequest;
222 static XWindowAttributes wa;
224 if(!XGetWindowAttributes(dpy, ev->window, &wa))
227 if(wa.override_redirect) {
228 XSelectInput(dpy, ev->window,
229 (StructureNotifyMask | PropertyChangeMask));
233 /*if(!client_of_win(ev->window))*/
234 manage(create_client(ev->window, &wa));
238 propertynotify(XEvent *e)
241 XPropertyEvent *ev = &e->xproperty;
244 if(ev->state == PropertyDelete)
247 if((c = client_of_win(ev->window)))
253 unmapnotify(XEvent *e)
257 XUnmapEvent *ev = &e->xunmap;
259 if((c = client_of_win(ev->window)))