summaryrefslogtreecommitdiff
path: root/src/Compositor.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2025-01-26 14:40:42 +0000
committerVaxry <vaxry@vaxry.net>2025-01-26 14:40:42 +0000
commit16aeb24bc1395b46d675ec3522ed452e487f5b69 (patch)
treef9f8b11cc68a80bbccfaaee22dfb529e1d80f1aa /src/Compositor.cpp
parent74d0f34cf396f4fc41ee98b000e7d0a4e277c066 (diff)
core: make persistent workspaces always follow the config
instead of just staying after open, they will now be enforced on their respective monitors fixes #8769
Diffstat (limited to 'src/Compositor.cpp')
-rw-r--r--src/Compositor.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 43efdac1..3421c314 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -3024,3 +3024,46 @@ bool CCompositor::shouldChangePreferredImageDescription() {
Debug::log(WARN, "FIXME: color management protocol is enabled and outputs changed, check preferred image description changes");
return false;
}
+
+void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<SWorkspaceRule>& rules) {
+ for (const auto& rule : rules) {
+ if (!rule.isPersistent)
+ continue;
+
+ const auto PMONITOR = getMonitorFromString(rule.monitor);
+
+ 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->m_pMonitor == PMONITOR) {
+ Debug::log(LOG, "ensurePersistentWorkspacesPresent: workspace persistent {} already on {}", rule.workspaceString, PMONITOR->szName);
+ continue;
+ }
+
+ Debug::log(LOG, "ensurePersistentWorkspacesPresent: workspace persistent {} not on {}, moving", rule.workspaceString, PMONITOR->szName);
+ moveWorkspaceToMonitor(PWORKSPACE, PMONITOR);
+ continue;
+ }
+
+ createNewWorkspace(id, PMONITOR ? PMONITOR : m_pLastMonitor.lock(), wsname, false);
+ }
+
+ // cleanup old
+ sanityCheckWorkspaces();
+}