diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-09-28 15:26:41 +0100 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-09-28 15:26:41 +0100 |
| commit | e3b1d3c3c53c2ffad07f2ef91d5a0cf3fa452879 (patch) | |
| tree | a3ed1657a2ce84dc07dbb56a5a1d604c390620f3 /src/helpers/MiscFunctions.cpp | |
| parent | 458ba3237b402c72b78e890de228e561b3b4de8b (diff) | |
allow for pure workspace names in dispatchers
Diffstat (limited to 'src/helpers/MiscFunctions.cpp')
| -rw-r--r-- | src/helpers/MiscFunctions.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index d7df7bd7..67debf32 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -192,7 +192,7 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) { } outName = WORKSPACENAME; } else { - if (in[0] == 'm' || in[0] == 'e') { + if ((in[0] == 'm' || in[0] == 'e') && (in[1] == '-' || in[1] == '+') && isNumber(in.substr(2))) { bool onAllMonitors = in[0] == 'e'; if (!g_pCompositor->m_pLastMonitor) { @@ -253,14 +253,22 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) { outName = g_pCompositor->getWorkspaceByID(currentID)->m_szName; } else { - if (g_pCompositor->m_pLastMonitor) - result = std::max((int)getPlusMinusKeywordResult(in, g_pCompositor->m_pLastMonitor->activeWorkspace), 1); - else if (isNumber(in)) + if (in[0] == '+' || in[0] == '-') { + if (g_pCompositor->m_pLastMonitor) + result = std::max((int)getPlusMinusKeywordResult(in, g_pCompositor->m_pLastMonitor->activeWorkspace), 1); + else { + Debug::log(ERR, "Relative workspace on no mon!"); + result = INT_MAX; + } + } else if (isNumber(in)) result = std::max(std::stoi(in), 1); else { - Debug::log(ERR, "Relative workspace on no mon!"); - result = INT_MAX; + // maybe name + const auto PWORKSPACE = g_pCompositor->getWorkspaceByName(in); + if (PWORKSPACE) + result = PWORKSPACE->m_iID; } + outName = std::to_string(result); } } |
