Xinqi Bao's Git
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((c
= getclient(ev
->window
))) {
72 configurerequest(XEvent
*e
)
74 XConfigureRequestEvent
*ev
= &e
->xconfigurerequest
;
78 ev
->value_mask
&= ~CWSibling
;
79 if((c
= getclient(ev
->window
))) {
80 if(ev
->value_mask
& CWX
)
82 if(ev
->value_mask
& CWY
)
84 if(ev
->value_mask
& CWWidth
)
86 if(ev
->value_mask
& CWHeight
)
93 wc
.height
= ev
->height
;
96 wc
.stack_mode
= Above
;
97 ev
->value_mask
&= ~CWStackMode
;
98 ev
->value_mask
|= CWBorderWidth
;
99 XConfigureWindow(dpy
, ev
->window
, ev
->value_mask
, &wc
);
104 destroynotify(XEvent
*e
)
107 XDestroyWindowEvent
*ev
= &e
->xdestroywindow
;
109 if((c
= getclient(ev
->window
)))
114 enternotify(XEvent
*e
)
116 XCrossingEvent
*ev
= &e
->xcrossing
;
119 if(ev
->mode
!= NotifyNormal
|| ev
->detail
== NotifyInferior
)
122 if((c
= getclient(ev
->window
)))
124 else if(ev
->window
== root
)
129 leavenotify(XEvent
*e
)
131 XCrossingEvent
*ev
= &e
->xcrossing
;
133 if((ev
->window
== root
) && !ev
->same_screen
)
140 XExposeEvent
*ev
= &e
->xexpose
;
144 if((c
= gettitle(ev
->window
)))
146 else if(ev
->window
== barwin
)
152 keymapnotify(XEvent
*e
)
158 maprequest(XEvent
*e
)
160 XMapRequestEvent
*ev
= &e
->xmaprequest
;
161 static XWindowAttributes wa
;
163 if(!XGetWindowAttributes(dpy
, ev
->window
, &wa
))
166 if(wa
.override_redirect
) {
167 XSelectInput(dpy
, ev
->window
,
168 (StructureNotifyMask
| PropertyChangeMask
));
172 if(!getclient(ev
->window
))
173 manage(ev
->window
, &wa
);
177 propertynotify(XEvent
*e
)
179 XPropertyEvent
*ev
= &e
->xproperty
;
182 if(ev
->state
== PropertyDelete
)
185 if(ev
->atom
== wm_atom
[WMProtocols
]) {
186 c
->proto
= win_proto(c
->win
);
189 if((c
= getclient(ev
->window
))) {
192 case XA_WM_TRANSIENT_FOR
:
193 XGetTransientForHint(dpy
, c
->win
, &c
->trans
);
196 case XA_WM_NORMAL_HINTS
:
200 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
)))