From b9bef6955487b75d13cfedd230bdc4adafedd115 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Sat, 20 Dec 2025 22:16:13 +0000 Subject: Desktop/history: Move history to desktop (#12676) --- src/desktop/state/FocusState.cpp | 47 ++++------------------------------------ 1 file changed, 4 insertions(+), 43 deletions(-) (limited to 'src/desktop/state/FocusState.cpp') diff --git a/src/desktop/state/FocusState.cpp b/src/desktop/state/FocusState.cpp index ea869398..e6257690 100644 --- a/src/desktop/state/FocusState.cpp +++ b/src/desktop/state/FocusState.cpp @@ -16,19 +16,7 @@ SP Desktop::focusState() { return state; } -Desktop::CFocusState::CFocusState() { - m_windowOpen = g_pHookSystem->hookDynamic("openWindowEarly", [this](void* self, SCallbackInfo& info, std::any data) { - auto window = std::any_cast(data); - - addWindowToHistory(window); - }); - - m_windowClose = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any data) { - auto window = std::any_cast(data); - - removeWindowFromHistory(window); - }); -} +Desktop::CFocusState::CFocusState() = default; struct SFullscreenWorkspaceFocusResult { PHLWINDOW overrideFocusWindow = nullptr; @@ -73,7 +61,7 @@ static SFullscreenWorkspaceFocusResult onFullscreenWorkspaceFocusWindow(PHLWINDO return {}; } -void CFocusState::fullWindowFocus(PHLWINDOW pWindow, SP surface, bool preserveFocusHistory, bool forceFSCycle) { +void CFocusState::fullWindowFocus(PHLWINDOW pWindow, SP surface, bool forceFSCycle) { if (pWindow) { if (!pWindow->m_workspace) return; @@ -93,10 +81,10 @@ void CFocusState::fullWindowFocus(PHLWINDOW pWindow, SP surf return; } - rawWindowFocus(pWindow, surface, preserveFocusHistory); + rawWindowFocus(pWindow, surface); } -void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP surface, bool preserveFocusHistory) { +void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP surface) { static auto PFOLLOWMOUSE = CConfigValue("input:follow_mouse"); static auto PSPECIALFALLTHROUGH = CConfigValue("input:special_fallthrough"); @@ -164,8 +152,6 @@ void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP surfa const auto PWORKSPACE = pWindow->m_workspace; // This is to fix incorrect feedback on the focus history. PWORKSPACE->m_lastFocusedWindow = pWindow; - if (m_focusMonitor->m_activeWorkspace) - PWORKSPACE->rememberPrevWorkspace(m_focusMonitor->m_activeWorkspace); if (PWORKSPACE->m_isSpecialWorkspace) m_focusMonitor->changeWorkspace(PWORKSPACE, false, true); // if special ws, open on current monitor else if (PMONITOR) @@ -214,11 +200,6 @@ void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP surfa g_pInputManager->recheckIdleInhibitorStatus(); - if (!preserveFocusHistory) { - // move to front of the window history - moveWindowToLatestInHistory(pWindow); - } - if (*PFOLLOWMOUSE == 0) g_pInputManager->sendMotionEventsToFocused(); @@ -308,23 +289,3 @@ PHLWINDOW CFocusState::window() { PHLMONITOR CFocusState::monitor() { return m_focusMonitor.lock(); } - -const std::vector& CFocusState::windowHistory() { - return m_windowFocusHistory; -} - -void CFocusState::removeWindowFromHistory(PHLWINDOW w) { - std::erase_if(m_windowFocusHistory, [&w](const auto& e) { return !e || e == w; }); -} - -void CFocusState::addWindowToHistory(PHLWINDOW w) { - m_windowFocusHistory.emplace_back(w); -} - -void CFocusState::moveWindowToLatestInHistory(PHLWINDOW w) { - const auto HISTORYPIVOT = std::ranges::find_if(m_windowFocusHistory, [&w](const auto& other) { return other.lock() == w; }); - if (HISTORYPIVOT == m_windowFocusHistory.end()) - Log::logger->log(Log::TRACE, "CFocusState: {} has no pivot in history, ignoring request to move to latest", w); - else - std::rotate(m_windowFocusHistory.begin(), HISTORYPIVOT, HISTORYPIVOT + 1); -} -- cgit v1.2.3