dwm-meillo
diff 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 |
line diff
1.1 --- a/mouse.c Tue Jul 11 21:41:49 2006 +0200 1.2 +++ b/mouse.c Tue Jul 11 22:49:09 2006 +0200 1.3 @@ -16,22 +16,22 @@ 1.4 static void 1.5 mmatch(Client *c, int x1, int y1, int x2, int y2) 1.6 { 1.7 - c->r[RFloat].width = abs(x1 - x2); 1.8 - c->r[RFloat].height = abs(y1 - y2); 1.9 - c->r[RFloat].width -= 1.10 - (c->r[RFloat].width - c->size.base_width) % c->size.width_inc; 1.11 - c->r[RFloat].height -= 1.12 - (c->r[RFloat].height - c->size.base_height) % c->size.height_inc; 1.13 - if(c->size.min_width && c->r[RFloat].width < c->size.min_width) 1.14 - c->r[RFloat].width = c->size.min_width; 1.15 - if(c->size.min_height && c->r[RFloat].height < c->size.min_height) 1.16 - c->r[RFloat].height = c->size.min_height; 1.17 - if(c->size.max_width && c->r[RFloat].width > c->size.max_width) 1.18 - c->r[RFloat].width = c->size.max_width; 1.19 - if(c->size.max_height && c->r[RFloat].height > c->size.max_height) 1.20 - c->r[RFloat].height = c->size.max_height; 1.21 - c->r[RFloat].x = (x1 <= x2) ? x1 : x1 - c->r[RFloat].width; 1.22 - c->r[RFloat].y = (y1 <= y2) ? y1 : y1 - c->r[RFloat].height; 1.23 + c->w = abs(x1 - x2); 1.24 + c->h = abs(y1 - y2); 1.25 + if(c->incw) 1.26 + c->w -= (c->w - c->basew) % c->incw; 1.27 + if(c->inch) 1.28 + c->h -= (c->h - c->baseh) % c->inch; 1.29 + if(c->minw && c->w < c->minw) 1.30 + c->w = c->minw; 1.31 + if(c->minh && c->h < c->minh) 1.32 + c->h = c->minh; 1.33 + if(c->maxw && c->w > c->maxw) 1.34 + c->w = c->maxw; 1.35 + if(c->maxh && c->h > c->maxh) 1.36 + c->h = c->maxh; 1.37 + c->x = (x1 <= x2) ? x1 : x1 - c->w; 1.38 + c->y = (y1 <= y2) ? y1 : y1 - c->h; 1.39 } 1.40 1.41 void 1.42 @@ -40,14 +40,13 @@ 1.43 XEvent ev; 1.44 int old_cx, old_cy; 1.45 1.46 - old_cx = c->r[RFloat].x; 1.47 - old_cy = c->r[RFloat].y; 1.48 + old_cx = c->x; 1.49 + old_cy = c->y; 1.50 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, 1.51 None, cursor[CurResize], CurrentTime) != GrabSuccess) 1.52 return; 1.53 XGrabServer(dpy); 1.54 - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, 1.55 - c->r[RFloat].width, c->r[RFloat].height); 1.56 + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); 1.57 for(;;) { 1.58 XMaskEvent(dpy, MouseMask, &ev); 1.59 switch(ev.type) { 1.60 @@ -55,7 +54,7 @@ 1.61 case MotionNotify: 1.62 XUngrabServer(dpy); 1.63 mmatch(c, old_cx, old_cy, ev.xmotion.x, ev.xmotion.y); 1.64 - XResizeWindow(dpy, c->win, c->r[RFloat].width, c->r[RFloat].height); 1.65 + XResizeWindow(dpy, c->win, c->w, c->h); 1.66 XGrabServer(dpy); 1.67 break; 1.68 case ButtonRelease: 1.69 @@ -75,8 +74,8 @@ 1.70 unsigned int dui; 1.71 Window dummy; 1.72 1.73 - old_cx = c->r[RFloat].x; 1.74 - old_cy = c->r[RFloat].y; 1.75 + old_cx = c->x; 1.76 + old_cy = c->y; 1.77 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, 1.78 None, cursor[CurMove], CurrentTime) != GrabSuccess) 1.79 return; 1.80 @@ -88,10 +87,9 @@ 1.81 default: break; 1.82 case MotionNotify: 1.83 XUngrabServer(dpy); 1.84 - c->r[RFloat].x = old_cx + (ev.xmotion.x - x1); 1.85 - c->r[RFloat].y = old_cy + (ev.xmotion.y - y1); 1.86 - XMoveResizeWindow(dpy, c->win, c->r[RFloat].x, c->r[RFloat].y, 1.87 - c->r[RFloat].width, c->r[RFloat].height); 1.88 + c->x = old_cx + (ev.xmotion.x - x1); 1.89 + c->y = old_cy + (ev.xmotion.y - y1); 1.90 + XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); 1.91 XGrabServer(dpy); 1.92 break; 1.93 case ButtonRelease: