Don't update focused pointer window on pointer movement while button is pressed

If a button is pressed all mouse events should go to the current surface
regardless of whether the pointer is on top of it or not.
This commit is contained in:
Martin Gräßlin 2015-06-03 17:56:59 +02:00
parent 8468da197c
commit 8b3be23032
2 changed files with 18 additions and 1 deletions

View file

@ -465,7 +465,10 @@ void InputRedirection::processPointerMotion(const QPointF &pos, uint32_t time)
return; return;
} }
QWeakPointer<Toplevel> old = m_pointerWindow; QWeakPointer<Toplevel> old = m_pointerWindow;
updatePointerWindow(); if (!areButtonsPressed()) {
// update pointer window only if no button is pressed
updatePointerWindow();
}
#if HAVE_WAYLAND #if HAVE_WAYLAND
if (auto seat = findSeat()) { if (auto seat = findSeat()) {
seat->setTimestamp(time); seat->setTimestamp(time);
@ -500,6 +503,9 @@ void InputRedirection::processPointerButton(uint32_t button, InputRedirection::P
state == PointerButtonPressed ? seat->pointerButtonPressed(button) : seat->pointerButtonReleased(button); state == PointerButtonPressed ? seat->pointerButtonPressed(button) : seat->pointerButtonReleased(button);
} }
#endif #endif
if (state == PointerButtonReleased && !areButtonsPressed()) {
updatePointerWindow();
}
} }
void InputRedirection::processPointerAxis(InputRedirection::PointerAxis axis, qreal delta, uint32_t time) void InputRedirection::processPointerAxis(InputRedirection::PointerAxis axis, qreal delta, uint32_t time)
@ -789,6 +795,16 @@ Qt::MouseButtons InputRedirection::qtButtonStates() const
return buttons; return buttons;
} }
bool InputRedirection::areButtonsPressed() const
{
for (auto it = m_pointerButtons.constBegin(); it != m_pointerButtons.constEnd(); ++it) {
if (it.value() == KWin::InputRedirection::PointerButtonPressed) {
return true;
}
}
return false;
}
Toplevel *InputRedirection::findToplevel(const QPoint &pos) Toplevel *InputRedirection::findToplevel(const QPoint &pos)
{ {
if (!Workspace::self()) { if (!Workspace::self()) {

View file

@ -183,6 +183,7 @@ private:
void updateFocusedPointerPosition(); void updateFocusedPointerPosition();
void updateFocusedTouchPosition(); void updateFocusedTouchPosition();
void updateTouchWindow(const QPointF &pos); void updateTouchWindow(const QPointF &pos);
bool areButtonsPressed() const;
QPointF m_globalPointer; QPointF m_globalPointer;
QHash<uint32_t, PointerButtonState> m_pointerButtons; QHash<uint32_t, PointerButtonState> m_pointerButtons;
#if HAVE_XKB #if HAVE_XKB