summaryrefslogtreecommitdiff
path: root/src/helpers/MiscFunctions.cpp
diff options
context:
space:
mode:
authorxDarksome <dev@darkso.me>2022-06-24 18:58:11 +0300
committerGitHub <noreply@github.com>2022-06-24 18:58:11 +0300
commitbe460ea9547691eb136bf8b600b67b778af47e3f (patch)
treeb74869ad39dd804aec31694d4dd429822c223644 /src/helpers/MiscFunctions.cpp
parent776ca3baf269059e8c13ba8b625645215e71f78c (diff)
parente7467c60f9fe9e66c74dd8dc7c752a73ed4bc4db (diff)
Merge branch 'hyprwm:main' into main
Diffstat (limited to 'src/helpers/MiscFunctions.cpp')
-rw-r--r--src/helpers/MiscFunctions.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp
index 6f9b465e..55b0ec83 100644
--- a/src/helpers/MiscFunctions.cpp
+++ b/src/helpers/MiscFunctions.cpp
@@ -158,6 +158,12 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
outName = WORKSPACENAME;
} else {
if (in[0] == 'm') {
+ if (!g_pCompositor->m_pLastMonitor) {
+ Debug::log(ERR, "Relative monitor workspace on monitor null!");
+ result = INT_MAX;
+ return result;
+ }
+
// monitor relative
result = (int)getPlusMinusKeywordResult(in.substr(1), 0);
@@ -207,7 +213,14 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
outName = g_pCompositor->getWorkspaceByID(currentID)->m_szName;
} else {
- result = std::clamp((int)getPlusMinusKeywordResult(in, g_pCompositor->m_pLastMonitor->activeWorkspace), 1, INT_MAX);
+ if (g_pCompositor->m_pLastMonitor)
+ result = std::clamp((int)getPlusMinusKeywordResult(in, g_pCompositor->m_pLastMonitor->activeWorkspace), 1, INT_MAX);
+ else if (isNumber(in))
+ result = std::clamp(std::stoi(in), 1, INT_MAX);
+ else {
+ Debug::log(ERR, "Relative workspace on no mon!");
+ result = INT_MAX;
+ }
outName = std::to_string(result);
}
}