diff options
| author | outfoxxed <outfoxxed@outfoxxed.me> | 2024-09-06 17:06:55 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-07 01:06:55 +0100 |
| commit | 0500213086f8402ccbdb2acb4748dbc6d22e21f6 (patch) | |
| tree | ce3154cab29fd2437af4d55e53ef994c0d6a72d2 /src/managers/SeatManager.cpp | |
| parent | b0fca6eaf00a2c5061f499c76ec8d60772b6a719 (diff) | |
input: try to refocus a focusable window when seat grabs are reset (#7669)
Diffstat (limited to 'src/managers/SeatManager.cpp')
| -rw-r--r-- | src/managers/SeatManager.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/managers/SeatManager.cpp b/src/managers/SeatManager.cpp index 3e4063f4..b40d6cad 100644 --- a/src/managers/SeatManager.cpp +++ b/src/managers/SeatManager.cpp @@ -6,6 +6,7 @@ #include "../protocols/core/Compositor.hpp" #include "../Compositor.hpp" #include "../devices/IKeyboard.hpp" +#include "wlr-layer-shell-unstable-v1.hpp" #include <algorithm> #include <ranges> @@ -584,6 +585,36 @@ void CSeatManager::setGrab(SP<CSeatGrab> grab) { auto oldGrab = seatGrab; seatGrab.reset(); g_pInputManager->refocus(); + + auto currentFocus = state.keyboardFocus.lock(); + auto refocus = !currentFocus; + + SP<CWLSurface> surf; + PHLLS layer; + + if (!refocus) { + surf = CWLSurface::fromResource(currentFocus); + layer = surf->getLayer(); + } + + if (!refocus && !layer) { + auto popup = surf->getPopup(); + if (popup) { + auto parent = popup->getT1Owner(); + layer = parent->getLayer(); + } + } + + if (!refocus && layer) + refocus = layer->interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE; + + if (refocus) { + auto candidate = g_pCompositor->m_pLastWindow.lock(); + + if (candidate) + g_pCompositor->focusWindow(candidate); + } + if (oldGrab->onEnd) oldGrab->onEnd(); } |
