From e7c2ea9724ef11038b14367587d9b4987708b1d1 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 8 May 2023 19:11:57 +0100 Subject: [PATCH] layershell: focus if changed keyboard mode --- src/events/Layers.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/events/Layers.cpp b/src/events/Layers.cpp index fa3e668c..56ab11ae 100644 --- a/src/events/Layers.cpp +++ b/src/events/Layers.cpp @@ -323,6 +323,20 @@ void Events::listener_commitLayerSurface(void* owner, void* data) { } } + if (layersurface->layerSurface->current.keyboard_interactive && + (!g_pCompositor->m_sSeat.mouse || !g_pCompositor->m_sSeat.mouse->currentConstraint) // don't focus if constrained + && g_pCompositor->m_pLastFocus != layersurface->layerSurface->surface) { + g_pCompositor->focusSurface(layersurface->layerSurface->surface); + + const auto LOCAL = + g_pInputManager->getMouseCoordsInternal() - Vector2D(layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y); + wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, layersurface->layerSurface->surface, LOCAL.x, LOCAL.y); + wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, 0, LOCAL.x, LOCAL.y); + } else if (!layersurface->layerSurface->current.keyboard_interactive && (!g_pCompositor->m_sSeat.mouse || !g_pCompositor->m_sSeat.mouse->currentConstraint) && + g_pCompositor->m_pLastFocus == layersurface->layerSurface->surface) { + g_pInputManager->refocus(); + } + g_pHyprRenderer->damageSurface(layersurface->layerSurface->surface, layersurface->position.x, layersurface->position.y); g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(layersurface->layerSurface->surface, PMONITOR->scale);