From b618fc1caa4063bbed8373935db7e00b2f0cc9fe Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 21 Apr 2022 16:38:48 +0200 Subject: Added named workspaces --- src/Compositor.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/Compositor.cpp') diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 2ed12112..0a0a55e4 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -707,5 +707,39 @@ CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow) { return &w; } + 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 -- cgit v1.2.3