mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-10-01 07:38:28 +00:00
Added named workspaces
This commit is contained in:
@@ -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;
|
||||
}
|
Reference in New Issue
Block a user