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.
This commit is contained in:
Martin Gräßlin 2015-10-28 10:43:49 +01:00
parent 7dcd69fdcc
commit a23a9d38f9
5 changed files with 35 additions and 8 deletions

View file

@ -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();
}
}

View file

@ -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;
}

View file

@ -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);

View file

@ -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;
}

View file

@ -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;