Mercurial > aewl
annotate 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 |
rev | line source |
---|---|
18 | 1 /* |
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> | |
3 * See LICENSE file for license details. | |
4 */ | |
5 | |
6 #include <stdlib.h> | |
7 #include <string.h> | |
8 #include <unistd.h> | |
9 | |
10 #include "wm.h" | |
11 | |
12 #define ButtonMask (ButtonPressMask | ButtonReleaseMask) | |
13 #define MouseMask (ButtonMask | PointerMotionMask) | |
14 | |
15 void | |
16 mresize(Client *c) | |
17 { | |
18 XEvent ev; | |
41 | 19 int ocx, ocy; |
18 | 20 |
41 | 21 ocx = c->x; |
22 ocy = c->y; | |
19
b5510d0c6d43
added basic mouse support (actually we don't need more)
Anselm R. Garbe <garbeam@wmii.de>
parents:
18
diff
changeset
|
23 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
18 | 24 None, cursor[CurResize], CurrentTime) != GrabSuccess) |
25 return; | |
20 | 26 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); |
18 | 27 for(;;) { |
26
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
20
diff
changeset
|
28 XMaskEvent(dpy, MouseMask | ExposureMask, &ev); |
18 | 29 switch(ev.type) { |
30 default: break; | |
26
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
20
diff
changeset
|
31 case Expose: |
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
20
diff
changeset
|
32 handler[Expose](&ev); |
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
20
diff
changeset
|
33 break; |
18 | 34 case MotionNotify: |
26
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
20
diff
changeset
|
35 XFlush(dpy); |
41 | 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; | |
31 | 40 resize(c); |
18 | 41 break; |
42 case ButtonRelease: | |
43 XUngrabPointer(dpy, CurrentTime); | |
44 return; | |
45 } | |
46 } | |
47 } | |
48 | |
49 void | |
50 mmove(Client *c) | |
51 { | |
52 XEvent ev; | |
41 | 53 int x1, y1, ocx, ocy, di; |
18 | 54 unsigned int dui; |
55 Window dummy; | |
56 | |
41 | 57 ocx = c->x; |
58 ocy = c->y; | |
19
b5510d0c6d43
added basic mouse support (actually we don't need more)
Anselm R. Garbe <garbeam@wmii.de>
parents:
18
diff
changeset
|
59 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
18 | 60 None, cursor[CurMove], CurrentTime) != GrabSuccess) |
61 return; | |
62 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); | |
63 for(;;) { | |
26
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
20
diff
changeset
|
64 XMaskEvent(dpy, MouseMask | ExposureMask, &ev); |
18 | 65 switch (ev.type) { |
66 default: break; | |
26
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
20
diff
changeset
|
67 case Expose: |
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
20
diff
changeset
|
68 handler[Expose](&ev); |
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
20
diff
changeset
|
69 break; |
18 | 70 case MotionNotify: |
26
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
20
diff
changeset
|
71 XFlush(dpy); |
41 | 72 c->x = ocx + (ev.xmotion.x - x1); |
73 c->y = ocy + (ev.xmotion.y - y1); | |
31 | 74 resize(c); |
18 | 75 break; |
76 case ButtonRelease: | |
77 XUngrabPointer(dpy, CurrentTime); | |
78 return; | |
79 } | |
80 } | |
81 } |