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.
This commit is contained in:
Maxim Andreev 2026-04-22 15:41:29 +04:00
parent 019dac7a05
commit dd75dc5dad

View file

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