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/Compositor.cpp | |
| parent | 70f54a1e1ba3478a56faf82431b2770bd727431d (diff) | |
Desktop/history: Move history to desktop (#12676)
Diffstat (limited to 'src/Compositor.cpp')
| -rw-r--r-- | src/Compositor.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 7b5e0324..9c806fdd 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -5,6 +5,8 @@ #include "debug/log/Logger.hpp" #include "desktop/DesktopTypes.hpp" #include "desktop/state/FocusState.hpp" +#include "desktop/history/WindowHistoryTracker.hpp" +#include "desktop/history/WorkspaceHistoryTracker.hpp" #include "helpers/Splashes.hpp" #include "config/ConfigValue.hpp" #include "config/ConfigWatcher.hpp" @@ -661,6 +663,11 @@ void CCompositor::initManagers(eManagersInitStage stage) { Log::logger->log(Log::DEBUG, "Creating the SeatManager!"); g_pSeatManager = makeUnique<CSeatManager>(); + + // init focus state els + Desktop::History::windowTracker(); + Desktop::History::workspaceTracker(); + } break; case STAGE_LATE: { Log::logger->log(Log::DEBUG, "Creating CHyprCtl"); @@ -1447,16 +1454,14 @@ PHLWINDOW CCompositor::getWindowInDirection(const CBox& box, PHLWORKSPACE pWorks // get idx int windowIDX = -1; - const auto& HISTORY = Desktop::focusState()->windowHistory(); - for (size_t i = 0; i < HISTORY.size(); ++i) { + const auto& HISTORY = Desktop::History::windowTracker()->fullHistory(); + for (int64_t i = HISTORY.size() - 1; i >= 0; --i) { if (HISTORY[i] == w) { windowIDX = i; break; } } - windowIDX = Desktop::focusState()->windowHistory().size() - windowIDX; - if (windowIDX > leaderValue) { leaderValue = windowIDX; leaderWindow = w; @@ -1560,10 +1565,9 @@ static PHLWINDOW getWeakWindowPred(Iterator cur, Iterator end, Iterator begin, c PHLWINDOW CCompositor::getWindowCycleHist(PHLWINDOWREF cur, bool focusableOnly, std::optional<bool> floating, bool visible, bool next) { const auto FINDER = [&](const PHLWINDOWREF& w) { return isWindowAvailableForCycle(cur, w, focusableOnly, floating, visible); }; // also m_vWindowFocusHistory has reverse order, so when it is next - we need to reverse again - return next ? getWeakWindowPred(std::ranges::find(Desktop::focusState()->windowHistory() | std::views::reverse, cur), Desktop::focusState()->windowHistory().rend(), - Desktop::focusState()->windowHistory().rbegin(), FINDER) : - getWeakWindowPred(std::ranges::find(Desktop::focusState()->windowHistory(), cur), Desktop::focusState()->windowHistory().end(), - Desktop::focusState()->windowHistory().begin(), FINDER); + const auto& HISTORY = Desktop::History::windowTracker()->fullHistory(); + return next ? getWeakWindowPred(std::ranges::find(HISTORY, cur), HISTORY.end(), HISTORY.begin(), FINDER) : + getWeakWindowPred(std::ranges::find(HISTORY | std::views::reverse, cur), HISTORY.rend(), HISTORY.rbegin(), FINDER); } PHLWINDOW CCompositor::getWindowCycle(PHLWINDOW cur, bool focusableOnly, std::optional<bool> floating, bool visible, bool prev) { @@ -1808,9 +1812,6 @@ void CCompositor::swapActiveWorkspaces(PHLMONITOR pMonitorA, PHLMONITOR pMonitor pMonitorA->m_activeWorkspace = PWORKSPACEB; pMonitorB->m_activeWorkspace = PWORKSPACEA; - PWORKSPACEA->rememberPrevWorkspace(PWORKSPACEB); - PWORKSPACEB->rememberPrevWorkspace(PWORKSPACEA); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitorA->m_id); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitorB->m_id); |
