comparison event.c @ 18:1efa34c6e1b6

added mouse-based resizals
author Anselm R. Garbe <garbeam@wmii.de>
date Tue, 11 Jul 2006 21:24:10 +0200
parents 359b6e563b95
children b5510d0c6d43
comparison
equal deleted inserted replaced
17:aaf520f53110 18:1efa34c6e1b6
10 #include <X11/Xatom.h> 10 #include <X11/Xatom.h>
11 11
12 #include "wm.h" 12 #include "wm.h"
13 13
14 /* local functions */ 14 /* local functions */
15 static void buttonpress(XEvent *e);
15 static void configurerequest(XEvent *e); 16 static void configurerequest(XEvent *e);
16 static void destroynotify(XEvent *e); 17 static void destroynotify(XEvent *e);
17 static void enternotify(XEvent *e); 18 static void enternotify(XEvent *e);
18 static void leavenotify(XEvent *e); 19 static void leavenotify(XEvent *e);
19 static void expose(XEvent *e); 20 static void expose(XEvent *e);
21 static void maprequest(XEvent *e); 22 static void maprequest(XEvent *e);
22 static void propertynotify(XEvent *e); 23 static void propertynotify(XEvent *e);
23 static void unmapnotify(XEvent *e); 24 static void unmapnotify(XEvent *e);
24 25
25 void (*handler[LASTEvent]) (XEvent *) = { 26 void (*handler[LASTEvent]) (XEvent *) = {
27 [ButtonPress] = buttonpress,
26 [ConfigureRequest] = configurerequest, 28 [ConfigureRequest] = configurerequest,
27 [DestroyNotify] = destroynotify, 29 [DestroyNotify] = destroynotify,
28 [EnterNotify] = enternotify, 30 [EnterNotify] = enternotify,
29 [LeaveNotify] = leavenotify, 31 [LeaveNotify] = leavenotify,
30 [Expose] = expose, 32 [Expose] = expose,
34 [PropertyNotify] = propertynotify, 36 [PropertyNotify] = propertynotify,
35 [UnmapNotify] = unmapnotify 37 [UnmapNotify] = unmapnotify
36 }; 38 };
37 39
38 unsigned int 40 unsigned int
39 flush_events(long even_mask) 41 discard_events(long even_mask)
40 { 42 {
41 XEvent ev; 43 XEvent ev;
42 unsigned int n = 0; 44 unsigned int n = 0;
43 while(XCheckMaskEvent(dpy, even_mask, &ev)) n++; 45 while(XCheckMaskEvent(dpy, even_mask, &ev)) n++;
44 return n; 46 return n;
45 } 47 }
46 48
47 static void 49 static void
50 buttonpress(XEvent *e)
51 {
52 XButtonPressedEvent *ev = &e->xbutton;
53 Client *c;
54
55 if((c = getclient(ev->window))) {
56 switch(ev->button) {
57 default:
58 break;
59 case Button1:
60 mmove(c);
61 break;
62 case Button2:
63 XLowerWindow(dpy, c->win);
64 break;
65 case Button3:
66 mresize(c);
67 break;
68 }
69 }
70 }
71
72 static void
48 configurerequest(XEvent *e) 73 configurerequest(XEvent *e)
49 { 74 {
50 XConfigureRequestEvent *ev = &e->xconfigurerequest; 75 XConfigureRequestEvent *ev = &e->xconfigurerequest;
51 XWindowChanges wc; 76 XWindowChanges wc;
52 Client *c; 77 Client *c;
53 78
54 c = getclient(ev->window);
55 ev->value_mask &= ~CWSibling; 79 ev->value_mask &= ~CWSibling;
56 if(c) { 80 if((c = getclient(ev->window))) {
57 if(ev->value_mask & CWX) 81 if(ev->value_mask & CWX)
58 c->r[RFloat].x = ev->x; 82 c->r[RFloat].x = ev->x;
59 if(ev->value_mask & CWY) 83 if(ev->value_mask & CWY)
60 c->r[RFloat].y = ev->y; 84 c->r[RFloat].y = ev->y;
61 if(ev->value_mask & CWWidth) 85 if(ev->value_mask & CWWidth)