Mercurial > dwm-meillo
annotate mouse.c @ 32:082c75b937b5
removed unnecessary crap
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Thu, 13 Jul 2006 01:30:55 +0200 |
parents | 386649deb651 |
children | fc9ccd34b8ab |
rev | line source |
---|---|
18 | 1 /* |
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> | |
3 * (C)opyright MMVI Kris Maglione <fbsdaemon@gmail.com> | |
4 * See LICENSE file for license details. | |
5 */ | |
6 | |
7 #include <stdlib.h> | |
8 #include <string.h> | |
9 #include <unistd.h> | |
10 | |
11 #include "wm.h" | |
12 | |
13 #define ButtonMask (ButtonPressMask | ButtonReleaseMask) | |
14 #define MouseMask (ButtonMask | PointerMotionMask) | |
15 | |
16 void | |
17 mresize(Client *c) | |
18 { | |
19 XEvent ev; | |
20 int old_cx, old_cy; | |
21 | |
20 | 22 old_cx = c->x; |
23 old_cy = c->y; | |
19
b5510d0c6d43
added basic mouse support (actually we don't need more)
Anselm R. Garbe <garbeam@wmii.de>
parents:
18
diff
changeset
|
24 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
18 | 25 None, cursor[CurResize], CurrentTime) != GrabSuccess) |
26 return; | |
20 | 27 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); |
18 | 28 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
|
29 XMaskEvent(dpy, MouseMask | ExposureMask, &ev); |
18 | 30 switch(ev.type) { |
31 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
|
32 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
|
33 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
|
34 break; |
18 | 35 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
|
36 XFlush(dpy); |
31 | 37 c->w = abs(old_cx - ev.xmotion.x); |
38 c->h = abs(old_cy - ev.xmotion.y); | |
39 c->x = (old_cx <= ev.xmotion.x) ? old_cx : old_cx - c->w; | |
40 c->y = (old_cy <= ev.xmotion.y) ? old_cy : old_cy - c->h; | |
41 resize(c); | |
18 | 42 break; |
43 case ButtonRelease: | |
44 XUngrabPointer(dpy, CurrentTime); | |
45 return; | |
46 } | |
47 } | |
48 } | |
49 | |
50 void | |
51 mmove(Client *c) | |
52 { | |
53 XEvent ev; | |
54 int x1, y1, old_cx, old_cy, di; | |
55 unsigned int dui; | |
56 Window dummy; | |
57 | |
20 | 58 old_cx = c->x; |
59 old_cy = c->y; | |
19
b5510d0c6d43
added basic mouse support (actually we don't need more)
Anselm R. Garbe <garbeam@wmii.de>
parents:
18
diff
changeset
|
60 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
18 | 61 None, cursor[CurMove], CurrentTime) != GrabSuccess) |
62 return; | |
63 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); | |
64 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
|
65 XMaskEvent(dpy, MouseMask | ExposureMask, &ev); |
18 | 66 switch (ev.type) { |
67 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
|
68 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
|
69 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
|
70 break; |
18 | 71 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
|
72 XFlush(dpy); |
20 | 73 c->x = old_cx + (ev.xmotion.x - x1); |
74 c->y = old_cy + (ev.xmotion.y - y1); | |
31 | 75 resize(c); |
18 | 76 break; |
77 case ButtonRelease: | |
78 XUngrabPointer(dpy, CurrentTime); | |
79 return; | |
80 } | |
81 } | |
82 } |