diff --git a/src/pointer_input.cpp b/src/pointer_input.cpp index f51493d22c..7e9e414dd5 100644 --- a/src/pointer_input.cpp +++ b/src/pointer_input.cpp @@ -553,6 +553,8 @@ void PointerInputRedirection::cleanupDecoration(Decoration::DecoratedClientImpl m_decorationDestroyedConnection = connect(now, &QObject::destroyed, this, &PointerInputRedirection::update, Qt::QueuedConnection); } +static bool s_cursorUpdateBlocking = false; + void PointerInputRedirection::focusUpdate(Toplevel *focusOld, Toplevel *focusNow) { if (AbstractClient *ac = qobject_cast(focusOld)) { @@ -573,6 +575,11 @@ void PointerInputRedirection::focusUpdate(Toplevel *focusOld, Toplevel *focusNow return; } + // prevent updating cursor and sending motion event outside the previously focused surface + s_cursorUpdateBlocking = true; + seat->setFocusedPointerSurface(nullptr); + s_cursorUpdateBlocking = false; + seat->notifyPointerMotion(m_pos.toPoint()); seat->setFocusedPointerSurface(focusNow->surface(), focusNow->inputTransformation()); @@ -1021,6 +1028,10 @@ void CursorImage::handlePointerChanged() void CursorImage::handleFocusedSurfaceChanged() { + if (s_cursorUpdateBlocking) { + return; + } + KWaylandServer::PointerInterface *pointer = waylandServer()->seat()->pointer(); disconnect(m_serverCursor.connection);