aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2024-07-27 15:03:52 +0200
committervaxerski <[email protected]>2024-07-27 15:04:03 +0200
commit963816b9a6524a99a6716fa1aa30b2c4f369d2f0 (patch)
tree84cc5b6e4a92e22070343a3d87628891dbbb3e89
parent534fdb5a375b65821adce3fec5d1622fc546b8b4 (diff)
downloadHyprland-963816b9a6524a99a6716fa1aa30b2c4f369d2f0.tar.gz
Hyprland-963816b9a6524a99a6716fa1aa30b2c4f369d2f0.zip
layersurface: fixup focus issues in onUnmap
fixes #6929
-rw-r--r--src/desktop/LayerSurface.cpp5
-rw-r--r--src/desktop/WLSurface.cpp9
-rw-r--r--src/desktop/WLSurface.hpp1
3 files changed, 14 insertions, 1 deletions
diff --git a/src/desktop/LayerSurface.cpp b/src/desktop/LayerSurface.cpp
index 83b0992f..2252adca 100644
--- a/src/desktop/LayerSurface.cpp
+++ b/src/desktop/LayerSurface.cpp
@@ -212,8 +212,11 @@ void CLayerSurface::onUnmap() {
return;
// refocus if needed
- if (WASLASTFOCUS)
+ // 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->keyboardFocusable()))
g_pInputManager->refocusLastWindow(PMONITOR);
+ else if (g_pCompositor->m_pLastFocus)
+ g_pSeatManager->setKeyboardFocus(g_pCompositor->m_pLastFocus.lock());
CBox geomFixed = {geometry.x + PMONITOR->vecPosition.x, geometry.y + PMONITOR->vecPosition.y, geometry.width, geometry.height};
g_pHyprRenderer->damageBox(&geomFixed);
diff --git a/src/desktop/WLSurface.cpp b/src/desktop/WLSurface.cpp
index 90924145..e1348a90 100644
--- a/src/desktop/WLSurface.cpp
+++ b/src/desktop/WLSurface.cpp
@@ -1,6 +1,7 @@
#include "WLSurface.hpp"
#include "../Compositor.hpp"
#include "../protocols/core/Compositor.hpp"
+#include "../protocols/LayerShell.hpp"
void CWLSurface::assign(SP<CWLSurfaceResource> pSurface) {
m_pResource = pSurface;
@@ -222,3 +223,11 @@ SP<CWLSurface> CWLSurface::fromResource(SP<CWLSurfaceResource> pSurface) {
return nullptr;
return pSurface->hlSurface.lock();
}
+
+bool CWLSurface::keyboardFocusable() const {
+ if (m_pWindowOwner || m_pPopupOwner || m_pSubsurfaceOwner)
+ return true;
+ if (m_pLayerOwner)
+ return m_pLayerOwner->layerSurface->current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE;
+ return false;
+}
diff --git a/src/desktop/WLSurface.hpp b/src/desktop/WLSurface.hpp
index bb476e0f..a962b882 100644
--- a/src/desktop/WLSurface.hpp
+++ b/src/desktop/WLSurface.hpp
@@ -39,6 +39,7 @@ class CWLSurface {
Vector2D getViewporterCorrectedSize() const;
CRegion computeDamage() const; // logical coordinates. May be wrong if the surface is unassigned
bool visible();
+ bool keyboardFocusable() const;
// getters for owners.
PHLWINDOW getWindow() const;