Mercurial > dwm-meillo
comparison mouse.c @ 20:4560e0882c1d
made code more readable
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Tue, 11 Jul 2006 22:49:09 +0200 |
parents | b5510d0c6d43 |
children | e8f627998d6f |
comparison
equal
deleted
inserted
replaced
19:b5510d0c6d43 | 20:4560e0882c1d |
---|---|
14 #define MouseMask (ButtonMask | PointerMotionMask) | 14 #define MouseMask (ButtonMask | PointerMotionMask) |
15 | 15 |
16 static void | 16 static void |
17 mmatch(Client *c, int x1, int y1, int x2, int y2) | 17 mmatch(Client *c, int x1, int y1, int x2, int y2) |
18 { | 18 { |
19 c->r[RFloat].width = abs(x1 - x2); | 19 c->w = abs(x1 - x2); |
20 c->r[RFloat].height = abs(y1 - y2); | 20 c->h = abs(y1 - y2); |
21 c->r[RFloat].width -= | 21 if(c->incw) |
22 (c->r[RFloat].width - c->size.base_width) % c->size.width_inc; | 22 c->w -= (c->w - c->basew) % c->incw; |
23 c->r[RFloat].height -= | 23 if(c->inch) |
24 (c->r[RFloat].height - c->size.base_height) % c->size.height_inc; | 24 c->h -= (c->h - c->baseh) % c->inch; |
25 if(c->size.min_width && c->r[RFloat].width < c->size.min_width) | 25 if(c->minw && c->w < c->minw) |
26 c->r[RFloat].width = c->size.min_width; | 26 c->w = c->minw; |
27 if(c->size.min_height && c->r[RFloat].height < c->size.min_height) | 27 if(c->minh && c->h < c->minh) |
28 c->r[RFloat].height = c->size.min_height; | 28 c->h = c->minh; |
29 if(c->size.max_width && c->r[RFloat].width > c->size.max_width) | 29 if(c->maxw && c->w > c->maxw) |
30 c->r[RFloat].width = c->size.max_width; | 30 c->w = c->maxw; |
31 if(c->size.max_height && c->r[RFloat].height > c->size.max_height) | 31 if(c->maxh && c->h > c->maxh) |
32 c->r[RFloat].height = c->size.max_height; | 32 c->h = c->maxh; |
33 c->r[RFloat].x = (x1 <= x2) ? x1 : x1 - c->r[RFloat].width; | 33 c->x = (x1 <= x2) ? x1 : x1 - c->w; |
34 c->r[RFloat].y = (y1 <= y2) ? y1 : y1 - c->r[RFloat].height; | 34 c->y = (y1 <= y2) ? y1 : y1 - c->h; |
35 } | 35 } |
36 | 36 |
37 void | 37 void |
38 mresize(Client *c) | 38 mresize(Client *c) |
39 { | 39 { |
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->x; |
44 old_cy = c->r[RFloat].y; | 44 old_cy = c->y; |
45 if(XGrabPointer(dpy, root, 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, c->w, c->h); |
50 c->r[RFloat].width, c->r[RFloat].height); | |
51 for(;;) { | 50 for(;;) { |
52 XMaskEvent(dpy, MouseMask, &ev); | 51 XMaskEvent(dpy, MouseMask, &ev); |
53 switch(ev.type) { | 52 switch(ev.type) { |
54 default: break; | 53 default: break; |
55 case MotionNotify: | 54 case MotionNotify: |
56 XUngrabServer(dpy); | 55 XUngrabServer(dpy); |
57 mmatch(c, old_cx, old_cy, ev.xmotion.x, ev.xmotion.y); | 56 mmatch(c, old_cx, old_cy, ev.xmotion.x, ev.xmotion.y); |
58 XResizeWindow(dpy, c->win, c->r[RFloat].width, c->r[RFloat].height); | 57 XResizeWindow(dpy, c->win, c->w, c->h); |
59 XGrabServer(dpy); | 58 XGrabServer(dpy); |
60 break; | 59 break; |
61 case ButtonRelease: | 60 case ButtonRelease: |
62 resize(c); | 61 resize(c); |
63 XUngrabServer(dpy); | 62 XUngrabServer(dpy); |
73 XEvent ev; | 72 XEvent ev; |
74 int x1, y1, old_cx, old_cy, di; | 73 int x1, y1, old_cx, old_cy, di; |
75 unsigned int dui; | 74 unsigned int dui; |
76 Window dummy; | 75 Window dummy; |
77 | 76 |
78 old_cx = c->r[RFloat].x; | 77 old_cx = c->x; |
79 old_cy = c->r[RFloat].y; | 78 old_cy = c->y; |
80 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, | 79 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
81 None, cursor[CurMove], CurrentTime) != GrabSuccess) | 80 None, cursor[CurMove], CurrentTime) != GrabSuccess) |
82 return; | 81 return; |
83 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); | 82 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); |
84 XGrabServer(dpy); | 83 XGrabServer(dpy); |
86 XMaskEvent(dpy, MouseMask, &ev); | 85 XMaskEvent(dpy, MouseMask, &ev); |
87 switch (ev.type) { | 86 switch (ev.type) { |
88 default: break; | 87 default: break; |
89 case MotionNotify: | 88 case MotionNotify: |
90 XUngrabServer(dpy); | 89 XUngrabServer(dpy); |
91 c->r[RFloat].x = old_cx + (ev.xmotion.x - x1); | 90 c->x = old_cx + (ev.xmotion.x - x1); |
92 c->r[RFloat].y = old_cy + (ev.xmotion.y - y1); | 91 c->y = old_cy + (ev.xmotion.y - y1); |
93 XMoveResizeWindow(dpy, c->win, c->r[RFloat].x, c->r[RFloat].y, | 92 XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); |
94 c->r[RFloat].width, c->r[RFloat].height); | |
95 XGrabServer(dpy); | 93 XGrabServer(dpy); |
96 break; | 94 break; |
97 case ButtonRelease: | 95 case ButtonRelease: |
98 resize(c); | 96 resize(c); |
99 XUngrabServer(dpy); | 97 XUngrabServer(dpy); |