Added named workspaces

This commit is contained in:
vaxerski
2022-04-21 16:38:48 +02:00
parent c02afa0c27
commit b618fc1caa
4 changed files with 71 additions and 18 deletions

View File

@@ -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;
}