diff --git a/src/events.cpp b/src/events.cpp index 93d0f532ba..87eafa4ed1 100644 --- a/src/events.cpp +++ b/src/events.cpp @@ -1184,9 +1184,23 @@ bool X11Window::motionNotifyEvent(xcb_window_t w, int state, int x, int y, int x y = this->y(); } - handleInteractiveMoveResize(QPoint(x, y), QPoint(x_root, y_root)); - if (isInteractiveMove()) { - workspace()->screenEdges()->check(QPoint(x_root, y_root), QDateTime::fromMSecsSinceEpoch(xTime(), Qt::UTC)); + if (!isInteractiveMoveResize()) { + const QPointF offset(interactiveMoveOffset().x() * width(), interactiveMoveOffset().y() * height()); + const QPointF delta(QPointF(x, y) - offset); + if (delta.manhattanLength() >= QApplication::startDragDistance()) { + if (startInteractiveMoveResize()) { + updateInteractiveMoveResize(QPointF(x_root, y_root)); + } else { + setInteractiveMoveResizePointerButtonDown(false); + } + updateCursor(); + } + } else { + updateInteractiveMoveResize(QPointF(x_root, y_root)); + + if (isInteractiveMove()) { + workspace()->screenEdges()->check(QPoint(x_root, y_root), QDateTime::fromMSecsSinceEpoch(xTime(), Qt::UTC)); + } } return true; diff --git a/src/window.cpp b/src/window.cpp index f088bb4f7a..5df971c2fa 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1190,6 +1190,10 @@ bool Window::startInteractiveMoveResize() if (isRequestedFullScreen() && (workspace()->outputs().count() < 2 || !isMovableAcrossScreens())) { return false; } + if ((interactiveMoveResizeGravity() == Gravity::None && !isMovableAcrossScreens()) + || (interactiveMoveResizeGravity() != Gravity::None && (isShade() || !isResizable()))) { + return false; + } if (!doStartInteractiveMoveResize()) { return false; } @@ -1371,37 +1375,12 @@ void Window::stopDelayedInteractiveMoveResize() m_interactiveMoveResize.delayedTimer = nullptr; } -void Window::updateInteractiveMoveResize(const QPointF ¤tGlobalCursor) -{ - handleInteractiveMoveResize(pos(), currentGlobalCursor); -} - -void Window::handleInteractiveMoveResize(const QPointF &local, const QPointF &global) +void Window::updateInteractiveMoveResize(const QPointF &global) { setInteractiveMoveResizeAnchor(global); - const Gravity gravity = interactiveMoveResizeGravity(); - if ((gravity == Gravity::None && !isMovableAcrossScreens()) - || (gravity != Gravity::None && (isShade() || !isResizable()))) { - return; - } - - if (!isInteractiveMoveResize()) { - const QPointF offset(interactiveMoveOffset().x() * width(), interactiveMoveOffset().y() * height()); - const QPointF p(local - offset); - if (p.manhattanLength() >= QApplication::startDragDistance()) { - if (!startInteractiveMoveResize()) { - setInteractiveMoveResizePointerButtonDown(false); - updateCursor(); - return; - } - updateCursor(); - } else { - return; - } - } - // ShadeHover or ShadeActive, ShadeNormal was already avoided above + const Gravity gravity = interactiveMoveResizeGravity(); if (gravity != Gravity::None && shadeMode() != ShadeNone) { setShade(ShadeNone); } @@ -2730,9 +2709,21 @@ void Window::layoutDecorationRects(QRectF &left, QRectF &top, QRectF &right, QRe void Window::processDecorationMove(const QPointF &localPos, const QPointF &globalPos) { if (isInteractiveMoveResizePointerButtonDown()) { - handleInteractiveMoveResize(localPos, globalPos); + if (!isInteractiveMoveResize()) { + const QPointF offset(interactiveMoveOffset().x() * width(), interactiveMoveOffset().y() * height()); + const QPointF delta(localPos - offset); + if (delta.manhattanLength() >= QApplication::startDragDistance()) { + if (startInteractiveMoveResize()) { + updateInteractiveMoveResize(globalPos); + } else { + setInteractiveMoveResizePointerButtonDown(false); + } + updateCursor(); + } + } return; } + // TODO: handle modifiers Gravity newGravity = mouseGravity(); if (newGravity != interactiveMoveResizeGravity()) { diff --git a/src/window.h b/src/window.h index 59cb338207..ed62695394 100644 --- a/src/window.h +++ b/src/window.h @@ -1128,7 +1128,7 @@ public: } uint32_t interactiveMoveResizeCount() const; - void updateInteractiveMoveResize(const QPointF ¤tGlobalCursor); + void updateInteractiveMoveResize(const QPointF &global); /** * Ends move resize when all pointer buttons are up again. */ @@ -1682,7 +1682,6 @@ protected: * Default implementation does nothing. */ virtual void doInteractiveResizeSync(const QRectF &rect); - void handleInteractiveMoveResize(const QPointF &local, const QPointF &global); QRectF titleBarRect(const QRectF &rect, bool &transposed, int &requiredPixels) const; QRectF nextInteractiveMoveGeometry(const QPointF &global) const; QRectF nextInteractiveResizeGeometry(const QPointF &global) const;