From dd75dc5dadea29588783620744431c9bcac5f7ac Mon Sep 17 00:00:00 2001 From: Maxim Andreev Date: Wed, 22 Apr 2026 15:41:29 +0400 Subject: [PATCH] input: keep pointer focus on layer surfaces during keyboard refocus Do not let sendMotionEventsToFocused() steal pointer focus from non-window surfaces such as waybar when follow_mouse is disabled. This keeps keyboard focus changes from workspace switches from moving pointer focus off the bar under the cursor, which otherwise makes workspace scrolling on waybar behave one event behind. --- src/managers/input/InputManager.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index c4df7c53b..313353a1b 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -175,6 +175,16 @@ void CInputManager::sendMotionEventsToFocused() { if (!Desktop::focusState()->surface() || isConstrained()) return; + const auto POINTERSURF = g_pSeatManager->m_state.pointerFocus.lock(); + if (POINTERSURF) { + const auto POINTERHLSURF = Desktop::View::CWLSurface::fromResource(POINTERSURF); + + // Keep pointer focus on desktop components such as bars or popups that are + // currently under the cursor. Keyboard focus changes should not steal it. + if (POINTERHLSURF && (!POINTERHLSURF->view() || POINTERHLSURF->view()->type() != Desktop::View::VIEW_TYPE_WINDOW)) + return; + } + const auto SURF = Desktop::focusState()->surface(); if (!SURF)