2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
9 #include <X11/keysym.h>
10 #include <X11/Xatom.h>
15 static void buttonpress(XEvent *e);
16 static void configurerequest(XEvent *e);
17 static void destroynotify(XEvent *e);
18 static void enternotify(XEvent *e);
19 static void leavenotify(XEvent *e);
20 static void expose(XEvent *e);
21 static void keymapnotify(XEvent *e);
22 static void maprequest(XEvent *e);
23 static void propertynotify(XEvent *e);
24 static void unmapnotify(XEvent *e);
26 void (*handler[LASTEvent]) (XEvent *) = {
27 [ButtonPress] = buttonpress,
28 [ConfigureRequest] = configurerequest,
29 [DestroyNotify] = destroynotify,
30 [EnterNotify] = enternotify,
31 [LeaveNotify] = leavenotify,
33 [KeyPress] = keypress,
34 [KeymapNotify] = keymapnotify,
35 [MapRequest] = maprequest,
36 [PropertyNotify] = propertynotify,
37 [UnmapNotify] = unmapnotify
41 discard_events(long even_mask)
44 while(XCheckMaskEvent(dpy, even_mask, &ev));
48 buttonpress(XEvent *e)
50 XButtonPressedEvent *ev = &e->xbutton;
53 if(barwin == ev->window)
55 else if((c = getclient(ev->window))) {
74 configurerequest(XEvent *e)
76 XConfigureRequestEvent *ev = &e->xconfigurerequest;
80 ev->value_mask &= ~CWSibling;
81 if((c = getclient(ev->window))) {
83 if(ev->value_mask & CWX)
85 if(ev->value_mask & CWY)
87 if(ev->value_mask & CWWidth)
89 if(ev->value_mask & CWHeight)
91 if(ev->value_mask & CWBorderWidth)
100 wc.height = ev->height;
103 wc.stack_mode = Above;
104 ev->value_mask &= ~CWStackMode;
105 ev->value_mask |= CWBorderWidth;
106 XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
111 destroynotify(XEvent *e)
114 XDestroyWindowEvent *ev = &e->xdestroywindow;
116 if((c = getclient(ev->window)))
121 enternotify(XEvent *e)
123 XCrossingEvent *ev = &e->xcrossing;
126 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
129 if((c = getclient(ev->window)))
131 else if(ev->window == root)
136 leavenotify(XEvent *e)
138 XCrossingEvent *ev = &e->xcrossing;
140 if((ev->window == root) && !ev->same_screen)
147 XExposeEvent *ev = &e->xexpose;
151 if((c = gettitle(ev->window)))
157 keymapnotify(XEvent *e)
163 maprequest(XEvent *e)
165 XMapRequestEvent *ev = &e->xmaprequest;
166 static XWindowAttributes wa;
168 if(!XGetWindowAttributes(dpy, ev->window, &wa))
171 if(wa.override_redirect) {
172 XSelectInput(dpy, ev->window,
173 (StructureNotifyMask | PropertyChangeMask));
177 if(!getclient(ev->window))
178 manage(ev->window, &wa);
182 propertynotify(XEvent *e)
184 XPropertyEvent *ev = &e->xproperty;
188 if(ev->state == PropertyDelete)
191 if((c = getclient(ev->window))) {
192 if(ev->atom == wm_atom[WMProtocols]) {
193 c->proto = win_proto(c->win);
198 case XA_WM_TRANSIENT_FOR:
199 XGetTransientForHint(dpy, c->win, &trans);
200 if(!c->floating && (c->floating = (trans != 0)))
203 case XA_WM_NORMAL_HINTS:
207 if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) {
215 unmapnotify(XEvent *e)
218 XUnmapEvent *ev = &e->xunmap;
220 if((c = getclient(ev->window)))