summaryrefslogtreecommitdiff
path: root/src/managers/input/InputManager.cpp
diff options
context:
space:
mode:
authoroutfoxxed <outfoxxed@outfoxxed.me>2024-06-11 10:35:30 -0700
committerGitHub <noreply@github.com>2024-06-11 19:35:30 +0200
commit21b9e31bf432e3d58f408b83e7dd15b653b49494 (patch)
tree46b5615253bd1924ad3b3b37a52fb22561b4c91e /src/managers/input/InputManager.cpp
parent1c388e52fb71b116d728830f31883f0ef0e6cf17 (diff)
layershell: Fix keyboard focus grabs (#4968) (#6394)
Diffstat (limited to 'src/managers/input/InputManager.cpp')
-rw-r--r--src/managers/input/InputManager.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 5ce53472..3e412b27 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -512,7 +512,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
}
if (pFoundLayerSurface && (pFoundLayerSurface->layerSurface->current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE) && FOLLOWMOUSE != 3 &&
- allowKeyboardRefocus) {
+ (allowKeyboardRefocus || pFoundLayerSurface->layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)) {
g_pCompositor->focusSurface(foundSurface);
}
@@ -1384,6 +1384,41 @@ void CInputManager::refocus() {
mouseMoveUnified(0, true);
}
+void CInputManager::refocusLastWindow(CMonitor* pMonitor) {
+ if (!pMonitor) {
+ refocus();
+ return;
+ }
+
+ Vector2D surfaceCoords;
+ PHLLS pFoundLayerSurface;
+ SP<CWLSurfaceResource> foundSurface = nullptr;
+
+ g_pInputManager->releaseAllMouseButtons();
+
+ // first try for an exclusive layer
+ if (!m_dExclusiveLSes.empty())
+ foundSurface = m_dExclusiveLSes[m_dExclusiveLSes.size() - 1]->surface->resource();
+
+ // then any surfaces above windows on the same monitor
+ if (!foundSurface)
+ foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY],
+ &surfaceCoords, &pFoundLayerSurface);
+
+ if (!foundSurface)
+ foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP],
+ &surfaceCoords, &pFoundLayerSurface);
+
+ if (!foundSurface && g_pCompositor->m_pLastWindow.lock() && g_pCompositor->isWorkspaceVisible(g_pCompositor->m_pLastWindow->m_pWorkspace)) {
+ // then the last focused window if we're on the same workspace as it
+ const auto PLASTWINDOW = g_pCompositor->m_pLastWindow.lock();
+ g_pCompositor->focusWindow(PLASTWINDOW);
+ } else {
+ // otherwise fall back to a normal refocus.
+ refocus();
+ }
+}
+
void CInputManager::unconstrainMouse() {
if (g_pSeatManager->mouse.expired())
return;