summaryrefslogtreecommitdiff
path: root/src/Compositor.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-21 16:38:48 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-21 16:38:48 +0200
commitb618fc1caa4063bbed8373935db7e00b2f0cc9fe (patch)
tree3080cea972386b28dc7d624c1a7c600f6e8124a4 /src/Compositor.cpp
parentc02afa0c2725b353c56706fa0186143f661cc283 (diff)
Added named workspaces
Diffstat (limited to 'src/Compositor.cpp')
-rw-r--r--src/Compositor.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 2ed12112..0a0a55e4 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -708,4 +708,38 @@ CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow) {
}
return nullptr;
+}
+
+int CCompositor::getNextAvailableNamedWorkspace() {
+ int highest = -1337 - 1;
+ for (auto& w : m_lWorkspaces) {
+ if (w.m_iID < 0 && w.m_iID > highest)
+ highest = w.m_iID;
+ }
+
+ return highest + 1;
+}
+
+CWorkspace* CCompositor::getWorkspaceByName(const std::string& name) {
+ for (auto& w : m_lWorkspaces) {
+ if (w.m_szName == name)
+ return &w;
+ }
+
+ return nullptr;
+}
+
+CWorkspace* CCompositor::getWorkspaceByString(const std::string& str) {
+ if (str.find("name:") == 0) {
+ return getWorkspaceByName(str.substr(str.find_first_of(':') + 1));
+ }
+
+ try {
+ int id = std::stoi(str);
+ return getWorkspaceByID(id);
+ } catch (std::exception& e) {
+ Debug::log(ERR, "Error in getWorkspaceByString, invalid id");
+ }
+
+ return nullptr;
} \ No newline at end of file