From 40d8fa84919c6d0e9fcb1536f4bc09710d4c031c Mon Sep 17 00:00:00 2001 From: Nikolai Nechaev Date: Wed, 26 Nov 2025 07:44:26 +0900 Subject: compositor: Configurable behavior when window to be focused conflicts with fullscreen (#12033) Renames `misc:new_window_takes_over_fullscreen` into `misc:on_focus_under_fullscreen` and implements the following behavior: - By default, when a tiling window is being focused on a workspace where a fullscreen/maximized window exists, respect the `misc:on_focus_under_fullscreen` config variable. --- src/layout/IHyprLayout.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/layout/IHyprLayout.cpp') diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 18c100b7..fb47938f 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -5,6 +5,7 @@ #include "../config/ConfigValue.hpp" #include "../config/ConfigManager.hpp" #include "../desktop/Window.hpp" +#include "../desktop/state/FocusState.hpp" #include "../protocols/XDGShell.hpp" #include "../protocols/core/Compositor.hpp" #include "../xwayland/XSurface.hpp" @@ -208,8 +209,8 @@ void IHyprLayout::onWindowCreatedFloating(PHLWINDOW pWindow) { bool IHyprLayout::onWindowCreatedAutoGroup(PHLWINDOW pWindow) { static auto PAUTOGROUP = CConfigValue("group:auto_group"); - const PHLWINDOW OPENINGON = g_pCompositor->m_lastWindow.lock() && g_pCompositor->m_lastWindow->m_workspace == pWindow->m_workspace ? - g_pCompositor->m_lastWindow.lock() : + const PHLWINDOW OPENINGON = Desktop::focusState()->window() && Desktop::focusState()->window()->m_workspace == pWindow->m_workspace ? + Desktop::focusState()->window() : (pWindow->m_workspace ? pWindow->m_workspace->getFirstWindow() : nullptr); const bool FLOATEDINTOTILED = pWindow->m_isFloating && OPENINGON && !OPENINGON->m_isFloating; const bool SWALLOWING = pWindow->m_swallowed || pWindow->m_groupSwallowed; @@ -304,7 +305,7 @@ void IHyprLayout::onBeginDragWindow() { g_pKeybindManager->shadowKeybinds(); - g_pCompositor->focusWindow(DRAGGINGWINDOW); + Desktop::focusState()->rawWindowFocus(DRAGGINGWINDOW); g_pCompositor->changeWindowZOrder(DRAGGINGWINDOW, true); } @@ -394,7 +395,7 @@ void IHyprLayout::onEndDragWindow() { } g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); - g_pCompositor->focusWindow(DRAGGINGWINDOW); + Desktop::focusState()->fullWindowFocus(DRAGGINGWINDOW); g_pInputManager->m_wasDraggingWindow = false; } @@ -785,7 +786,7 @@ void IHyprLayout::changeWindowFloatingMode(PHLWINDOW pWindow) { // fix pseudo leaving artifacts g_pHyprRenderer->damageMonitor(pWindow->m_monitor.lock()); - if (pWindow == g_pCompositor->m_lastWindow) + if (pWindow == Desktop::focusState()->window()) m_lastTiledWindow = pWindow; } else { onWindowRemovedTiling(pWindow); @@ -852,7 +853,7 @@ void IHyprLayout::fitFloatingWindowOnMonitor(PHLWINDOW w, std::optional tb } void IHyprLayout::moveActiveWindow(const Vector2D& delta, PHLWINDOW pWindow) { - const auto PWINDOW = pWindow ? pWindow : g_pCompositor->m_lastWindow.lock(); + const auto PWINDOW = pWindow ? pWindow : Desktop::focusState()->window(); if (!validMapped(PWINDOW)) return; @@ -927,7 +928,7 @@ PHLWINDOW IHyprLayout::getNextWindowCandidate(PHLWINDOW pWindow) { pWindowCandidate = PWORKSPACE->getFirstWindow(); if (!pWindowCandidate || pWindow == pWindowCandidate || !pWindowCandidate->m_isMapped || pWindowCandidate->isHidden() || pWindowCandidate->m_X11ShouldntFocus || - pWindowCandidate->isX11OverrideRedirect() || pWindowCandidate->m_monitor != g_pCompositor->m_lastMonitor) + pWindowCandidate->isX11OverrideRedirect() || pWindowCandidate->m_monitor != Desktop::focusState()->monitor()) return nullptr; return pWindowCandidate; @@ -949,13 +950,13 @@ void IHyprLayout::bringWindowToTop(PHLWINDOW pWindow) { void IHyprLayout::requestFocusForWindow(PHLWINDOW pWindow) { bringWindowToTop(pWindow); - g_pCompositor->focusWindow(pWindow); + Desktop::focusState()->fullWindowFocus(pWindow); g_pCompositor->warpCursorTo(pWindow->middle()); } Vector2D IHyprLayout::predictSizeForNewWindowFloating(PHLWINDOW pWindow) { // get all rules, see if we have any size overrides. Vector2D sizeOverride = {}; - if (g_pCompositor->m_lastMonitor) { + if (Desktop::focusState()->monitor()) { // If `persistentsize` is set, use the stored size if available. const bool HASPERSISTENTSIZE = pWindow->m_ruleApplicator->persistentSize().valueOrDefault(); -- cgit v1.2.3