diff options
| author | ItsOhen <TNordfeldt@gmail.com> | 2026-03-13 22:50:34 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-13 16:50:34 -0500 |
| commit | de3471b3356280e692109cea81e426b7222a8aea (patch) | |
| tree | c7b454165cd9b198728958623849c32ff58634b3 /src | |
| parent | 2877ca2933a2f6e11512479b18e5d418b3e23da3 (diff) | |
config/workspacerule: add animation style (#13380)
Diffstat (limited to 'src')
| -rw-r--r-- | src/config/ConfigManager.cpp | 6 | ||||
| -rw-r--r-- | src/config/ConfigManager.hpp | 1 | ||||
| -rw-r--r-- | src/desktop/Workspace.cpp | 2 | ||||
| -rw-r--r-- | src/desktop/Workspace.hpp | 7 | ||||
| -rw-r--r-- | src/helpers/Monitor.cpp | 6 | ||||
| -rw-r--r-- | src/managers/animation/DesktopAnimationManager.cpp | 8 | ||||
| -rw-r--r-- | src/managers/animation/DesktopAnimationManager.hpp | 3 |
7 files changed, 23 insertions, 10 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index e4632bb9..93edfe23 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -1681,6 +1681,8 @@ SWorkspaceRule CConfigManager::mergeWorkspaceRules(const SWorkspaceRule& rule1, mergedRule.layoutopts[layoutopt.first] = layoutopt.second; } } + if (rule2.animationStyle.has_value()) + mergedRule.animationStyle = rule2.animationStyle; return mergedRule; } @@ -1921,7 +1923,6 @@ PHLMONITOR CConfigManager::getBoundMonitorForWS(const std::string& wsname) { std::string CConfigManager::getBoundMonitorStringForWS(const std::string& wsname) { for (auto const& wr : m_workspaceRules) { const auto WSNAME = wr.workspaceName.starts_with("name:") ? wr.workspaceName.substr(5) : wr.workspaceName; - if (WSNAME == wsname) return wr.monitor; } @@ -2774,6 +2775,9 @@ std::optional<std::string> CConfigManager::handleWorkspaceRules(const std::strin } else if ((delim = rule.find("layout:")) != std::string::npos) { std::string layout = rule.substr(delim + 7); wsRule.layout = std::move(layout); + } else if ((delim = rule.find("animation:")) != std::string::npos) { + std::string animationStyle = rule.substr(delim + 10); + wsRule.animationStyle = std::move(animationStyle); } return {}; diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 36e25f6b..6a9f6d60 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -48,6 +48,7 @@ struct SWorkspaceRule { std::optional<std::string> defaultName; std::optional<std::string> layout; std::map<std::string, std::string> layoutopts; + std::optional<std::string> animationStyle; }; struct SPluginKeyword { diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp index 5df3f087..7676060a 100644 --- a/src/desktop/Workspace.cpp +++ b/src/desktop/Workspace.cpp @@ -36,6 +36,8 @@ void CWorkspace::init(PHLWORKSPACE self) { const auto RULEFORTHIS = g_pConfigManager->getWorkspaceRuleFor(self); if (RULEFORTHIS.defaultName.has_value()) m_name = RULEFORTHIS.defaultName.value(); + if (RULEFORTHIS.animationStyle.has_value()) + m_animationStyle = RULEFORTHIS.animationStyle.value(); m_focusedWindowHook = Event::bus()->m_events.window.close.listen([this](PHLWINDOW pWindow) { if (pWindow == m_lastFocusedWindow.lock()) diff --git a/src/desktop/Workspace.hpp b/src/desktop/Workspace.hpp index 87d1c2d8..81af38cd 100644 --- a/src/desktop/Workspace.hpp +++ b/src/desktop/Workspace.hpp @@ -40,9 +40,10 @@ class CWorkspace { wl_array m_wlrCoordinateArr; // for animations - PHLANIMVAR<Vector2D> m_renderOffset; - PHLANIMVAR<float> m_alpha; - bool m_forceRendering = false; + PHLANIMVAR<Vector2D> m_renderOffset; + PHLANIMVAR<float> m_alpha; + bool m_forceRendering = false; + std::optional<std::string> m_animationStyle; // allows damage to propagate. bool m_visible = false; diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 5eb73868..7e320b94 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -45,6 +45,7 @@ #include <hyprutils/utils/ScopeGuard.hpp> #include <cstring> #include <climits> +#include <optional> #include <ranges> #include <vector> #include <algorithm> @@ -1364,9 +1365,10 @@ void CMonitor::changeWorkspace(const PHLWORKSPACE& pWorkspace, bool internal, bo if (!internal) { const auto ANIMTOLEFT = POLDWORKSPACE && (shouldWraparound(pWorkspace->m_id, POLDWORKSPACE->m_id) ^ (pWorkspace->m_id > POLDWORKSPACE->m_id)); + const auto ANIMSTYLE = pWorkspace->m_animationStyle; if (POLDWORKSPACE) - g_pDesktopAnimationManager->startAnimation(POLDWORKSPACE, CDesktopAnimationManager::ANIMATION_TYPE_OUT, ANIMTOLEFT); - g_pDesktopAnimationManager->startAnimation(pWorkspace, CDesktopAnimationManager::ANIMATION_TYPE_IN, ANIMTOLEFT); + g_pDesktopAnimationManager->startAnimation(POLDWORKSPACE, CDesktopAnimationManager::ANIMATION_TYPE_OUT, ANIMTOLEFT, false, ANIMSTYLE); + g_pDesktopAnimationManager->startAnimation(pWorkspace, CDesktopAnimationManager::ANIMATION_TYPE_IN, ANIMTOLEFT, false, ANIMSTYLE); // move pinned windows for (auto const& w : g_pCompositor->m_windows) { diff --git a/src/managers/animation/DesktopAnimationManager.cpp b/src/managers/animation/DesktopAnimationManager.cpp index 2c450add..224fc52f 100644 --- a/src/managers/animation/DesktopAnimationManager.cpp +++ b/src/managers/animation/DesktopAnimationManager.cpp @@ -1,6 +1,7 @@ #include "DesktopAnimationManager.hpp" #include <algorithm> +#include <optional> #include "../../desktop/view/LayerSurface.hpp" #include "../../desktop/view/Window.hpp" @@ -232,7 +233,7 @@ void CDesktopAnimationManager::startAnimation(PHLLS ls, eAnimationType type, boo } } -void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType type, bool left, bool instant) { +void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType type, bool left, bool instant, std::optional<std::string> style) { const bool IN = type == ANIMATION_TYPE_IN; if (!instant) { @@ -243,8 +244,9 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty } static auto PWORKSPACEGAP = CConfigValue<Hyprlang::INT>("general:gaps_workspaces"); const auto PMONITOR = ws->m_monitor.lock(); - const auto ANIMSTYLE = ws->m_alpha->getStyle(); - float movePerc = 100.f; + const auto ANIMSTYLE = style.value_or(ws->m_alpha->getStyle()); + + float movePerc = 100.f; // inverted for some reason. TODO: fix the cause bool vert = ANIMSTYLE.starts_with("slidevert") || ANIMSTYLE.starts_with("slidefadevert"); diff --git a/src/managers/animation/DesktopAnimationManager.hpp b/src/managers/animation/DesktopAnimationManager.hpp index fa86425e..92aadb9f 100644 --- a/src/managers/animation/DesktopAnimationManager.hpp +++ b/src/managers/animation/DesktopAnimationManager.hpp @@ -3,6 +3,7 @@ #include "../../helpers/memory/Memory.hpp" #include "../../desktop/DesktopTypes.hpp" #include <string> +#include <optional> class CDesktopAnimationManager { public: @@ -13,7 +14,7 @@ class CDesktopAnimationManager { void startAnimation(PHLWINDOW w, eAnimationType type, bool force = false); void startAnimation(PHLLS ls, eAnimationType type, bool instant = false); - void startAnimation(PHLWORKSPACE ws, eAnimationType type, bool left = true, bool instant = false); + void startAnimation(PHLWORKSPACE ws, eAnimationType type, bool left = true, bool instant = false, std::optional<std::string> style = std::nullopt); void setFullscreenFadeAnimation(PHLWORKSPACE ws, eAnimationType type); void setFullscreenFloatingFade(PHLWINDOW pWindow, float fade); |
