wayland: Avoid pointer warp if constraint region is invalid

It may happen that the constraint region doesn't include the specified
cursor hint anymore. If that's the case, avoid warping the pointer.

BUG: 457021
This commit is contained in:
Vlad Zahorodnii 2023-05-04 15:50:32 +03:00
parent 271d758f8c
commit 7c91c4bad9

View file

@ -669,7 +669,7 @@ void PointerInputRedirection::updatePointerConstraints()
lock->setLocked(false);
m_locked = false;
disconnectLockedPointerAboutToBeUnboundConnection();
if (!(hint.x() < 0 || hint.y() < 0) && focus()) {
if (!(hint.x() < 0 || hint.y() < 0 || !lock->region().contains(hint.toPoint())) && focus()) {
processMotionAbsolute(focus()->mapFromLocal(hint), waylandServer()->seat()->timestamp());
}
}
@ -684,7 +684,7 @@ void PointerInputRedirection::updatePointerConstraints()
// In this case the cached cursor position hint must be fetched before the resource goes away
m_lockedPointerAboutToBeUnboundConnection = connect(lock, &KWaylandServer::LockedPointerV1Interface::aboutToBeDestroyed, this, [this, lock]() {
const auto hint = lock->cursorPositionHint();
if (hint.x() < 0 || hint.y() < 0 || !focus()) {
if (hint.x() < 0 || hint.y() < 0 || !lock->region().contains(hint.toPoint()) || !focus()) {
return;
}
auto globalHint = focus()->mapFromLocal(hint);