summaryrefslogtreecommitdiff
path: root/src/events/Layers.cpp
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2022-10-25 14:19:24 +0100
committervaxerski <vaxry@vaxry.net>2022-10-25 14:19:24 +0100
commitba9a8a9ded02b5af182b0dfcb46da1769060fbba (patch)
tree99c3eb1fc09e9ac393a48aec515d2504791b5278 /src/events/Layers.cpp
parent34bd2cf803e790e6592707cbc5dfd0d3b42b86fe (diff)
unify LS unmap focus
Diffstat (limited to 'src/events/Layers.cpp')
-rw-r--r--src/events/Layers.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/events/Layers.cpp b/src/events/Layers.cpp
index dae25391..da57bb68 100644
--- a/src/events/Layers.cpp
+++ b/src/events/Layers.cpp
@@ -199,8 +199,29 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
// refocus if needed
if (layersurface->layerSurface->surface == g_pCompositor->m_pLastFocus) {
+
+ Vector2D surfaceCoords;
+ SLayerSurface* pFoundLayerSurface = nullptr;
+ wlr_surface* foundSurface = nullptr;
+
g_pCompositor->m_pLastFocus = nullptr;
- g_pInputManager->refocus();
+
+ // find LS-es to focus
+ foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &surfaceCoords, &pFoundLayerSurface);
+
+ if (!foundSurface)
+ foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords, &pFoundLayerSurface);
+
+
+ if (!foundSurface) {
+ // if there isn't any, focus the last window
+ const auto PLASTWINDOW = g_pCompositor->m_pLastWindow;
+ g_pCompositor->focusWindow(nullptr);
+ g_pCompositor->focusWindow(PLASTWINDOW);
+ } else {
+ // otherwise, full refocus
+ g_pInputManager->refocus();
+ }
}
wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width, layersurface->geometry.height};