aewl
view mouse.c @ 41:fc9ccd34b8ab
removed obsolete stuff
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Thu, 13 Jul 2006 10:25:57 +0200 |
parents | 386649deb651 |
children |
line source
1 /*
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
4 */
6 #include <stdlib.h>
7 #include <string.h>
8 #include <unistd.h>
10 #include "wm.h"
12 #define ButtonMask (ButtonPressMask | ButtonReleaseMask)
13 #define MouseMask (ButtonMask | PointerMotionMask)
15 void
16 mresize(Client *c)
17 {
18 XEvent ev;
19 int ocx, ocy;
21 ocx = c->x;
22 ocy = c->y;
23 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
24 None, cursor[CurResize], CurrentTime) != GrabSuccess)
25 return;
26 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
27 for(;;) {
28 XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
29 switch(ev.type) {
30 default: break;
31 case Expose:
32 handler[Expose](&ev);
33 break;
34 case MotionNotify:
35 XFlush(dpy);
36 c->w = abs(ocx - ev.xmotion.x);
37 c->h = abs(ocy - ev.xmotion.y);
38 c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
39 c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
40 resize(c);
41 break;
42 case ButtonRelease:
43 XUngrabPointer(dpy, CurrentTime);
44 return;
45 }
46 }
47 }
49 void
50 mmove(Client *c)
51 {
52 XEvent ev;
53 int x1, y1, ocx, ocy, di;
54 unsigned int dui;
55 Window dummy;
57 ocx = c->x;
58 ocy = c->y;
59 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
60 None, cursor[CurMove], CurrentTime) != GrabSuccess)
61 return;
62 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
63 for(;;) {
64 XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
65 switch (ev.type) {
66 default: break;
67 case Expose:
68 handler[Expose](&ev);
69 break;
70 case MotionNotify:
71 XFlush(dpy);
72 c->x = ocx + (ev.xmotion.x - x1);
73 c->y = ocy + (ev.xmotion.y - y1);
74 resize(c);
75 break;
76 case ButtonRelease:
77 XUngrabPointer(dpy, CurrentTime);
78 return;
79 }
80 }
81 }