summaryrefslogtreecommitdiffstats
path: root/mouse.c
diff options
context:
space:
mode:
Diffstat (limited to 'mouse.c')
-rw-r--r--mouse.c52
1 files changed, 25 insertions, 27 deletions
diff --git a/mouse.c b/mouse.c
index 07b533c..577f23c 100644
--- a/mouse.c
+++ b/mouse.c
@@ -16,22 +16,22 @@
16static void 16static void
17mmatch(Client *c, int x1, int y1, int x2, int y2) 17mmatch(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
37void 37void
@@ -40,14 +40,13 @@ mresize(Client *c)
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) {
@@ -55,7 +54,7 @@ mresize(Client *c)
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:
@@ -75,8 +74,8 @@ mmove(Client *c)
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;
@@ -88,10 +87,9 @@ mmove(Client *c)
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: