diff options
| author | CyrenArkade <cyrenarkade@gmail.com> | 2025-05-05 20:54:27 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-06 03:54:27 +0200 |
| commit | 1ce614dfc0eb8b323e603b76975842c1f2e6a553 (patch) | |
| tree | b4a05c13b57c8faaaaf2c15cd10eb289548043dc /src/helpers/Monitor.cpp | |
| parent | 930eeac900c60d147bf26491e15b0727605b3944 (diff) | |
animations: Add option for animating workspaces as if the first and last were adjacent (#10277)
* add option for animating workspaces as if the first and last were adjacent
* change wraparound detection to use IDs instead of dispatcher
* move shouldWraparound from MiscFunctions to Monitor
Diffstat (limited to 'src/helpers/Monitor.cpp')
| -rw-r--r-- | src/helpers/Monitor.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 3cbfbf46..4dc0942d 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -1100,6 +1100,25 @@ float CMonitor::getDefaultScale() { return 1; } +static bool shouldWraparound(const WORKSPACEID id1, const WORKSPACEID id2) { + static auto PWORKSPACEWRAPAROUND = CConfigValue<Hyprlang::INT>("animations:workspace_wraparound"); + + if (!*PWORKSPACEWRAPAROUND) + return false; + + WORKSPACEID lowestID = INT64_MAX; + WORKSPACEID highestID = INT64_MIN; + + for (auto const& w : g_pCompositor->m_workspaces) { + if (w->m_id < 0 || w->m_isSpecialWorkspace) + continue; + lowestID = std::min(w->m_id, lowestID); + highestID = std::max(w->m_id, highestID); + } + + return std::min(id1, id2) == lowestID && std::max(id1, id2) == highestID; +} + void CMonitor::changeWorkspace(const PHLWORKSPACE& pWorkspace, bool internal, bool noMouseMove, bool noFocus) { if (!pWorkspace) return; @@ -1123,7 +1142,7 @@ void CMonitor::changeWorkspace(const PHLWORKSPACE& pWorkspace, bool internal, bo m_activeWorkspace = pWorkspace; if (!internal) { - const auto ANIMTOLEFT = POLDWORKSPACE && pWorkspace->m_id > POLDWORKSPACE->m_id; + const auto ANIMTOLEFT = POLDWORKSPACE && (shouldWraparound(pWorkspace->m_id, POLDWORKSPACE->m_id) ^ (pWorkspace->m_id > POLDWORKSPACE->m_id)); if (POLDWORKSPACE) POLDWORKSPACE->startAnim(false, ANIMTOLEFT); pWorkspace->startAnim(true, ANIMTOLEFT); |
