summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2025-04-07 20:52:11 +0200
committerGitHub <noreply@github.com>2025-04-07 20:52:11 +0200
commit70ae99f52162a0ed2723d45c63adfb2e61f4e2f5 (patch)
treeb3f5f8d3b781c4606e4a2f6b812459fed54a71b5 /src
parenta8eda7f978ed367969d0de2adc836ceb268ccd54 (diff)
input/layers: Fix exclusive LS focus / refocus after unmap (#9984)
Diffstat (limited to 'src')
-rw-r--r--src/desktop/LayerSurface.cpp7
-rw-r--r--src/managers/input/InputManager.cpp26
-rw-r--r--src/managers/input/InputManager.hpp2
3 files changed, 25 insertions, 10 deletions
diff --git a/src/desktop/LayerSurface.cpp b/src/desktop/LayerSurface.cpp
index 428dcbbc..8747d079 100644
--- a/src/desktop/LayerSurface.cpp
+++ b/src/desktop/LayerSurface.cpp
@@ -234,9 +234,10 @@ void CLayerSurface::onUnmap() {
// refocus if needed
// vvvvvvvvvvvvv if there is a last focus and the last focus is not keyboard focusable, fallback to window
- if (WASLASTFOCUS || (g_pCompositor->m_pLastFocus && g_pCompositor->m_pLastFocus->hlSurface && !g_pCompositor->m_pLastFocus->hlSurface->keyboardFocusable()))
- g_pInputManager->refocusLastWindow(PMONITOR);
- else if (g_pCompositor->m_pLastFocus && g_pCompositor->m_pLastFocus != surface->resource())
+ if (WASLASTFOCUS || (g_pCompositor->m_pLastFocus && g_pCompositor->m_pLastFocus->hlSurface && !g_pCompositor->m_pLastFocus->hlSurface->keyboardFocusable())) {
+ if (!g_pInputManager->refocusLastWindow(PMONITOR))
+ g_pInputManager->refocus();
+ } else if (g_pCompositor->m_pLastFocus && g_pCompositor->m_pLastFocus != surface->resource())
g_pSeatManager->setKeyboardFocus(g_pCompositor->m_pLastFocus.lock());
CBox geomFixed = {geometry.x + PMONITOR->vecPosition.x, geometry.y + PMONITOR->vecPosition.y, geometry.width, geometry.height};
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 8ca8c21d..2153b916 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -306,6 +306,17 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) {
g_pLayoutManager->getCurrentLayout()->onMouseMove(getMouseCoordsInternal());
+ // forced above all
+ if (!g_pInputManager->m_dExclusiveLSes.empty()) {
+ if (!foundSurface)
+ foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &g_pInputManager->m_dExclusiveLSes, &surfaceCoords, &pFoundLayerSurface);
+
+ if (!foundSurface) {
+ foundSurface = (*g_pInputManager->m_dExclusiveLSes.begin())->surface->resource();
+ surfacePos = (*g_pInputManager->m_dExclusiveLSes.begin())->realPosition->goal();
+ }
+ }
+
if (!foundSurface)
foundSurface = g_pCompositor->vectorToLayerPopupSurface(mouseCoords, PMONITOR, &surfaceCoords, &pFoundLayerSurface);
@@ -1420,10 +1431,15 @@ void CInputManager::refocus() {
mouseMoveUnified(0, true);
}
-void CInputManager::refocusLastWindow(PHLMONITOR pMonitor) {
+bool CInputManager::refocusLastWindow(PHLMONITOR pMonitor) {
+ if (!m_dExclusiveLSes.empty()) {
+ Debug::log(LOG, "CInputManager::refocusLastWindow: ignoring, exclusive LS present.");
+ return false;
+ }
+
if (!pMonitor) {
refocus();
- return;
+ return true;
}
Vector2D surfaceCoords;
@@ -1432,10 +1448,6 @@ void CInputManager::refocusLastWindow(PHLMONITOR pMonitor) {
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],
@@ -1465,6 +1477,8 @@ void CInputManager::refocusLastWindow(PHLMONITOR pMonitor) {
refocus();
}
+
+ return true;
}
void CInputManager::unconstrainMouse() {
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index 7774a6db..fa06454f 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -114,7 +114,7 @@ class CInputManager {
Vector2D getMouseCoordsInternal();
void refocus();
- void refocusLastWindow(PHLMONITOR pMonitor);
+ bool refocusLastWindow(PHLMONITOR pMonitor);
void simulateMouseMovement();
void sendMotionEventsToFocused();