summaryrefslogtreecommitdiffstats
path: root/mouse.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--mouse.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/mouse.c b/mouse.c
index 896d6b0..ff81701 100644
--- a/mouse.c
+++ b/mouse.c
@@ -13,27 +13,6 @@
13#define ButtonMask (ButtonPressMask | ButtonReleaseMask) 13#define ButtonMask (ButtonPressMask | ButtonReleaseMask)
14#define MouseMask (ButtonMask | PointerMotionMask) 14#define MouseMask (ButtonMask | PointerMotionMask)
15 15
16static void
17mmatch(Client *c, int x1, int y1, int x2, int y2)
18{
19 c->w = abs(x1 - x2);
20 c->h = abs(y1 - y2);
21 if(c->incw)
22 c->w -= (c->w - c->basew) % c->incw;
23 if(c->inch)
24 c->h -= (c->h - c->baseh) % c->inch;
25 if(c->minw && c->w < c->minw)
26 c->w = c->minw;
27 if(c->minh && c->h < c->minh)
28 c->h = c->minh;
29 if(c->maxw && c->w > c->maxw)
30 c->w = c->maxw;
31 if(c->maxh && c->h > c->maxh)
32 c->h = c->maxh;
33 c->x = (x1 <= x2) ? x1 : x1 - c->w;
34 c->y = (y1 <= y2) ? y1 : y1 - c->h;
35}
36
37void 16void
38mresize(Client *c) 17mresize(Client *c)
39{ 18{
@@ -55,11 +34,13 @@ mresize(Client *c)
55 break; 34 break;
56 case MotionNotify: 35 case MotionNotify:
57 XFlush(dpy); 36 XFlush(dpy);
58 mmatch(c, old_cx, old_cy, ev.xmotion.x, ev.xmotion.y); 37 c->w = abs(old_cx - ev.xmotion.x);
59 XResizeWindow(dpy, c->win, c->w, c->h); 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);
60 break; 42 break;
61 case ButtonRelease: 43 case ButtonRelease:
62 resize(c);
63 XUngrabPointer(dpy, CurrentTime); 44 XUngrabPointer(dpy, CurrentTime);
64 return; 45 return;
65 } 46 }
@@ -91,10 +72,9 @@ mmove(Client *c)
91 XFlush(dpy); 72 XFlush(dpy);
92 c->x = old_cx + (ev.xmotion.x - x1); 73 c->x = old_cx + (ev.xmotion.x - x1);
93 c->y = old_cy + (ev.xmotion.y - y1); 74 c->y = old_cy + (ev.xmotion.y - y1);
94 XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); 75 resize(c);
95 break; 76 break;
96 case ButtonRelease: 77 case ButtonRelease:
97 resize(c);
98 XUngrabPointer(dpy, CurrentTime); 78 XUngrabPointer(dpy, CurrentTime);
99 return; 79 return;
100 } 80 }