pointer input: always confine pointer to screens

Checking if the pointer needs to be confined before doing `std::clamp` on
the position is useless and causes problems. With this change, the pointer
will always be confined to exactly the screen, without any fractional offsets.

BUG: 461911


(cherry picked from commit 520fa3042a9877379870af7b300fab7c669d7e7e)
icc-effect-5.27.2
Xaver Hugl 2023-02-22 19:01:22 +00:00 committed by Vlad Zahorodnii
parent 7ea6506d61
commit 5abb038a3c
2 changed files with 4 additions and 11 deletions

View File

@ -1520,9 +1520,9 @@ void PointerInputTest::testConfineToScreenGeometry_data()
QTest::newRow("move top - top screen") << QPoint(1920, 512) << QPoint(1920, -100) << QPoint(1920, 0);
QTest::newRow("move top-right - top screen") << QPoint(1920, 512) << QPoint(2660, -100) << QPoint(2660, 0);
QTest::newRow("move right - top screen") << QPoint(1920, 512) << QPoint(2660, 512) << QPoint(2660, 512);
QTest::newRow("move bottom-right - top screen") << QPoint(1920, 512) << QPoint(2660, 1124) << QPoint(2559, 1023);
QTest::newRow("move bottom-right - top screen") << QPoint(1920, 512) << QPoint(2660, 1124) << QPoint(2660, 1023);
QTest::newRow("move bottom - top screen") << QPoint(1920, 512) << QPoint(1920, 1124) << QPoint(1920, 1124);
QTest::newRow("move bottom-left - top screen") << QPoint(1920, 512) << QPoint(1180, 1124) << QPoint(1280, 1023);
QTest::newRow("move bottom-left - top screen") << QPoint(1920, 512) << QPoint(1180, 1124) << QPoint(1180, 1023);
QTest::newRow("move left - top screen") << QPoint(1920, 512) << QPoint(1180, 512) << QPoint(1180, 512);
QTest::newRow("move top-left - right screen") << QPoint(3200, 512) << QPoint(2460, -100) << QPoint(2460, 0);

View File

@ -745,15 +745,8 @@ void PointerInputRedirection::updatePosition(const QPointF &pos)
return;
}
// verify that at least one screen contains the pointer position
QPointF p = pos;
if (!screenContainsPos(p)) {
const QRectF unitedScreensGeometry = workspace()->geometry();
p = confineToBoundingBox(p, unitedScreensGeometry);
if (!screenContainsPos(p)) {
const Output *currentOutput = workspace()->outputAt(m_pos);
p = confineToBoundingBox(p, currentOutput->geometry());
}
}
const Output *currentOutput = workspace()->outputAt(pos);
QPointF p = confineToBoundingBox(pos, currentOutput->geometry());
p = applyPointerConfinement(p);
if (p == m_pos) {
// didn't change due to confinement