rev |
line source |
garbeam@5
|
1 /*
|
garbeam@5
|
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
garbeam@5
|
3 * See LICENSE file for license details.
|
garbeam@5
|
4 */
|
garbeam@5
|
5
|
garbeam@5
|
6 #include <fcntl.h>
|
garbeam@5
|
7 #include <stdlib.h>
|
garbeam@5
|
8 #include <string.h>
|
garbeam@5
|
9 #include <X11/keysym.h>
|
garbeam@5
|
10
|
garbeam@5
|
11 #include "wm.h"
|
garbeam@5
|
12
|
garbeam@5
|
13 /* local functions */
|
garbeam@5
|
14 static void configurerequest(XEvent *e);
|
garbeam@5
|
15 static void destroynotify(XEvent *e);
|
garbeam@5
|
16 static void enternotify(XEvent *e);
|
garbeam@5
|
17 static void leavenotify(XEvent *e);
|
garbeam@5
|
18 static void expose(XEvent *e);
|
garbeam@5
|
19 static void keymapnotify(XEvent *e);
|
garbeam@5
|
20 static void maprequest(XEvent *e);
|
garbeam@5
|
21 static void propertynotify(XEvent *e);
|
garbeam@5
|
22 static void unmapnotify(XEvent *e);
|
garbeam@5
|
23
|
garbeam@5
|
24 void (*handler[LASTEvent]) (XEvent *) = {
|
garbeam@5
|
25 [ConfigureRequest] = configurerequest,
|
garbeam@5
|
26 [DestroyNotify] = destroynotify,
|
garbeam@5
|
27 [EnterNotify] = enternotify,
|
garbeam@5
|
28 [LeaveNotify] = leavenotify,
|
garbeam@5
|
29 [Expose] = expose,
|
garbeam@5
|
30 [KeyPress] = keypress,
|
garbeam@5
|
31 [KeymapNotify] = keymapnotify,
|
garbeam@5
|
32 [MapRequest] = maprequest,
|
garbeam@5
|
33 [PropertyNotify] = propertynotify,
|
garbeam@5
|
34 [UnmapNotify] = unmapnotify
|
garbeam@5
|
35 };
|
garbeam@5
|
36
|
garbeam@5
|
37 unsigned int
|
garbeam@5
|
38 flush_masked_events(long even_mask)
|
garbeam@5
|
39 {
|
garbeam@5
|
40 XEvent ev;
|
garbeam@5
|
41 unsigned int n = 0;
|
garbeam@5
|
42 while(XCheckMaskEvent(dpy, even_mask, &ev)) n++;
|
garbeam@5
|
43 return n;
|
garbeam@5
|
44 }
|
garbeam@5
|
45
|
garbeam@5
|
46 static void
|
garbeam@5
|
47 configurerequest(XEvent *e)
|
garbeam@5
|
48 {
|
garbeam@5
|
49 XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
garbeam@5
|
50 XWindowChanges wc;
|
garbeam@5
|
51 Client *c;
|
garbeam@5
|
52
|
garbeam@9
|
53 c = getclient(ev->window);
|
garbeam@5
|
54 ev->value_mask &= ~CWSibling;
|
garbeam@5
|
55 if(c) {
|
garbeam@5
|
56 if(ev->value_mask & CWX)
|
garbeam@9
|
57 c->r[RFloat].x = ev->x;
|
garbeam@5
|
58 if(ev->value_mask & CWY)
|
garbeam@9
|
59 c->r[RFloat].y = ev->y;
|
garbeam@5
|
60 if(ev->value_mask & CWWidth)
|
garbeam@9
|
61 c->r[RFloat].width = ev->width;
|
garbeam@5
|
62 if(ev->value_mask & CWHeight)
|
garbeam@9
|
63 c->r[RFloat].height = ev->height;
|
garbeam@5
|
64 if(ev->value_mask & CWBorderWidth)
|
garbeam@5
|
65 c->border = ev->border_width;
|
garbeam@5
|
66 }
|
garbeam@5
|
67
|
garbeam@5
|
68 wc.x = ev->x;
|
garbeam@5
|
69 wc.y = ev->y;
|
garbeam@5
|
70 wc.width = ev->width;
|
garbeam@5
|
71 wc.height = ev->height;
|
garbeam@5
|
72 wc.border_width = 0;
|
garbeam@5
|
73 wc.sibling = None;
|
garbeam@5
|
74 wc.stack_mode = Above;
|
garbeam@5
|
75 ev->value_mask &= ~CWStackMode;
|
garbeam@5
|
76 ev->value_mask |= CWBorderWidth;
|
garbeam@5
|
77 XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
|
garbeam@5
|
78 XFlush(dpy);
|
garbeam@5
|
79 }
|
garbeam@5
|
80
|
garbeam@5
|
81 static void
|
garbeam@5
|
82 destroynotify(XEvent *e)
|
garbeam@5
|
83 {
|
garbeam@5
|
84 #if 0
|
garbeam@5
|
85 Client *c;
|
garbeam@5
|
86 XDestroyWindowEvent *ev = &e->xdestroywindow;
|
garbeam@5
|
87
|
garbeam@5
|
88 if((c = client_of_win(ev->window)))
|
garbeam@5
|
89 destroy_client(c);
|
garbeam@5
|
90 #endif
|
garbeam@5
|
91 }
|
garbeam@5
|
92
|
garbeam@5
|
93 static void
|
garbeam@5
|
94 enternotify(XEvent *e)
|
garbeam@5
|
95 {
|
garbeam@5
|
96 #if 0
|
garbeam@5
|
97 XCrossingEvent *ev = &e->xcrossing;
|
garbeam@5
|
98 Client *c;
|
garbeam@5
|
99
|
garbeam@5
|
100 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
|
garbeam@5
|
101 return;
|
garbeam@5
|
102
|
garbeam@5
|
103 if((c = client_of_win(ev->window))) {
|
garbeam@5
|
104 Frame *f = c->sel;
|
garbeam@5
|
105 Area *a = f->area;
|
garbeam@5
|
106 if(a->mode == Colmax)
|
garbeam@5
|
107 c = a->sel->client;
|
garbeam@5
|
108 focus(c, False);
|
garbeam@5
|
109 }
|
garbeam@5
|
110 else if(ev->window == root) {
|
garbeam@5
|
111 sel_screen = True;
|
garbeam@5
|
112 draw_frames();
|
garbeam@5
|
113 }
|
garbeam@5
|
114 #endif
|
garbeam@5
|
115 }
|
garbeam@5
|
116
|
garbeam@5
|
117 static void
|
garbeam@5
|
118 leavenotify(XEvent *e)
|
garbeam@5
|
119 {
|
garbeam@5
|
120 XCrossingEvent *ev = &e->xcrossing;
|
garbeam@5
|
121
|
garbeam@5
|
122 if((ev->window == root) && !ev->same_screen) {
|
garbeam@5
|
123 sel_screen = True;
|
garbeam@5
|
124 /*draw_frames();*/
|
garbeam@5
|
125 }
|
garbeam@5
|
126 }
|
garbeam@5
|
127
|
garbeam@5
|
128 static void
|
garbeam@5
|
129 expose(XEvent *e)
|
garbeam@5
|
130 {
|
garbeam@5
|
131 XExposeEvent *ev = &e->xexpose;
|
garbeam@5
|
132
|
garbeam@5
|
133 if(ev->count == 0) {
|
garbeam@5
|
134 if(ev->window == barwin)
|
garbeam@5
|
135 draw_bar();
|
garbeam@5
|
136 }
|
garbeam@5
|
137 }
|
garbeam@5
|
138
|
garbeam@5
|
139 static void
|
garbeam@5
|
140 keymapnotify(XEvent *e)
|
garbeam@5
|
141 {
|
garbeam@5
|
142 #if 0
|
garbeam@5
|
143 update_keys();
|
garbeam@5
|
144 #endif
|
garbeam@5
|
145 }
|
garbeam@5
|
146
|
garbeam@5
|
147 static void
|
garbeam@5
|
148 maprequest(XEvent *e)
|
garbeam@5
|
149 {
|
garbeam@5
|
150 XMapRequestEvent *ev = &e->xmaprequest;
|
garbeam@5
|
151 static XWindowAttributes wa;
|
garbeam@5
|
152
|
garbeam@5
|
153 if(!XGetWindowAttributes(dpy, ev->window, &wa))
|
garbeam@5
|
154 return;
|
garbeam@5
|
155
|
garbeam@5
|
156 if(wa.override_redirect) {
|
garbeam@5
|
157 XSelectInput(dpy, ev->window,
|
garbeam@5
|
158 (StructureNotifyMask | PropertyChangeMask));
|
garbeam@5
|
159 return;
|
garbeam@5
|
160 }
|
garbeam@5
|
161
|
garbeam@6
|
162 /*if(!client_of_win(ev->window))*/
|
garbeam@9
|
163 /*manage(create_client(ev->window, &wa));*/
|
garbeam@9
|
164 XMapRaised(dpy, ev->window);
|
garbeam@9
|
165 XMoveResizeWindow(dpy, ev->window, rect.x, rect.y, rect.width, rect.height - barrect.height);
|
garbeam@9
|
166 XSetInputFocus(dpy, ev->window, RevertToPointerRoot, CurrentTime);
|
garbeam@9
|
167 XFlush(dpy);
|
garbeam@5
|
168 }
|
garbeam@5
|
169
|
garbeam@5
|
170 static void
|
garbeam@5
|
171 propertynotify(XEvent *e)
|
garbeam@5
|
172 {
|
garbeam@5
|
173 #if 0
|
garbeam@5
|
174 XPropertyEvent *ev = &e->xproperty;
|
garbeam@5
|
175 Client *c;
|
garbeam@5
|
176
|
garbeam@5
|
177 if(ev->state == PropertyDelete)
|
garbeam@5
|
178 return; /* ignore */
|
garbeam@5
|
179
|
garbeam@5
|
180 if((c = client_of_win(ev->window)))
|
garbeam@5
|
181 prop_client(c, ev);
|
garbeam@5
|
182 #endif
|
garbeam@5
|
183 }
|
garbeam@5
|
184
|
garbeam@5
|
185 static void
|
garbeam@5
|
186 unmapnotify(XEvent *e)
|
garbeam@5
|
187 {
|
garbeam@5
|
188 #if 0
|
garbeam@5
|
189 Client *c;
|
garbeam@5
|
190 XUnmapEvent *ev = &e->xunmap;
|
garbeam@5
|
191
|
garbeam@5
|
192 if((c = client_of_win(ev->window)))
|
garbeam@5
|
193 destroy_client(c);
|
garbeam@5
|
194 #endif
|
garbeam@5
|
195 }
|