+ default:
+ assert(false); // unhandled Corner
+ return; // unreachable, for the compiler
+ }
+
+ XGrabServer(blackbox->getXDisplay());
+ XGrabPointer(blackbox->getXDisplay(), frame.window, False,
+ PointerMotionMask | ButtonReleaseMask,
+ GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime);
+
+ flags.resizing = True;
+ blackbox->setChangingWindow(this);
+
+ unsigned int gw, gh;
+ frame.changing = frame.rect;
+
+ constrain(anchor, &gw, &gh);
+
+ XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(),
+ screen->getOpGC(), frame.changing.x(), frame.changing.y(),
+ frame.changing.width() - 1, frame.changing.height() - 1);
+
+ screen->showGeometry(gw, gh);
+
+ frame.grab_x = x_root;
+ frame.grab_y = y_root;
+}
+
+
+void BlackboxWindow::doResize(int x_root, int y_root) {
+ assert(flags.resizing);
+ assert(blackbox->getChangingWindow() == this);
+
+ XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(),
+ screen->getOpGC(), frame.changing.x(), frame.changing.y(),
+ frame.changing.width() - 1, frame.changing.height() - 1);
+
+ unsigned int gw, gh;
+ Corner anchor;
+
+ switch (resize_dir) {
+ case BottomLeft:
+ anchor = TopRight;
+ frame.changing.setSize(frame.rect.width() - (x_root - frame.grab_x),
+ frame.rect.height() + (y_root - frame.grab_y));
+ break;
+ case BottomRight:
+ anchor = TopLeft;
+ frame.changing.setSize(frame.rect.width() + (x_root - frame.grab_x),
+ frame.rect.height() + (y_root - frame.grab_y));
+ break;
+ case TopLeft:
+ anchor = BottomRight;
+ frame.changing.setSize(frame.rect.width() - (x_root - frame.grab_x),
+ frame.rect.height() - (y_root - frame.grab_y));
+ break;
+ case TopRight:
+ anchor = BottomLeft;
+ frame.changing.setSize(frame.rect.width() + (x_root - frame.grab_x),
+ frame.rect.height() - (y_root - frame.grab_y));
+ break;
+
+ default:
+ assert(false); // unhandled Corner
+ return; // unreachable, for the compiler
+ }
+
+ constrain(anchor, &gw, &gh);
+
+ XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(),
+ screen->getOpGC(), frame.changing.x(), frame.changing.y(),
+ frame.changing.width() - 1, frame.changing.height() - 1);
+
+ screen->showGeometry(gw, gh);
+}
+
+
+void BlackboxWindow::endResize(void) {
+ assert(flags.resizing);
+ assert(blackbox->getChangingWindow() == this);
+
+ XDrawRectangle(blackbox->getXDisplay(), screen->getRootWindow(),
+ screen->getOpGC(), frame.changing.x(), frame.changing.y(),
+ frame.changing.width() - 1, frame.changing.height() - 1);
+ XUngrabServer(blackbox->getXDisplay());
+
+ // unset maximized state after resized when fully maximized
+ if (flags.maximized == 1)
+ maximize(0);
+
+ flags.resizing = False;
+ blackbox->setChangingWindow(0);
+
+ configure(frame.changing.x(), frame.changing.y(),
+ frame.changing.width(), frame.changing.height());
+ screen->hideGeometry();
+
+ XUngrabPointer(blackbox->getXDisplay(), CurrentTime);
+
+ // if there are any left over motions from the resize, drop them now
+ XSync(blackbox->getXDisplay(), false); // make sure we don't miss any
+ XEvent e;
+ while (XCheckTypedWindowEvent(blackbox->getXDisplay(), frame.window,
+ MotionNotify, &e));
+}
+
+
+void BlackboxWindow::motionNotifyEvent(const XMotionEvent *me) {
+#if 0
+ fprintf(stderr, "BlackboxWindow::motionNotifyEvent() for 0x%lx\n",
+ client.window);
+#endif
+
+ if (flags.moving) {
+ doMove(me->x_root, me->y_root);
+ } else if (flags.resizing) {
+ doResize(me->x_root, me->y_root);
+ } else {
+ if ((functions & Func_Move) &&
+ (me->state & Button1Mask) &&
+ (frame.title == me->window || frame.label == me->window ||
+ frame.handle == me->window || frame.window == me->window)) {
+ beginMove(me->x_root, me->y_root);
+ } else if ((functions & Func_Resize) &&
+ ((me->state & Button1Mask) && (me->window == frame.right_grip ||
+ me->window == frame.left_grip)) ||
+ ((me->state & Button3Mask) && (me->state & mod_mask) &&
+ (frame.title == me->window || frame.label == me->window ||
+ frame.handle == me->window || frame.window == me->window))) {
+ unsigned int zones = screen->getResizeZones();
+ Corner corner;
+
+ if (me->window == frame.left_grip) {
+ corner = BottomLeft;
+ } else if (me->window == frame.right_grip || zones == 1) {
+ corner = BottomRight;