diff --git a/abstract_client.cpp b/abstract_client.cpp index c101c55b87..cbe5eb6a06 100644 --- a/abstract_client.cpp +++ b/abstract_client.cpp @@ -1291,4 +1291,20 @@ QSize AbstractClient::resizeIncrements() const return QSize(1, 1); } +AbstractClient::Position AbstractClient::mousePosition() const +{ + return PositionCenter; +} + +void AbstractClient::endMoveResize() +{ + setMoveResizePointerButtonDown(false); + stopDelayedMoveResize(); + if (isMoveResize()) { + finishMoveResize(false); + setMoveResizePointerMode(mousePosition()); + } + updateCursor(); +} + } diff --git a/abstract_client.h b/abstract_client.h index 0deab5b213..128c141960 100644 --- a/abstract_client.h +++ b/abstract_client.h @@ -364,6 +364,10 @@ public: void growVertical(); void shrinkVertical(); void updateMoveResize(const QPointF ¤tGlobalCursor); + /** + * Ends move resize when all pointer buttons are up again. + **/ + void endMoveResize(); void keyPressEvent(uint key_code); /** @@ -748,6 +752,11 @@ protected: virtual QSize resizeIncrements() const; + /** + * Default implementation returns PositionCenter + **/ + virtual Position mousePosition() const; + static bool haveResizeEffect() { return s_haveResizeEffect; } diff --git a/client.h b/client.h index 0bdc0e9e6c..4fbaa5ffbc 100644 --- a/client.h +++ b/client.h @@ -419,7 +419,7 @@ private: // Use Workspace::createClient() virtual ~Client(); ///< Use destroyClient() or releaseWindow() - Position mousePosition() const; + Position mousePosition() const override; // Handlers for X11 events bool mapRequestEvent(xcb_map_request_event_t *e); diff --git a/events.cpp b/events.cpp index f022b85758..b1edf6f348 100644 --- a/events.cpp +++ b/events.cpp @@ -1303,13 +1303,7 @@ bool Client::buttonReleaseEvent(xcb_window_t w, int button, int state, int x, in buttonMask &= ~XCB_BUTTON_MASK_3; if ((state & buttonMask) == 0) { - setMoveResizePointerButtonDown(false); - stopDelayedMoveResize(); - if (isMoveResize()) { - finishMoveResize(false); - setMoveResizePointerMode(mousePosition()); - } - updateCursor(); + endMoveResize(); } return true; } diff --git a/input.cpp b/input.cpp index d6214324ac..67702fce77 100644 --- a/input.cpp +++ b/input.cpp @@ -731,6 +731,14 @@ void InputRedirection::processPointerButton(uint32_t button, InputRedirection::P // an effect grabbed the pointer, we do not forward the event to surfaces return; } + if (AbstractClient *c = workspace()->getMovingClient()) { + if (state == KWin::InputRedirection::PointerButtonReleased) { + if (!areButtonsPressed()) { + c->endMoveResize(); + } + } + return; + } if (state == KWin::InputRedirection::PointerButtonPressed) { if (m_shortcuts->processPointerPressed(m_xkb->modifiers(), qtButtonStates())) { return;