|
|
@ -35,14 +35,16 @@ movemouse(Client *c) {
|
|
|
|
c->ismax = False;
|
|
|
|
c->ismax = False;
|
|
|
|
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
|
|
|
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
|
|
|
for(;;) {
|
|
|
|
for(;;) {
|
|
|
|
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
|
|
|
|
XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
|
|
|
|
switch (ev.type) {
|
|
|
|
switch (ev.type) {
|
|
|
|
case ButtonRelease:
|
|
|
|
case ButtonRelease:
|
|
|
|
resize(c, True, TopLeft);
|
|
|
|
resize(c, True);
|
|
|
|
XUngrabPointer(dpy, CurrentTime);
|
|
|
|
XUngrabPointer(dpy, CurrentTime);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case ConfigureRequest:
|
|
|
|
case Expose:
|
|
|
|
case Expose:
|
|
|
|
handler[Expose](&ev);
|
|
|
|
case MapRequest:
|
|
|
|
|
|
|
|
handler[ev.type](&ev);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case MotionNotify:
|
|
|
|
case MotionNotify:
|
|
|
|
XSync(dpy, False);
|
|
|
|
XSync(dpy, False);
|
|
|
@ -50,13 +52,13 @@ movemouse(Client *c) {
|
|
|
|
c->y = ocy + (ev.xmotion.y - y1);
|
|
|
|
c->y = ocy + (ev.xmotion.y - y1);
|
|
|
|
if(abs(wax + c->x) < SNAP)
|
|
|
|
if(abs(wax + c->x) < SNAP)
|
|
|
|
c->x = wax;
|
|
|
|
c->x = wax;
|
|
|
|
else if(abs((wax + waw) - (c->x + c->w)) < SNAP)
|
|
|
|
else if(abs((wax + waw) - (c->x + c->w + 2 * c->border)) < SNAP)
|
|
|
|
c->x = wax + waw - c->w - 2 * BORDERPX;
|
|
|
|
c->x = wax + waw - c->w - 2 * c->border;
|
|
|
|
if(abs(way - c->y) < SNAP)
|
|
|
|
if(abs(way - c->y) < SNAP)
|
|
|
|
c->y = way;
|
|
|
|
c->y = way;
|
|
|
|
else if(abs((way + wah) - (c->y + c->h)) < SNAP)
|
|
|
|
else if(abs((way + wah) - (c->y + c->h + 2 * c->border)) < SNAP)
|
|
|
|
c->y = way + wah - c->h - 2 * BORDERPX;
|
|
|
|
c->y = way + wah - c->h - 2 * c->border;
|
|
|
|
resize(c, False, TopLeft);
|
|
|
|
resize(c, False);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -66,7 +68,6 @@ static void
|
|
|
|
resizemouse(Client *c) {
|
|
|
|
resizemouse(Client *c) {
|
|
|
|
int ocx, ocy;
|
|
|
|
int ocx, ocy;
|
|
|
|
int nw, nh;
|
|
|
|
int nw, nh;
|
|
|
|
Corner sticky;
|
|
|
|
|
|
|
|
XEvent ev;
|
|
|
|
XEvent ev;
|
|
|
|
|
|
|
|
|
|
|
|
ocx = c->x;
|
|
|
|
ocx = c->x;
|
|
|
@ -75,30 +76,26 @@ resizemouse(Client *c) {
|
|
|
|
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
|
|
|
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
c->ismax = False;
|
|
|
|
c->ismax = False;
|
|
|
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
|
|
|
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
|
|
|
|
for(;;) {
|
|
|
|
for(;;) {
|
|
|
|
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
|
|
|
|
XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask , &ev);
|
|
|
|
switch(ev.type) {
|
|
|
|
switch(ev.type) {
|
|
|
|
case ButtonRelease:
|
|
|
|
case ButtonRelease:
|
|
|
|
resize(c, True, TopLeft);
|
|
|
|
resize(c, True);
|
|
|
|
XUngrabPointer(dpy, CurrentTime);
|
|
|
|
XUngrabPointer(dpy, CurrentTime);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case ConfigureRequest:
|
|
|
|
case Expose:
|
|
|
|
case Expose:
|
|
|
|
handler[Expose](&ev);
|
|
|
|
case MapRequest:
|
|
|
|
|
|
|
|
handler[ev.type](&ev);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case MotionNotify:
|
|
|
|
case MotionNotify:
|
|
|
|
XSync(dpy, False);
|
|
|
|
XSync(dpy, False);
|
|
|
|
if((nw = abs(ocx - ev.xmotion.x)))
|
|
|
|
nw = ev.xmotion.x - ocx - 2 * c->border + 1;
|
|
|
|
c->w = nw;
|
|
|
|
c->w = nw > 0 ? nw : 1;
|
|
|
|
if((nh = abs(ocy - ev.xmotion.y)))
|
|
|
|
nh = ev.xmotion.y - ocy - 2 * c->border + 1;
|
|
|
|
c->h = nh;
|
|
|
|
c->h = nh > 0 ? nh : 1;
|
|
|
|
c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
|
|
|
|
resize(c, True);
|
|
|
|
c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
|
|
|
|
|
|
|
|
if(ocx <= ev.xmotion.x)
|
|
|
|
|
|
|
|
sticky = (ocy <= ev.xmotion.y) ? TopLeft : BotLeft;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
sticky = (ocy <= ev.xmotion.y) ? TopRight : BotRight;
|
|
|
|
|
|
|
|
resize(c, True, sticky);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -194,7 +191,7 @@ configurerequest(XEvent *e) {
|
|
|
|
configure(c);
|
|
|
|
configure(c);
|
|
|
|
XSync(dpy, False);
|
|
|
|
XSync(dpy, False);
|
|
|
|
if(c->isfloat) {
|
|
|
|
if(c->isfloat) {
|
|
|
|
resize(c, False, TopLeft);
|
|
|
|
resize(c, False);
|
|
|
|
if(!isvisible(c))
|
|
|
|
if(!isvisible(c))
|
|
|
|
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
|
|
|
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -234,7 +231,8 @@ enternotify(XEvent *e) {
|
|
|
|
focus(c);
|
|
|
|
focus(c);
|
|
|
|
else if(ev->window == root) {
|
|
|
|
else if(ev->window == root) {
|
|
|
|
issel = True;
|
|
|
|
issel = True;
|
|
|
|
focus(sel);
|
|
|
|
for(c = stack; c && !isvisible(c); c = c->snext);
|
|
|
|
|
|
|
|
focus(c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|