|
|
@ -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->w = abs(x1 - x2);
|
|
|
|
c->r[RFloat].height = abs(y1 - y2);
|
|
|
|
c->h = abs(y1 - y2);
|
|
|
|
c->r[RFloat].width -=
|
|
|
|
if(c->incw)
|
|
|
|
(c->r[RFloat].width - c->size.base_width) % c->size.width_inc;
|
|
|
|
c->w -= (c->w - c->basew) % c->incw;
|
|
|
|
c->r[RFloat].height -=
|
|
|
|
if(c->inch)
|
|
|
|
(c->r[RFloat].height - c->size.base_height) % c->size.height_inc;
|
|
|
|
c->h -= (c->h - c->baseh) % c->inch;
|
|
|
|
if(c->size.min_width && c->r[RFloat].width < c->size.min_width)
|
|
|
|
if(c->minw && c->w < c->minw)
|
|
|
|
c->r[RFloat].width = c->size.min_width;
|
|
|
|
c->w = c->minw;
|
|
|
|
if(c->size.min_height && c->r[RFloat].height < c->size.min_height)
|
|
|
|
if(c->minh && c->h < c->minh)
|
|
|
|
c->r[RFloat].height = c->size.min_height;
|
|
|
|
c->h = c->minh;
|
|
|
|
if(c->size.max_width && c->r[RFloat].width > c->size.max_width)
|
|
|
|
if(c->maxw && c->w > c->maxw)
|
|
|
|
c->r[RFloat].width = c->size.max_width;
|
|
|
|
c->w = c->maxw;
|
|
|
|
if(c->size.max_height && c->r[RFloat].height > c->size.max_height)
|
|
|
|
if(c->maxh && c->h > c->maxh)
|
|
|
|
c->r[RFloat].height = c->size.max_height;
|
|
|
|
c->h = c->maxh;
|
|
|
|
c->r[RFloat].x = (x1 <= x2) ? x1 : x1 - c->r[RFloat].width;
|
|
|
|
c->x = (x1 <= x2) ? x1 : x1 - c->w;
|
|
|
|
c->r[RFloat].y = (y1 <= y2) ? y1 : y1 - c->r[RFloat].height;
|
|
|
|
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_cx = c->x;
|
|
|
|
old_cy = c->r[RFloat].y;
|
|
|
|
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,
|
|
|
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
|
|
|
|
c->r[RFloat].width, c->r[RFloat].height);
|
|
|
|
|
|
|
|
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_cx = c->x;
|
|
|
|
old_cy = c->r[RFloat].y;
|
|
|
|
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->x = old_cx + (ev.xmotion.x - x1);
|
|
|
|
c->r[RFloat].y = old_cy + (ev.xmotion.y - y1);
|
|
|
|
c->y = old_cy + (ev.xmotion.y - y1);
|
|
|
|
XMoveResizeWindow(dpy, c->win, c->r[RFloat].x, c->r[RFloat].y,
|
|
|
|
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
|
|
|
c->r[RFloat].width, c->r[RFloat].height);
|
|
|
|
|
|
|
|
XGrabServer(dpy);
|
|
|
|
XGrabServer(dpy);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case ButtonRelease:
|
|
|
|
case ButtonRelease:
|
|
|
|