From d19690ce984acc566754c79148b6b1ab1a5702af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 29 Apr 2016 15:08:22 +0200 Subject: [PATCH] Honor input mask set on internal windows Summary: This ensures that QWindow::setMask works for KWin internal windows. Without KWin sends all pointer events to the QWindow, even if the mask says it shouldn't get events. Reviewers: #plasma Subscribers: plasma-devel Projects: #plasma Differential Revision: https://phabricator.kde.org/D1509 --- autotests/wayland/internal_window.cpp | 10 ++++++++++ pointer_input.cpp | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/autotests/wayland/internal_window.cpp b/autotests/wayland/internal_window.cpp index f252b9a580..4085f8a675 100644 --- a/autotests/wayland/internal_window.cpp +++ b/autotests/wayland/internal_window.cpp @@ -191,6 +191,16 @@ void InternalWindowTest::testEnterLeave() kwinApp()->platform()->pointerMotion(QPoint(101, 50), timestamp++); QTRY_COMPARE(leaveSpy.count(), 1); + + // set a mask on the window + win.setMask(QRegion(10, 20, 30, 40)); + // outside the mask we should not get an enter + kwinApp()->platform()->pointerMotion(QPoint(5, 5), timestamp++); + QVERIFY(!enterSpy.wait(100)); + QCOMPARE(enterSpy.count(), 1); + // inside the mask we should still get an enter + kwinApp()->platform()->pointerMotion(QPoint(25, 27), timestamp++); + QTRY_COMPARE(enterSpy.count(), 2); } void InternalWindowTest::testPointerPressRelease() diff --git a/pointer_input.cpp b/pointer_input.cpp index 1c5b92eb37..b92ce3110f 100644 --- a/pointer_input.cpp +++ b/pointer_input.cpp @@ -314,6 +314,11 @@ void PointerInputRedirection::updateInternalWindow() continue; } if (w->geometry().contains(m_pos.toPoint())) { + // check input mask + const QRegion mask = w->mask().translated(w->geometry().topLeft()); + if (!mask.isEmpty() && !mask.contains(m_pos.toPoint())) { + continue; + } m_internalWindow = QPointer(w); found = true; break;