summaryrefslogtreecommitdiff
path: root/src/helpers/MiscFunctions.cpp
diff options
context:
space:
mode:
authorJulian Schuler <31921487+julianschuler@users.noreply.github.com>2022-11-23 15:10:26 +0100
committerGitHub <noreply@github.com>2022-11-23 14:10:26 +0000
commit79a9bc9076a98cc11a7f2c361765adacda224b0c (patch)
treed295eb2a8919fa5b462eeede4798a5f530e10e3a /src/helpers/MiscFunctions.cpp
parentdcb6a0425c1c902555fac43441c0581afb2defd4 (diff)
Add option for retrieving first empty workspace (#1085)
Diffstat (limited to 'src/helpers/MiscFunctions.cpp')
-rw-r--r--src/helpers/MiscFunctions.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp
index 706bb31e..37828c5d 100644
--- a/src/helpers/MiscFunctions.cpp
+++ b/src/helpers/MiscFunctions.cpp
@@ -244,6 +244,13 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
result = WORKSPACE->m_iID;
}
outName = WORKSPACENAME;
+ } else if (in.find("empty") == 0) {
+ int id = 0;
+ while (++id < INT_MAX) {
+ const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(id);
+ if (!PWORKSPACE || (g_pCompositor->getWindowsOnWorkspace(id) == 0))
+ return id;
+ }
} else {
if ((in[0] == 'm' || in[0] == 'e') && (in[1] == '-' || in[1] == '+') && isNumber(in.substr(2))) {
bool onAllMonitors = in[0] == 'e';
@@ -485,4 +492,4 @@ int64_t configStringToInt(const std::string& VALUE) {
return 0;
}
return stol(VALUE);
-} \ No newline at end of file
+}