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.
This commit is contained in:
parent
79c274b942
commit
a51171720e
2 changed files with 8 additions and 7 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
11
input.cpp
11
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)
|
||||
|
|
Loading…
Reference in a new issue