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
master
Xaver Hugl 2 years ago committed by Vlad Zahorodnii
parent 4b1ef33c1e
commit 520fa3042a

@ -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);

@ -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

Loading…
Cancel
Save