From 7e89c518237b175ecdd4df33bb4f03c2bbffb0ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 10 Jan 2017 20:29:22 +0100 Subject: [PATCH] Add workaround for touch input offset for decorated windows Summary: If a Wayland window is decorated the decoration size was not considered when passing touch points to the Wayland window. For pointer input this is considered and implemented through the input transformation matrix which KWayland::Server::SeatInterface accepts. This should also be done for Touch. Unfortunately the frameworks version for Plasma 5.9 is already tagged and done and we cannot depend on new API. Thus this change tries to workaround by calculating the proper offset through the input transformation matrix. It isn't nice but fixes the problem for now. BUG: 374778 Test Plan: Only in unit test, real test still missing Reviewers: #plasma_on_wayland, #kwin Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D4074 --- autotests/integration/touch_input_test.cpp | 3 --- touch_input.cpp | 6 ++++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/autotests/integration/touch_input_test.cpp b/autotests/integration/touch_input_test.cpp index c63643c13c..c81c1fb70e 100644 --- a/autotests/integration/touch_input_test.cpp +++ b/autotests/integration/touch_input_test.cpp @@ -161,7 +161,6 @@ void TouchInputTest::testMultipleTouchPoints() QCOMPARE(sequenceStartedSpy.count(), 1); QCOMPARE(m_touch->sequence().count(), 1); QCOMPARE(m_touch->sequence().first()->isDown(), true); - QEXPECT_FAIL("decorated", "BUG 374778", Continue); QCOMPARE(m_touch->sequence().first()->position(), QPointF(25, 25)); QCOMPARE(pointAddedSpy.count(), 0); QCOMPARE(pointMovedSpy.count(), 0); @@ -172,7 +171,6 @@ void TouchInputTest::testMultipleTouchPoints() QCOMPARE(pointAddedSpy.count(), 1); QCOMPARE(m_touch->sequence().count(), 2); QCOMPARE(m_touch->sequence().at(1)->isDown(), true); - QEXPECT_FAIL("decorated", "BUG 374778", Continue); QCOMPARE(m_touch->sequence().at(1)->position(), QPointF(-100, -100)); QCOMPARE(pointMovedSpy.count(), 0); @@ -182,7 +180,6 @@ void TouchInputTest::testMultipleTouchPoints() QCOMPARE(pointMovedSpy.count(), 1); QCOMPARE(m_touch->sequence().count(), 2); QCOMPARE(m_touch->sequence().at(1)->isDown(), true); - QEXPECT_FAIL("decorated", "BUG 374778", Continue); QCOMPARE(m_touch->sequence().at(1)->position(), QPointF(0, 0)); kwinApp()->platform()->touchUp(1, timestamp++); diff --git a/touch_input.cpp b/touch_input.cpp index 1f5894a063..c28f6c5894 100644 --- a/touch_input.cpp +++ b/touch_input.cpp @@ -102,7 +102,8 @@ void TouchInputRedirection::update(const QPointF &pos) m_windowGeometryConnection = QMetaObject::Connection(); } if (t && t->surface()) { - seat->setFocusedTouchSurface(t->surface(), t->pos()); + // FIXME: add input transformation API to KWayland::Server::SeatInterface for touch input + seat->setFocusedTouchSurface(t->surface(), -1 * t->inputTransformation().map(t->pos()) + t->pos()); m_windowGeometryConnection = connect(t, &Toplevel::geometryChanged, this, [this] { if (m_window.isNull()) { @@ -112,7 +113,8 @@ void TouchInputRedirection::update(const QPointF &pos) if (m_window.data()->surface() != seat->focusedTouchSurface()) { return; } - seat->setFocusedTouchSurfacePosition(m_window.data()->pos()); + auto t = m_window.data(); + seat->setFocusedTouchSurfacePosition(-1 * t->inputTransformation().map(t->pos()) + t->pos()); } ); } else {