diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-05-18 12:18:58 +0200 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-05-18 12:18:58 +0200 |
| commit | f70d0ec5aa7ad7fdfd8229204c3a0cbfe04f13e7 (patch) | |
| tree | 0f3f6553c6fd43142c6c55386822b2cdb640bea1 /src/helpers/MiscFunctions.cpp | |
| parent | 5fa4b9a7777256924147838901e27de2151e1d8a (diff) | |
Added movetoworkspacesilent
Diffstat (limited to 'src/helpers/MiscFunctions.cpp')
| -rw-r--r-- | src/helpers/MiscFunctions.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index 61ae0c49..ebc8c213 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -1,6 +1,7 @@ #include "MiscFunctions.hpp" #include "../defines.hpp" #include <algorithm> +#include "../Compositor.hpp" void addWLSignal(wl_signal* pSignal, wl_listener* pListener, void* pOwner, std::string ownerString) { ASSERT(pSignal); @@ -120,4 +121,23 @@ bool isNumber(const std::string& str) { bool isDirection(const std::string& arg) { return arg == "l" || arg == "r" || arg == "u" || arg == "d" || arg == "t" || arg == "b"; +} + +int getWorkspaceIDFromString(const std::string& in, std::string& outName) { + int result = INT_MAX; + if (in.find("name:") == 0) { + const auto WORKSPACENAME = in.substr(in.find_first_of(':') + 1); + const auto WORKSPACE = g_pCompositor->getWorkspaceByName(WORKSPACENAME); + if (!WORKSPACE) { + result = g_pCompositor->getNextAvailableNamedWorkspace(); + } else { + result = WORKSPACE->m_iID; + } + outName = WORKSPACENAME; + } else { + result = std::clamp((int)getPlusMinusKeywordResult(in, g_pCompositor->m_pLastMonitor->activeWorkspace), 1, INT_MAX); + outName = std::to_string(result); + } + + return result; }
\ No newline at end of file |
