mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-05 14:42:01 -07:00
workspaces: update persistence on workspace rename (#9368)
This commit is contained in:
@@ -3043,34 +3043,53 @@ bool CCompositor::shouldChangePreferredImageDescription() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<SWorkspaceRule>& rules) {
|
||||
void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<SWorkspaceRule>& rules, PHLWORKSPACE pWorkspace) {
|
||||
|
||||
for (const auto& rule : rules) {
|
||||
if (!rule.isPersistent)
|
||||
continue;
|
||||
|
||||
PHLWORKSPACE PWORKSPACE = nullptr;
|
||||
if (pWorkspace) {
|
||||
if (pWorkspace->matchesStaticSelector(rule.workspaceString))
|
||||
PWORKSPACE = pWorkspace;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto PMONITOR = getMonitorFromString(rule.monitor);
|
||||
|
||||
if (!PWORKSPACE) {
|
||||
WORKSPACEID id = rule.workspaceId;
|
||||
std::string wsname = rule.workspaceName;
|
||||
|
||||
if (id == WORKSPACE_INVALID) {
|
||||
const auto R = getWorkspaceIDNameFromString(rule.workspaceString);
|
||||
id = R.id;
|
||||
wsname = R.name;
|
||||
}
|
||||
|
||||
if (id == WORKSPACE_INVALID) {
|
||||
Debug::log(ERR, "ensurePersistentWorkspacesPresent: couldn't resolve id for workspace {}", rule.workspaceString);
|
||||
continue;
|
||||
}
|
||||
PWORKSPACE = getWorkspaceByID(id);
|
||||
if (!PWORKSPACE)
|
||||
createNewWorkspace(id, PMONITOR ? PMONITOR : m_pLastMonitor.lock(), wsname, false);
|
||||
}
|
||||
|
||||
if (PWORKSPACE)
|
||||
PWORKSPACE->m_bPersistent = true;
|
||||
|
||||
if (!PMONITOR) {
|
||||
Debug::log(ERR, "ensurePersistentWorkspacesPresent: couldn't resolve monitor for {}, skipping", rule.monitor);
|
||||
continue;
|
||||
}
|
||||
|
||||
WORKSPACEID id = rule.workspaceId;
|
||||
std::string wsname = rule.workspaceName;
|
||||
if (id == WORKSPACE_INVALID) {
|
||||
const auto R = getWorkspaceIDNameFromString(rule.workspaceString);
|
||||
id = R.id;
|
||||
wsname = R.name;
|
||||
}
|
||||
|
||||
if (id == WORKSPACE_INVALID) {
|
||||
Debug::log(ERR, "ensurePersistentWorkspacesPresent: couldn't resolve id for workspace {}", rule.workspaceString);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (const auto PWORKSPACE = getWorkspaceByID(id); PWORKSPACE) {
|
||||
if (PWORKSPACE) {
|
||||
if (PWORKSPACE->m_pMonitor == PMONITOR) {
|
||||
Debug::log(LOG, "ensurePersistentWorkspacesPresent: workspace persistent {} already on {}", rule.workspaceString, PMONITOR->szName);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3078,8 +3097,6 @@ void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<SWorkspace
|
||||
moveWorkspaceToMonitor(PWORKSPACE, PMONITOR);
|
||||
continue;
|
||||
}
|
||||
|
||||
createNewWorkspace(id, PMONITOR ? PMONITOR : m_pLastMonitor.lock(), wsname, false);
|
||||
}
|
||||
|
||||
// cleanup old
|
||||
|
Reference in New Issue
Block a user