|
@ -16,22 +16,22 @@ |
|
|
static void |
|
|
static void |
|
|
mmatch(Client *c, int x1, int y1, int x2, int y2) |
|
|
mmatch(Client *c, int x1, int y1, int x2, int y2) |
|
|
{ |
|
|
{ |
|
|
c->r[RFloat].width = abs(x1 - x2); |
|
|
|
|
|
c->r[RFloat].height = abs(y1 - y2); |
|
|
|
|
|
c->r[RFloat].width -= |
|
|
|
|
|
(c->r[RFloat].width - c->size.base_width) % c->size class="p">.width_inc; |
|
|
|
|
|
c->r[RFloat].height -= |
|
|
|
|
|
(c->r[RFloat].height - c->size.base_height) % c->size.height_inc; |
|
|
|
|
|
if(c->size.min_width && c->r[RFloat].width < c->size.min_width) |
|
|
|
|
|
c->r[RFloat].width = c->size.min_width; |
|
|
|
|
|
if(c->size.min_height && c->r[RFloat].height < c->size.min_height) |
|
|
|
|
|
c->r[RFloat].height = c->size.min_height; |
|
|
|
|
|
if(c->size.max_width && c->r[RFloat].width > c->size.max_width) |
|
|
|
|
|
c->r[RFloat].width = c->size.max_width; |
|
|
|
|
|
if(c->size.max_height && c->r[RFloat].height > c->size.max_height) |
|
|
|
|
|
c->r[RFloat].height = c->size.max_height; |
|
|
|
|
|
c->r[RFloat].x = (x1 <= x2) ? x1 : x1 - c->r[RFloat].width; |
|
|
|
|
|
c->r[RFloat].y = (y1 <= y2) ? y1 : y1 - c->r[RFloat].height; |
|
|
|
|
|
|
|
|
c->w = abs(x1 - x2); |
|
|
|
|
|
c->h = abs(y1 - y2); |
|
|
|
|
|
if(c->incw) |
|
|
|
|
|
c->w -= (c->w - c->basew) % c->incw; |
|
|
|
|
|
if(c->inch) |
|
|
|
|
|
c->h -= (c->h - c->baseh) % c->inch; |
|
|
|
|
|
if(c->minw && c->w < c->minw) |
|
|
|
|
|
c->w = c->minw; |
|
|
|
|
|
if(c->minh && c->h < c->minh) |
|
|
|
|
|
c->h = c->minh; |
|
|
|
|
|
if(c->maxw && c->w > c->maxw) |
|
|
|
|
|
c->w = c->maxw; |
|
|
|
|
|
if(c->maxh && c->h > c->maxh) |
|
|
|
|
|
c->h = c->maxh; |
|
|
|
|
|
c->x = (x1 <= x2) ? x1 : x1 - c->w; |
|
|
|
|
|
c->y = (y1 <= y2) ? y1 : y1 - c->h; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
void |
|
@ -40,14 +40,13 @@ mresize(Client *c) |
|
|
XEvent ev; |
|
|
XEvent ev; |
|
|
int old_cx, old_cy; |
|
|
int old_cx, old_cy; |
|
|
|
|
|
|
|
|
old_cx = c->r[RFloat].x; |
|
|
|
|
|
old_cy = c->r[RFloat].y; |
|
|
|
|
|
|
|
|
old_cx = c->x; |
|
|
|
|
|
old_cy = c->y; |
|
|
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
|
|
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
|
|
None, cursor[CurResize], CurrentTime) != GrabSuccess) |
|
|
None, cursor[CurResize], CurrentTime) != GrabSuccess) |
|
|
return; |
|
|
return; |
|
|
XGrabServer(dpy); |
|
|
XGrabServer(dpy); |
|
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, |
|
|
|
|
|
c->r[RFloat].width, c->r[RFloat].height); |
|
|
|
|
|
|
|
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); |
|
|
for(;;) { |
|
|
for(;;) { |
|
|
XMaskEvent(dpy, MouseMask, &ev); |
|
|
XMaskEvent(dpy, MouseMask, &ev); |
|
|
switch(ev.type) { |
|
|
switch(ev.type) { |
|
@ -55,7 +54,7 @@ mresize(Client *c) |
|
|
case MotionNotify: |
|
|
case MotionNotify: |
|
|
XUngrabServer(dpy); |
|
|
XUngrabServer(dpy); |
|
|
mmatch(c, old_cx, old_cy, ev.xmotion.x, ev.xmotion.y); |
|
|
mmatch(c, old_cx, old_cy, ev.xmotion.x, ev.xmotion.y); |
|
|
XResizeWindow(dpy, c->win, c->r[RFloat].width, c->r[RFloat].height); |
|
|
|
|
|
|
|
|
XResizeWindow(dpy, c->win, c->w, c->h); |
|
|
XGrabServer(dpy); |
|
|
XGrabServer(dpy); |
|
|
break; |
|
|
break; |
|
|
case ButtonRelease: |
|
|
case ButtonRelease: |
|
@ -75,8 +74,8 @@ mmove(Client *c) |
|
|
unsigned int dui; |
|
|
unsigned int dui; |
|
|
Window dummy; |
|
|
Window dummy; |
|
|
|
|
|
|
|
|
old_cx = c->r[RFloat].x; |
|
|
|
|
|
old_cy = c->r[RFloat].y; |
|
|
|
|
|
|
|
|
old_cx = c->x; |
|
|
|
|
|
old_cy = c->y; |
|
|
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
|
|
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
|
|
None, cursor[CurMove], CurrentTime) != GrabSuccess) |
|
|
None, cursor[CurMove], CurrentTime) != GrabSuccess) |
|
|
return; |
|
|
return; |
|
@ -88,10 +87,9 @@ mmove(Client *c) |
|
|
default: break; |
|
|
default: break; |
|
|
case MotionNotify: |
|
|
case MotionNotify: |
|
|
XUngrabServer(dpy); |
|
|
XUngrabServer(dpy); |
|
|
c->r[RFloat].x = old_cx + (ev.xmotion.x - x1); |
|
|
|
|
|
c->r[RFloat].y = old_cy + (ev.xmotion.y - y1); |
|
|
|
|
|
XMoveResizeWindow(dpy, c->win, c->r[RFloat].x, c->r[RFloat].y, |
|
|
|
|
|
c->r[RFloat].width, c->r[RFloat].height); |
|
|
|
|
|
|
|
|
c->x = old_cx + (ev.xmotion.x - x1); |
|
|
|
|
|
c->y = old_cy + (ev.xmotion.y - y1); |
|
|
|
|
|
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); |
|
|
XGrabServer(dpy); |
|
|
XGrabServer(dpy); |
|
|
break; |
|
|
break; |
|
|
case ButtonRelease: |
|
|
case ButtonRelease: |
|
|