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>
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 keymapnotify(XEvent
*e
);
20 static void maprequest(XEvent
*e
);
21 static void propertynotify(XEvent
*e
);
22 static void unmapnotify(XEvent
*e
);
24 void (*handler
[LASTEvent
]) (XEvent
*) = {
25 [ConfigureRequest
] = configurerequest
,
26 [DestroyNotify
] = destroynotify
,
27 [EnterNotify
] = enternotify
,
28 [LeaveNotify
] = leavenotify
,
30 [KeyPress
] = keypress
,
31 [KeymapNotify
] = keymapnotify
,
32 [MapRequest
] = maprequest
,
33 [PropertyNotify
] = propertynotify
,
34 [UnmapNotify
] = unmapnotify
38 flush_masked_events(long even_mask
)
42 while(XCheckMaskEvent(dpy
, even_mask
, &ev
)) n
++;
47 configurerequest(XEvent
*e
)
49 XConfigureRequestEvent
*ev
= &e
->xconfigurerequest
;
53 c
= getclient(ev
->window
);
54 ev
->value_mask
&= ~CWSibling
;
56 if(ev
->value_mask
& CWX
)
57 c
->r
[RFloat
].x
= ev
->x
;
58 if(ev
->value_mask
& CWY
)
59 c
->r
[RFloat
].y
= ev
->y
;
60 if(ev
->value_mask
& CWWidth
)
61 c
->r
[RFloat
].width
= ev
->width
;
62 if(ev
->value_mask
& CWHeight
)
63 c
->r
[RFloat
].height
= ev
->height
;
64 if(ev
->value_mask
& CWBorderWidth
)
65 c
->border
= ev
->border_width
;
71 wc
.height
= ev
->height
;
74 wc
.stack_mode
= Above
;
75 ev
->value_mask
&= ~CWStackMode
;
76 ev
->value_mask
|= CWBorderWidth
;
77 XConfigureWindow(dpy
, ev
->window
, ev
->value_mask
, &wc
);
82 destroynotify(XEvent
*e
)
86 XDestroyWindowEvent
*ev
= &e
->xdestroywindow
;
88 if((c
= client_of_win(ev
->window
)))
94 enternotify(XEvent
*e
)
97 XCrossingEvent
*ev
= &e
->xcrossing
;
100 if(ev
->mode
!= NotifyNormal
|| ev
->detail
== NotifyInferior
)
103 if((c
= client_of_win(ev
->window
))) {
106 if(a
->mode
== Colmax
)
110 else if(ev
->window
== root
) {
118 leavenotify(XEvent
*e
)
120 XCrossingEvent
*ev
= &e
->xcrossing
;
122 if((ev
->window
== root
) && !ev
->same_screen
) {
131 XExposeEvent
*ev
= &e
->xexpose
;
134 if(ev
->window
== barwin
)
140 keymapnotify(XEvent
*e
)
148 maprequest(XEvent
*e
)
150 XMapRequestEvent
*ev
= &e
->xmaprequest
;
151 static XWindowAttributes wa
;
153 if(!XGetWindowAttributes(dpy
, ev
->window
, &wa
))
156 if(wa
.override_redirect
) {
157 XSelectInput(dpy
, ev
->window
,
158 (StructureNotifyMask
| PropertyChangeMask
));
162 /*if(!client_of_win(ev->window))*/
163 /*manage(create_client(ev->window, &wa));*/
164 XMapRaised(dpy
, ev
->window
);
165 XMoveResizeWindow(dpy
, ev
->window
, rect
.x
, rect
.y
, rect
.width
, rect
.height
- barrect
.height
);
166 XSetInputFocus(dpy
, ev
->window
, RevertToPointerRoot
, CurrentTime
);
171 propertynotify(XEvent
*e
)
174 XPropertyEvent
*ev
= &e
->xproperty
;
177 if(ev
->state
== PropertyDelete
)
180 if((c
= client_of_win(ev
->window
)))
186 unmapnotify(XEvent
*e
)
190 XUnmapEvent
*ev
= &e
->xunmap
;
192 if((c
= client_of_win(ev
->window
)))