diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 5cb18e0f..285e144f 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -432,6 +432,7 @@ CConfigManager::CConfigManager() { m_pConfig->addConfigValue("animations:enabled", {1L}); m_pConfig->addConfigValue("animations:first_launch_animation", {1L}); + m_pConfig->addConfigValue("animations:workspace_wraparound", {0L}); m_pConfig->addConfigValue("input:follow_mouse", {1L}); m_pConfig->addConfigValue("input:mouse_refocus", {1L}); diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index 2905ce2b..52fdc225 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -521,6 +521,15 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) { return result; } +std::optional isWorkspaceChangeDirectionLeft(const std::string& args) { + if ((args[0] == '-' || args[0] == '+') && isNumber(args.substr(1))) + return args[0] == '+'; + else if ((args[0] == 'r' || args[0] == 'm' || args[0] == 'e') && (args[1] == '-' || args[1] == '+') && isNumber(args.substr(2))) + return args[1] == '+'; + else + return {}; +} + std::optional cleanCmdForWorkspace(const std::string& inWorkspaceName, std::string dirtyCmd) { std::string cmd = removeBeginEndSpacesTabs(dirtyCmd); diff --git a/src/helpers/MiscFunctions.hpp b/src/helpers/MiscFunctions.hpp index 23fc6e5a..aab9175f 100644 --- a/src/helpers/MiscFunctions.hpp +++ b/src/helpers/MiscFunctions.hpp @@ -22,6 +22,7 @@ bool isNumber(const std::string&, bool allowfloat = bool isDirection(const std::string&); bool isDirection(const char&); int getWorkspaceIDFromString(const std::string&, std::string&); +std::optional isWorkspaceChangeDirectionLeft(const std::string&); std::optional cleanCmdForWorkspace(const std::string&, std::string); float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2); void logSystemInfo(); diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 2dd2a2d9..86d34add 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -536,7 +536,7 @@ float CMonitor::getDefaultScale() { return 1; } -void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal, bool noMouseMove, bool noFocus) { +void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal, bool noMouseMove, bool noFocus, std::optional animateLeftOverride) { if (!pWorkspace) return; @@ -556,7 +556,7 @@ void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal, bool activeWorkspace = pWorkspace->m_iID; if (!internal) { - const auto ANIMTOLEFT = pWorkspace->m_iID > POLDWORKSPACE->m_iID; + const auto ANIMTOLEFT = animateLeftOverride.value_or(pWorkspace->m_iID > POLDWORKSPACE->m_iID); POLDWORKSPACE->startAnim(false, ANIMTOLEFT); pWorkspace->startAnim(true, ANIMTOLEFT); diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 051c5305..38c8876e 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -142,7 +142,7 @@ class CMonitor { bool isMirror(); bool matchesStaticSelector(const std::string& selector) const; float getDefaultScale(); - void changeWorkspace(CWorkspace* const pWorkspace, bool internal = false, bool noMouseMove = false, bool noFocus = false); + void changeWorkspace(CWorkspace* const pWorkspace, bool internal = false, bool noMouseMove = false, bool noFocus = false, std::optional animateLeftOverride = {}); void changeWorkspace(const int& id, bool internal = false, bool noMouseMove = false, bool noFocus = false); void setSpecialWorkspace(CWorkspace* const pWorkspace); void setSpecialWorkspace(const int& id); diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 481b8987..4a3afe5d 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -895,6 +895,7 @@ void CKeybindManager::changeworkspace(std::string args) { static auto* const PBACKANDFORTH = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("binds:workspace_back_and_forth"); static auto* const PALLOWWORKSPACECYCLES = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles"); static auto* const PWORKSPACECENTERON = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("binds:workspace_center_on"); + static auto* const PWORKSPACEWRAPAROUND = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("animations:workspace_wraparound"); const auto PMONITOR = g_pCompositor->m_pLastMonitor; @@ -955,7 +956,12 @@ void CKeybindManager::changeworkspace(std::string args) { g_pCompositor->setActiveMonitor(PMONITORWORKSPACEOWNER); - PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo, false, true); + if (**PWORKSPACEWRAPAROUND) { + const auto ANIMATELEFT = isWorkspaceChangeDirectionLeft(args); + PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo, false, true, false, ANIMATELEFT); + } else { + PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo, false, true); + } if (PMONITOR != PMONITORWORKSPACEOWNER) { Vector2D middle = PMONITORWORKSPACEOWNER->middle();