comparison mouse.c @ 19:b5510d0c6d43

added basic mouse support (actually we don't need more)
author Anselm R. Garbe <garbeam@wmii.de>
date Tue, 11 Jul 2006 21:41:49 +0200
parents 1efa34c6e1b6
children 4560e0882c1d
comparison
equal deleted inserted replaced
18:1efa34c6e1b6 19:b5510d0c6d43
40 XEvent ev; 40 XEvent ev;
41 int old_cx, old_cy; 41 int old_cx, old_cy;
42 42
43 old_cx = c->r[RFloat].x; 43 old_cx = c->r[RFloat].x;
44 old_cy = c->r[RFloat].y; 44 old_cy = c->r[RFloat].y;
45 if(XGrabPointer(dpy, c->win, False, MouseMask, GrabModeAsync, GrabModeAsync, 45 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
46 None, cursor[CurResize], CurrentTime) != GrabSuccess) 46 None, cursor[CurResize], CurrentTime) != GrabSuccess)
47 return; 47 return;
48 XGrabServer(dpy); 48 XGrabServer(dpy);
49 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, 49 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
50 c->r[RFloat].width, c->r[RFloat].height); 50 c->r[RFloat].width, c->r[RFloat].height);
53 switch(ev.type) { 53 switch(ev.type) {
54 default: break; 54 default: break;
55 case MotionNotify: 55 case MotionNotify:
56 XUngrabServer(dpy); 56 XUngrabServer(dpy);
57 mmatch(c, old_cx, old_cy, ev.xmotion.x, ev.xmotion.y); 57 mmatch(c, old_cx, old_cy, ev.xmotion.x, ev.xmotion.y);
58 resize(c); 58 XResizeWindow(dpy, c->win, c->r[RFloat].width, c->r[RFloat].height);
59 XGrabServer(dpy); 59 XGrabServer(dpy);
60 break; 60 break;
61 case ButtonRelease: 61 case ButtonRelease:
62 resize(c);
63 XUngrabServer(dpy);
62 XUngrabPointer(dpy, CurrentTime); 64 XUngrabPointer(dpy, CurrentTime);
63 return; 65 return;
64 } 66 }
65 } 67 }
66 } 68 }
73 unsigned int dui; 75 unsigned int dui;
74 Window dummy; 76 Window dummy;
75 77
76 old_cx = c->r[RFloat].x; 78 old_cx = c->r[RFloat].x;
77 old_cy = c->r[RFloat].y; 79 old_cy = c->r[RFloat].y;
78 if(XGrabPointer(dpy, c->win, False, MouseMask, GrabModeAsync, GrabModeAsync, 80 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
79 None, cursor[CurMove], CurrentTime) != GrabSuccess) 81 None, cursor[CurMove], CurrentTime) != GrabSuccess)
80 return; 82 return;
81 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); 83 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
82 XGrabServer(dpy); 84 XGrabServer(dpy);
83 for(;;) { 85 for(;;) {
86 default: break; 88 default: break;
87 case MotionNotify: 89 case MotionNotify:
88 XUngrabServer(dpy); 90 XUngrabServer(dpy);
89 c->r[RFloat].x = old_cx + (ev.xmotion.x - x1); 91 c->r[RFloat].x = old_cx + (ev.xmotion.x - x1);
90 c->r[RFloat].y = old_cy + (ev.xmotion.y - y1); 92 c->r[RFloat].y = old_cy + (ev.xmotion.y - y1);
91 resize(c); 93 XMoveResizeWindow(dpy, c->win, c->r[RFloat].x, c->r[RFloat].y,
94 c->r[RFloat].width, c->r[RFloat].height);
92 XGrabServer(dpy); 95 XGrabServer(dpy);
93 break; 96 break;
94 case ButtonRelease: 97 case ButtonRelease:
98 resize(c);
95 XUngrabServer(dpy); 99 XUngrabServer(dpy);
96 XUngrabPointer(dpy, CurrentTime); 100 XUngrabPointer(dpy, CurrentTime);
97 return; 101 return;
98 } 102 }
99 } 103 }