From 8b3be23032385777a9981c9d408c3c9c822c267b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 3 Jun 2015 17:56:59 +0200 Subject: [PATCH] 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. --- input.cpp | 18 +++++++++++++++++- input.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/input.cpp b/input.cpp index 57ba3c1035..ab627cd008 100644 --- a/input.cpp +++ b/input.cpp @@ -465,7 +465,10 @@ void InputRedirection::processPointerMotion(const QPointF &pos, uint32_t time) return; } QWeakPointer old = m_pointerWindow; - updatePointerWindow(); + if (!areButtonsPressed()) { + // update pointer window only if no button is pressed + updatePointerWindow(); + } #if HAVE_WAYLAND if (auto seat = findSeat()) { seat->setTimestamp(time); @@ -500,6 +503,9 @@ void InputRedirection::processPointerButton(uint32_t button, InputRedirection::P state == PointerButtonPressed ? seat->pointerButtonPressed(button) : seat->pointerButtonReleased(button); } #endif + if (state == PointerButtonReleased && !areButtonsPressed()) { + updatePointerWindow(); + } } void InputRedirection::processPointerAxis(InputRedirection::PointerAxis axis, qreal delta, uint32_t time) @@ -789,6 +795,16 @@ Qt::MouseButtons InputRedirection::qtButtonStates() const 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) { if (!Workspace::self()) { diff --git a/input.h b/input.h index a29d2d9d17..2a33e10945 100644 --- a/input.h +++ b/input.h @@ -183,6 +183,7 @@ private: void updateFocusedPointerPosition(); void updateFocusedTouchPosition(); void updateTouchWindow(const QPointF &pos); + bool areButtonsPressed() const; QPointF m_globalPointer; QHash m_pointerButtons; #if HAVE_XKB