diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2025-12-20 22:16:13 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-20 22:16:13 +0000 |
| commit | b9bef6955487b75d13cfedd230bdc4adafedd115 (patch) | |
| tree | 21400bb6bbb37651ad8e2f3338d2fa5e317b4098 /src/desktop/state/FocusState.cpp | |
| parent | 70f54a1e1ba3478a56faf82431b2770bd727431d (diff) | |
Desktop/history: Move history to desktop (#12676)
Diffstat (limited to 'src/desktop/state/FocusState.cpp')
| -rw-r--r-- | src/desktop/state/FocusState.cpp | 47 |
1 files changed, 4 insertions, 43 deletions
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<CFocusState> 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<PHLWINDOW>(data); - - addWindowToHistory(window); - }); - - m_windowClose = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any data) { - auto window = std::any_cast<PHLWINDOW>(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<CWLSurfaceResource> surface, bool preserveFocusHistory, bool forceFSCycle) { +void CFocusState::fullWindowFocus(PHLWINDOW pWindow, SP<CWLSurfaceResource> surface, bool forceFSCycle) { if (pWindow) { if (!pWindow->m_workspace) return; @@ -93,10 +81,10 @@ void CFocusState::fullWindowFocus(PHLWINDOW pWindow, SP<CWLSurfaceResource> surf return; } - rawWindowFocus(pWindow, surface, preserveFocusHistory); + rawWindowFocus(pWindow, surface); } -void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP<CWLSurfaceResource> surface, bool preserveFocusHistory) { +void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP<CWLSurfaceResource> surface) { static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse"); static auto PSPECIALFALLTHROUGH = CConfigValue<Hyprlang::INT>("input:special_fallthrough"); @@ -164,8 +152,6 @@ void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP<CWLSurfaceResource> 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<CWLSurfaceResource> 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<PHLWINDOWREF>& 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); -} |
