Mercurial > aewl
comparison event.c @ 461:9d23330a5268
removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Tue, 12 Sep 2006 10:57:28 +0200 |
parents | ffb462fb7903 |
children | ad3fa2d18542 |
comparison
equal
deleted
inserted
replaced
460:ab4b08d49d24 | 461:9d23330a5268 |
---|---|
19 KEYS | 19 KEYS |
20 | 20 |
21 #define CLEANMASK(mask) (mask & ~(numlockmask | LockMask)) | 21 #define CLEANMASK(mask) (mask & ~(numlockmask | LockMask)) |
22 | 22 |
23 static void | 23 static void |
24 movemouse(Client *c) | 24 movemouse(Client *c) { |
25 { | |
26 int x1, y1, ocx, ocy, di; | 25 int x1, y1, ocx, ocy, di; |
27 unsigned int dui; | 26 unsigned int dui; |
28 Window dummy; | 27 Window dummy; |
29 XEvent ev; | 28 XEvent ev; |
30 | 29 |
35 return; | 34 return; |
36 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); | 35 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); |
37 for(;;) { | 36 for(;;) { |
38 XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev); | 37 XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev); |
39 switch (ev.type) { | 38 switch (ev.type) { |
40 default: break; | 39 default: |
40 break; | |
41 case Expose: | 41 case Expose: |
42 handler[Expose](&ev); | 42 handler[Expose](&ev); |
43 break; | 43 break; |
44 case MotionNotify: | 44 case MotionNotify: |
45 XSync(dpy, False); | 45 XSync(dpy, False); |
53 } | 53 } |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 static void | 57 static void |
58 resizemouse(Client *c) | 58 resizemouse(Client *c) { |
59 { | |
60 int ocx, ocy; | 59 int ocx, ocy; |
61 int nw, nh; | 60 int nw, nh; |
62 Corner sticky; | 61 Corner sticky; |
63 XEvent ev; | 62 XEvent ev; |
64 | 63 |
69 return; | 68 return; |
70 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); | 69 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); |
71 for(;;) { | 70 for(;;) { |
72 XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev); | 71 XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev); |
73 switch(ev.type) { | 72 switch(ev.type) { |
74 default: break; | 73 default: |
74 break; | |
75 case Expose: | 75 case Expose: |
76 handler[Expose](&ev); | 76 handler[Expose](&ev); |
77 break; | 77 break; |
78 case MotionNotify: | 78 case MotionNotify: |
79 XSync(dpy, False); | 79 XSync(dpy, False); |
95 } | 95 } |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 static void | 99 static void |
100 buttonpress(XEvent *e) | 100 buttonpress(XEvent *e) { |
101 { | |
102 int x; | 101 int x; |
103 Arg a; | 102 Arg a; |
104 Client *c; | 103 Client *c; |
105 XButtonPressedEvent *ev = &e->xbutton; | 104 XButtonPressedEvent *ev = &e->xbutton; |
106 | 105 |
145 } | 144 } |
146 } | 145 } |
147 } | 146 } |
148 | 147 |
149 static void | 148 static void |
150 synconfig(Client *c, int x, int y, int w, int h, unsigned int border) | 149 synconfig(Client *c, int x, int y, int w, int h, unsigned int border) { |
151 { | |
152 XEvent synev; | 150 XEvent synev; |
153 | 151 |
154 synev.type = ConfigureNotify; | 152 synev.type = ConfigureNotify; |
155 synev.xconfigure.display = dpy; | 153 synev.xconfigure.display = dpy; |
156 synev.xconfigure.event = c->win; | 154 synev.xconfigure.event = c->win; |
163 synev.xconfigure.above = None; | 161 synev.xconfigure.above = None; |
164 XSendEvent(dpy, c->win, True, NoEventMask, &synev); | 162 XSendEvent(dpy, c->win, True, NoEventMask, &synev); |
165 } | 163 } |
166 | 164 |
167 static void | 165 static void |
168 configurerequest(XEvent *e) | 166 configurerequest(XEvent *e) { |
169 { | |
170 unsigned long newmask; | 167 unsigned long newmask; |
171 Client *c; | 168 Client *c; |
172 XConfigureRequestEvent *ev = &e->xconfigurerequest; | 169 XConfigureRequestEvent *ev = &e->xconfigurerequest; |
173 XWindowChanges wc; | 170 XWindowChanges wc; |
174 | 171 |
217 XSync(dpy, False); | 214 XSync(dpy, False); |
218 } | 215 } |
219 } | 216 } |
220 | 217 |
221 static void | 218 static void |
222 destroynotify(XEvent *e) | 219 destroynotify(XEvent *e) { |
223 { | |
224 Client *c; | 220 Client *c; |
225 XDestroyWindowEvent *ev = &e->xdestroywindow; | 221 XDestroyWindowEvent *ev = &e->xdestroywindow; |
226 | 222 |
227 if((c = getclient(ev->window))) | 223 if((c = getclient(ev->window))) |
228 unmanage(c); | 224 unmanage(c); |
229 } | 225 } |
230 | 226 |
231 static void | 227 static void |
232 enternotify(XEvent *e) | 228 enternotify(XEvent *e) { |
233 { | |
234 Client *c; | 229 Client *c; |
235 XCrossingEvent *ev = &e->xcrossing; | 230 XCrossingEvent *ev = &e->xcrossing; |
236 | 231 |
237 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) | 232 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) |
238 return; | 233 return; |
245 drawall(); | 240 drawall(); |
246 } | 241 } |
247 } | 242 } |
248 | 243 |
249 static void | 244 static void |
250 expose(XEvent *e) | 245 expose(XEvent *e) { |
251 { | |
252 Client *c; | 246 Client *c; |
253 XExposeEvent *ev = &e->xexpose; | 247 XExposeEvent *ev = &e->xexpose; |
254 | 248 |
255 if(ev->count == 0) { | 249 if(ev->count == 0) { |
256 if(barwin == ev->window) | 250 if(barwin == ev->window) |
259 drawtitle(c); | 253 drawtitle(c); |
260 } | 254 } |
261 } | 255 } |
262 | 256 |
263 static void | 257 static void |
264 keypress(XEvent *e) | 258 keypress(XEvent *e) { |
265 { | |
266 static unsigned int len = sizeof(key) / sizeof(key[0]); | 259 static unsigned int len = sizeof(key) / sizeof(key[0]); |
267 unsigned int i; | 260 unsigned int i; |
268 KeySym keysym; | 261 KeySym keysym; |
269 XKeyEvent *ev = &e->xkey; | 262 XKeyEvent *ev = &e->xkey; |
270 | 263 |
271 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); | 264 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); |
272 for(i = 0; i < len; i++) { | 265 for(i = 0; i < len; i++) { |
273 if(keysym == key[i].keysym && | 266 if(keysym == key[i].keysym |
274 CLEANMASK(key[i].mod) == CLEANMASK(ev->state)) | 267 && CLEANMASK(key[i].mod) == CLEANMASK(ev->state)) |
275 { | 268 { |
276 if(key[i].func) | 269 if(key[i].func) |
277 key[i].func(&key[i].arg); | 270 key[i].func(&key[i].arg); |
278 return; | 271 return; |
279 } | 272 } |
280 } | 273 } |
281 } | 274 } |
282 | 275 |
283 static void | 276 static void |
284 leavenotify(XEvent *e) | 277 leavenotify(XEvent *e) { |
285 { | |
286 XCrossingEvent *ev = &e->xcrossing; | 278 XCrossingEvent *ev = &e->xcrossing; |
287 | 279 |
288 if((ev->window == root) && !ev->same_screen) { | 280 if((ev->window == root) && !ev->same_screen) { |
289 issel = False; | 281 issel = False; |
290 drawall(); | 282 drawall(); |
291 } | 283 } |
292 } | 284 } |
293 | 285 |
294 static void | 286 static void |
295 mappingnotify(XEvent *e) | 287 mappingnotify(XEvent *e) { |
296 { | |
297 XMappingEvent *ev = &e->xmapping; | 288 XMappingEvent *ev = &e->xmapping; |
298 | 289 |
299 XRefreshKeyboardMapping(ev); | 290 XRefreshKeyboardMapping(ev); |
300 if(ev->request == MappingKeyboard) | 291 if(ev->request == MappingKeyboard) |
301 grabkeys(); | 292 grabkeys(); |
302 } | 293 } |
303 | 294 |
304 static void | 295 static void |
305 maprequest(XEvent *e) | 296 maprequest(XEvent *e) { |
306 { | |
307 static XWindowAttributes wa; | 297 static XWindowAttributes wa; |
308 XMapRequestEvent *ev = &e->xmaprequest; | 298 XMapRequestEvent *ev = &e->xmaprequest; |
309 | 299 |
310 if(!XGetWindowAttributes(dpy, ev->window, &wa)) | 300 if(!XGetWindowAttributes(dpy, ev->window, &wa)) |
311 return; | 301 return; |
319 if(!getclient(ev->window)) | 309 if(!getclient(ev->window)) |
320 manage(ev->window, &wa); | 310 manage(ev->window, &wa); |
321 } | 311 } |
322 | 312 |
323 static void | 313 static void |
324 propertynotify(XEvent *e) | 314 propertynotify(XEvent *e) { |
325 { | |
326 Client *c; | 315 Client *c; |
327 Window trans; | 316 Window trans; |
328 XPropertyEvent *ev = &e->xproperty; | 317 XPropertyEvent *ev = &e->xproperty; |
329 | 318 |
330 if(ev->state == PropertyDelete) | 319 if(ev->state == PropertyDelete) |
352 } | 341 } |
353 } | 342 } |
354 } | 343 } |
355 | 344 |
356 static void | 345 static void |
357 unmapnotify(XEvent *e) | 346 unmapnotify(XEvent *e) { |
358 { | |
359 Client *c; | 347 Client *c; |
360 XUnmapEvent *ev = &e->xunmap; | 348 XUnmapEvent *ev = &e->xunmap; |
361 | 349 |
362 if((c = getclient(ev->window))) | 350 if((c = getclient(ev->window))) |
363 unmanage(c); | 351 unmanage(c); |
378 [PropertyNotify] = propertynotify, | 366 [PropertyNotify] = propertynotify, |
379 [UnmapNotify] = unmapnotify | 367 [UnmapNotify] = unmapnotify |
380 }; | 368 }; |
381 | 369 |
382 void | 370 void |
383 grabkeys() | 371 grabkeys() { |
384 { | |
385 static unsigned int len = sizeof(key) / sizeof(key[0]); | 372 static unsigned int len = sizeof(key) / sizeof(key[0]); |
386 unsigned int i; | 373 unsigned int i; |
387 KeyCode code; | 374 KeyCode code; |
388 | 375 |
389 XUngrabKey(dpy, AnyKey, AnyModifier, root); | 376 XUngrabKey(dpy, AnyKey, AnyModifier, root); |
399 GrabModeAsync, GrabModeAsync); | 386 GrabModeAsync, GrabModeAsync); |
400 } | 387 } |
401 } | 388 } |
402 | 389 |
403 void | 390 void |
404 procevent() | 391 procevent() { |
405 { | |
406 XEvent ev; | 392 XEvent ev; |
407 | 393 |
408 while(XPending(dpy)) { | 394 while(XPending(dpy)) { |
409 XNextEvent(dpy, &ev); | 395 XNextEvent(dpy, &ev); |
410 if(handler[ev.type]) | 396 if(handler[ev.type]) |
411 (handler[ev.type])(&ev); /* call handler */ | 397 (handler[ev.type])(&ev); /* call handler */ |
412 } | 398 } |
413 } | 399 } |
414 |