Commit a23a9d38 authored by Martin Flöser's avatar Martin Flöser

Make it possible to end move/resize through mouse button release

Properly handle the mouse press/release events in InputRedirection
while we move windows. If it's the last mouse release event we end
the move resize of the window. For that we reuse the code written
in Client.
parent 7dcd69fd
......@@ -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();
}
}
......@@ -364,6 +364,10 @@ public:
void growVertical();
void shrinkVertical();
void updateMoveResize(const QPointF &currentGlobalCursor);
/**
* 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;
}
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment