diff options
Diffstat (limited to 'src/Compositor.cpp')
| -rw-r--r-- | src/Compositor.cpp | 34 |
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 |
