Border resizing by dragging.

Thanks to Axel Belinfante.
This commit is contained in:
rsc 2004-03-29 12:00:15 +00:00
parent d99b2f34e6
commit 1cb3fa8093
10 changed files with 268 additions and 45 deletions

View file

@ -78,6 +78,9 @@ mainloop(int shape_event)
case EnterNotify:
enter(&ev.xcrossing);
break;
case LeaveNotify:
leave(&ev.xcrossing);
break;
case ReparentNotify:
reparent(&ev.xreparent);
break;
@ -85,6 +88,8 @@ mainloop(int shape_event)
focusin(&ev.xfocus);
break;
case MotionNotify:
motionnotify(&ev.xmotion);
break;
case Expose:
case NoExpose:
case FocusOut:
@ -449,6 +454,16 @@ enter(XCrossingEvent *e)
}
}
void
leave(XCrossingEvent *e)
{
Client *c;
c = getclient(e->window, 0);
XUndefineCursor(dpy, c->parent);
/* XDefineCursor(dpy, c->parent, c->screen->arrow); */
}
void
focusin(XFocusChangeEvent *e)
{
@ -465,3 +480,82 @@ focusin(XFocusChangeEvent *e)
active(c);
}
}
BorderLocation
borderlocation(Client *c, int x, int y)
{
if (x <= BORDER) {
if (y <= CORNER) {
if (debug) fprintf(stderr, "topleft\n");
return BorderNW;
}
if (y >= (c->dy + 2*BORDER) - CORNER) {
if (debug) fprintf(stderr, "botleft\n");
return BorderSW;
}
if (y > CORNER &&
y < (c->dy + 2*BORDER) - CORNER) {
if (debug) fprintf(stderr, "left\n");
return BorderW;
}
} else if (x <= CORNER) {
if (y <= BORDER) {
if (debug) fprintf(stderr, "topleft\n");
return BorderNW;
}
if (y >= (c->dy + BORDER)) {
if (debug) fprintf(stderr, "botleft\n");
return BorderSW;
}
} else if (x >= (c->dx + BORDER)) {
if (y <= CORNER) {
if (debug) fprintf(stderr, "topright\n");
return BorderNE;
}
if (y >= (c->dy + 2*BORDER) - CORNER) {
if (debug) fprintf(stderr, "botright\n");
return BorderSE;
}
if (y > CORNER &&
y < (c->dy + 2*BORDER) - CORNER) {
if (debug) fprintf(stderr, "right\n");
return BorderE;
}
} else if (x >= (c->dx + 2*BORDER) - CORNER) {
if (y <= BORDER) {
if (debug) fprintf(stderr, "topright\n");
return BorderNE;
}
if (y >= (c->dy + BORDER)) {
if (debug) fprintf(stderr, "botright\n");
return BorderSE;
}
} else if (x > CORNER &&
x < (c->dx + 2*BORDER) - CORNER) {
if (y <= BORDER) {
if (debug) fprintf(stderr, "top\n");
return BorderN;
}
if (y >= (c->dy + BORDER)) {
if (debug) fprintf(stderr, "bot\n");
return BorderS;
}
}
return BorderUnknown;
}
void
motionnotify(XMotionEvent *e)
{
Client *c;
BorderLocation bl;
c = getclient(e->window, 0);
if (c) {
bl = borderlocation(c, e->x, e->y);
if (bl == BorderUnknown)
XUndefineCursor(dpy, c->parent);
else
XDefineCursor(dpy, c->parent, c->screen->bordcurs[bl]);
}
}