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
This commit is contained in:
Xaver Hugl 2023-02-22 19:01:22 +00:00 committed by Vlad Zahorodnii
parent 4b1ef33c1e
commit 520fa3042a
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 - 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 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 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 - 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 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); 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; return;
} }
// verify that at least one screen contains the pointer position // verify that at least one screen contains the pointer position
QPointF p = pos; const Output *currentOutput = workspace()->outputAt(pos);
if (!screenContainsPos(p)) { QPointF p = confineToBoundingBox(pos, currentOutput->geometry());
const QRectF unitedScreensGeometry = workspace()->geometry();
p = confineToBoundingBox(p, unitedScreensGeometry);
if (!screenContainsPos(p)) {
const Output *currentOutput = workspace()->outputAt(m_pos);
p = confineToBoundingBox(p, currentOutput->geometry());
}
}
p = applyPointerConfinement(p); p = applyPointerConfinement(p);
if (p == m_pos) { if (p == m_pos) {
// didn't change due to confinement // didn't change due to confinement