From 723870337f299d4c80aa0048144f3a1ca1c885bd Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Sat, 21 Feb 2026 21:30:39 +0000 Subject: layout: rethonk layouts from the ground up (#12890) Rewrites layouts to be much smaller, and deal with much less annoying BS. Improves the overall architecture, unifies handling of pseudotiling, and various other improvements. --- src/desktop/state/FocusState.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src/desktop/state/FocusState.cpp') diff --git a/src/desktop/state/FocusState.cpp b/src/desktop/state/FocusState.cpp index 0712fc10..90524b74 100644 --- a/src/desktop/state/FocusState.cpp +++ b/src/desktop/state/FocusState.cpp @@ -3,15 +3,19 @@ #include "../../Compositor.hpp" #include "../../protocols/XDGShell.hpp" #include "../../render/Renderer.hpp" -#include "../../managers/LayoutManager.hpp" #include "../../managers/EventManager.hpp" #include "../../managers/HookSystemManager.hpp" +#include "../../managers/input/InputManager.hpp" +#include "../../managers/SeatManager.hpp" #include "../../xwayland/XSurface.hpp" #include "../../protocols/PointerConstraints.hpp" #include "managers/animation/DesktopAnimationManager.hpp" +#include "../../layout/LayoutManager.hpp" using namespace Desktop; +#define COMMA , + SP Desktop::focusState() { static SP state = makeShared(); return state; @@ -63,7 +67,7 @@ static SFullscreenWorkspaceFocusResult onFullscreenWorkspaceFocusWindow(PHLWINDO return {}; } -void CFocusState::fullWindowFocus(PHLWINDOW pWindow, SP surface, bool forceFSCycle) { +void CFocusState::fullWindowFocus(PHLWINDOW pWindow, eFocusReason reason, SP surface, bool forceFSCycle) { if (pWindow) { if (!pWindow->m_workspace) return; @@ -83,10 +87,10 @@ void CFocusState::fullWindowFocus(PHLWINDOW pWindow, SP surf return; } - rawWindowFocus(pWindow, surface); + rawWindowFocus(pWindow, reason, surface); } -void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP surface) { +void CFocusState::rawWindowFocus(PHLWINDOW pWindow, eFocusReason reason, SP surface) { static auto PFOLLOWMOUSE = CConfigValue("input:follow_mouse"); static auto PSPECIALFALLTHROUGH = CConfigValue("input:special_fallthrough"); @@ -105,7 +109,9 @@ void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP surfa if (pWindow && pWindow->m_isX11 && pWindow->isX11OverrideRedirect() && !pWindow->m_xwaylandSurface->wantsFocus()) return; - g_pLayoutManager->getCurrentLayout()->bringWindowToTop(pWindow); + // m_target on purpose, this avoids the group + if (pWindow) + g_layoutManager->bringTargetToTop(pWindow->m_target); if (!pWindow || !validMapped(pWindow)) { @@ -127,9 +133,7 @@ void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP surfa g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", ","}); g_pEventManager->postEvent(SHyprIPCEvent{"activewindowv2", ""}); - EMIT_HOOK_EVENT("activeWindow", PHLWINDOW{nullptr}); - - g_pLayoutManager->getCurrentLayout()->onWindowFocusChange(nullptr); + EMIT_HOOK_EVENT("activeWindow", Desktop::View::SWindowActiveEvent{nullptr COMMA reason}); m_focusSurface.reset(); @@ -196,16 +200,14 @@ void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP surfa g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindow", .data = pWindow->m_class + "," + pWindow->m_title}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindowv2", .data = std::format("{:x}", rc(pWindow.get()))}); - EMIT_HOOK_EVENT("activeWindow", pWindow); - - g_pLayoutManager->getCurrentLayout()->onWindowFocusChange(pWindow); + EMIT_HOOK_EVENT("activeWindow", Desktop::View::SWindowActiveEvent{pWindow COMMA reason}); g_pInputManager->recheckIdleInhibitorStatus(); if (*PFOLLOWMOUSE == 0) g_pInputManager->sendMotionEventsToFocused(); - if (pWindow->m_groupData.pNextWindow) + if (pWindow->m_group) pWindow->deactivateGroupMembers(); } @@ -296,3 +298,7 @@ void CFocusState::resetWindowFocus() { m_focusWindow.reset(); m_focusSurface.reset(); } + +bool Desktop::isHardInputFocusReason(eFocusReason r) { + return r == FOCUS_REASON_NEW_WINDOW || r == FOCUS_REASON_KEYBIND || r == FOCUS_REASON_GHOSTS || r == FOCUS_REASON_CLICK || r == FOCUS_REASON_DESKTOP_STATE_CHANGE; +} -- cgit v1.2.3