summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2025-09-23 21:08:30 +0200
committerGitHub <noreply@github.com>2025-09-23 21:08:30 +0200
commitec9a72d9fbe8372c4cc4e86966f6b13d178b0bba (patch)
treed88e9b453d5f00f262ce61b4cad7804453a46b97
parent31bd9ec41705a606bb074facca114ea79b62a63a (diff)
workspaces: fix persistence with no monitor specified (#11807)
-rw-r--r--hyprtester/src/tests/main/workspaces.cpp10
-rw-r--r--src/Compositor.cpp7
2 files changed, 15 insertions, 2 deletions
diff --git a/hyprtester/src/tests/main/workspaces.cpp b/hyprtester/src/tests/main/workspaces.cpp
index fa29338c..de724af6 100644
--- a/hyprtester/src/tests/main/workspaces.cpp
+++ b/hyprtester/src/tests/main/workspaces.cpp
@@ -27,6 +27,16 @@ static bool test() {
NLog::log("{}Switching to workspace 1", Colors::YELLOW);
OK(getFromSocket("/dispatch workspace 1"));
+ NLog::log("{}Checking persistent no-mon", Colors::YELLOW);
+ OK(getFromSocket("r/keyword workspace 966,persistent:1"));
+
+ {
+ auto str = getFromSocket("/workspaces");
+ EXPECT_CONTAINS(str, "workspace ID 966 (966)");
+ }
+
+ OK(getFromSocket("/reload"));
+
NLog::log("{}Spawning kittyProc on ws 1", Colors::YELLOW);
auto kittyProcA = Tests::spawnKitty();
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index ce549459..5ea88b11 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -3145,7 +3145,7 @@ void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<SWorkspace
continue;
}
- const auto PMONITOR = getMonitorFromString(rule.monitor);
+ auto PMONITOR = getMonitorFromString(rule.monitor);
if (!rule.monitor.empty() && !PMONITOR)
continue; // don't do anything yet, as the monitor is not yet present.
@@ -3165,8 +3165,11 @@ void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<SWorkspace
continue;
}
PWORKSPACE = getWorkspaceByID(id);
+ if (!PMONITOR)
+ PMONITOR = m_lastMonitor.lock();
+
if (!PWORKSPACE)
- PWORKSPACE = createNewWorkspace(id, PMONITOR ? PMONITOR->m_id : m_lastMonitor->m_id, wsname, false);
+ PWORKSPACE = createNewWorkspace(id, PMONITOR->m_id, wsname, false);
}
if (!PMONITOR) {