workspaces: fix persistence with no monitor specified (#11807)

This commit is contained in:
Vaxry 2025-09-23 21:08:30 +02:00 committed by GitHub
parent 31bd9ec417
commit ec9a72d9fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 2 deletions

View file

@ -27,6 +27,16 @@ static bool test() {
NLog::log("{}Switching to workspace 1", Colors::YELLOW); NLog::log("{}Switching to workspace 1", Colors::YELLOW);
OK(getFromSocket("/dispatch workspace 1")); 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); NLog::log("{}Spawning kittyProc on ws 1", Colors::YELLOW);
auto kittyProcA = Tests::spawnKitty(); auto kittyProcA = Tests::spawnKitty();

View file

@ -3145,7 +3145,7 @@ void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<SWorkspace
continue; continue;
} }
const auto PMONITOR = getMonitorFromString(rule.monitor); auto PMONITOR = getMonitorFromString(rule.monitor);
if (!rule.monitor.empty() && !PMONITOR) if (!rule.monitor.empty() && !PMONITOR)
continue; // don't do anything yet, as the monitor is not yet present. 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; continue;
} }
PWORKSPACE = getWorkspaceByID(id); PWORKSPACE = getWorkspaceByID(id);
if (!PMONITOR)
PMONITOR = m_lastMonitor.lock();
if (!PWORKSPACE) 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) { if (!PMONITOR) {