From a51171720e59a47c850a34629e99cba8ac4694d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 11 Feb 2016 14:27:30 +0100 Subject: [PATCH] Improve updating the pointer position after screen changes The logic should not be tied to whether libinput is used. It's relevant for all Wayland backends whether they use libinput or not. In addition this should generate a pointer motion event, so that proper processing can take place and we get proper pointer enter events. --- autotests/wayland/pointer_input.cpp | 4 ---- input.cpp | 11 ++++++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/autotests/wayland/pointer_input.cpp b/autotests/wayland/pointer_input.cpp index 9516d7974f..cb9abeb524 100644 --- a/autotests/wayland/pointer_input.cpp +++ b/autotests/wayland/pointer_input.cpp @@ -302,15 +302,11 @@ void PointerInputTest::testUpdateFocusAfterScreenChange() QCOMPARE(screens()->count(), 1); // this should have warped the cursor - QEXPECT_FAIL("", "Doesn't work yet, requires libinput", Continue); QCOMPARE(Cursor::pos(), QPoint(639, 511)); - QEXPECT_FAIL("", "Doesn't work yet, requires libinput", Continue); QVERIFY(window->geometry().contains(Cursor::pos())); // and we should get an enter event - QEXPECT_FAIL("", "Not yet passed through", Continue); QVERIFY(enteredSpy.wait()); - QEXPECT_FAIL("", "Not yet passed through", Continue); QCOMPARE(enteredSpy.count(), 1); } diff --git a/input.cpp b/input.cpp index 0451a87e2d..53106fe6d5 100644 --- a/input.cpp +++ b/input.cpp @@ -915,6 +915,7 @@ void InputRedirection::setupWorkspace() } ); connect(workspace(), &Workspace::configChanged, this, &InputRedirection::reconfigure); + connect(screens(), &Screens::changed, this, &InputRedirection::updatePointerAfterScreenChange); connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &InputRedirection::updatePointerWindow); connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &InputRedirection::updateKeyboardWindow); @@ -1071,7 +1072,6 @@ void InputRedirection::setupLibInputWithScreens() } ); // set pos to center of all screens - connect(screens(), &Screens::changed, this, &InputRedirection::updatePointerAfterScreenChange); m_globalPointer = screens()->geometry().center(); emit globalPointerChanged(m_globalPointer); // sanitize @@ -1686,8 +1686,13 @@ void InputRedirection::updatePointerAfterScreenChange() return; } // pointer no longer on a screen, reposition to closes screen - m_globalPointer = screens()->geometry(screens()->number(m_globalPointer.toPoint())).center(); - emit globalPointerChanged(m_globalPointer); + const QPointF pos = screens()->geometry(screens()->number(m_globalPointer.toPoint())).center(); + quint32 timestamp = 0; + if (auto seat = findSeat()) { + timestamp = seat->timestamp(); + } + // TODO: better way to get timestamps + processPointerMotion(pos, timestamp); } void InputRedirection::warpPointer(const QPointF &pos)