2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
10 #include <X11/keysym.h>
11 #include <X11/Xatom.h>
16 static void buttonpress(XEvent *e);
17 static void configurerequest(XEvent *e);
18 static void destroynotify(XEvent *e);
19 static void enternotify(XEvent *e);
20 static void leavenotify(XEvent *e);
21 static void expose(XEvent *e);
22 static void keymapnotify(XEvent *e);
23 static void maprequest(XEvent *e);
24 static void propertynotify(XEvent *e);
25 static void unmapnotify(XEvent *e);
27 void (*handler[LASTEvent]) (XEvent *) = {
28 [ButtonPress] = buttonpress,
29 [ConfigureRequest] = configurerequest,
30 [DestroyNotify] = destroynotify,
31 [EnterNotify] = enternotify,
32 [LeaveNotify] = leavenotify,
34 [KeyPress] = keypress,
35 [KeymapNotify] = keymapnotify,
36 [MapRequest] = maprequest,
37 [PropertyNotify] = propertynotify,
38 [UnmapNotify] = unmapnotify
42 buttonpress(XEvent *e)
44 XButtonPressedEvent *ev = &e->xbutton;
47 if(barwin == ev->window)
49 else if((c = getclient(ev->window))) {
68 configurerequest(XEvent *e)
70 XConfigureRequestEvent *ev = &e->xconfigurerequest;
74 ev->value_mask &= ~CWSibling;
75 if((c = getclient(ev->window))) {
77 if(ev->value_mask & CWX)
79 if(ev->value_mask & CWY)
81 if(ev->value_mask & CWWidth)
83 if(ev->value_mask & CWHeight)
85 if(ev->value_mask & CWBorderWidth)
94 wc.height = ev->height;
97 wc.stack_mode = Above;
98 ev->value_mask &= ~CWStackMode;
99 ev->value_mask |= CWBorderWidth;
100 XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
105 destroynotify(XEvent *e)
108 XDestroyWindowEvent *ev = &e->xdestroywindow;
110 if((c = getclient(ev->window)))
115 enternotify(XEvent *e)
117 XCrossingEvent *ev = &e->xcrossing;
120 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
123 if((c = getclient(ev->window)))
125 else if(ev->window == root)
130 leavenotify(XEvent *e)
132 XCrossingEvent *ev = &e->xcrossing;
134 if((ev->window == root) && !ev->same_screen)
141 XExposeEvent *ev = &e->xexpose;
145 if(barwin == ev->window)
147 else if((c = gettitle(ev->window)))
153 keymapnotify(XEvent *e)
159 maprequest(XEvent *e)
161 XMapRequestEvent *ev = &e->xmaprequest;
162 static XWindowAttributes wa;
164 if(!XGetWindowAttributes(dpy, ev->window, &wa))
167 if(wa.override_redirect) {
168 XSelectInput(dpy, ev->window,
169 (StructureNotifyMask | PropertyChangeMask));
173 if(!getclient(ev->window))
174 manage(ev->window, &wa);
178 propertynotify(XEvent *e)
180 XPropertyEvent *ev = &e->xproperty;
184 if(ev->state == PropertyDelete)
187 if((c = getclient(ev->window))) {
188 if(ev->atom == wm_atom[WMProtocols]) {
189 c->proto = win_proto(c->win);
194 case XA_WM_TRANSIENT_FOR:
195 XGetTransientForHint(dpy, c->win, &trans);
196 if(!c->floating && (c->floating = (trans != 0)))
199 case XA_WM_NORMAL_HINTS:
203 if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) {
211 unmapnotify(XEvent *e)
214 XUnmapEvent *ev = &e->xunmap;
216 if((c = getclient(ev->window)))