diff options
| author | Nathan Ollerenshaw <chrome@stupendous.net> | 2025-04-14 02:07:53 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-14 11:07:53 +0200 |
| commit | 533bc5115e49a6d0d093b45f7db65854bc9a0494 (patch) | |
| tree | 5e538ba7ffd2939a88817870f11c2e966bd75ac4 /src/helpers/Monitor.cpp | |
| parent | 99ab3e19d928c3c33ca7d7c5f5b0cbc7eb50dce5 (diff) | |
monitors: fix disconnected monitors are reconnected to an empty workspace (#9874)
---------
Co-authored-by: nyx <nnyyxxxx@protonmail.com>
Diffstat (limited to 'src/helpers/Monitor.cpp')
| -rw-r--r-- | src/helpers/Monitor.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 97f74609..e30849a7 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -235,6 +235,19 @@ void CMonitor::onConnect(bool noRule) { } } + Debug::log(LOG, "checking if we have seen this monitor before: {}", szName); + // if we saw this monitor before, set it to the workspace it was on + if (g_pCompositor->m_mSeenMonitorWorkspaceMap.contains(szName)) { + auto workspaceID = g_pCompositor->m_mSeenMonitorWorkspaceMap[szName]; + Debug::log(LOG, "Monitor {} was on workspace {}, setting it to that", szName, workspaceID); + auto ws = g_pCompositor->getWorkspaceByID(workspaceID); + if (ws) { + g_pCompositor->moveWorkspaceToMonitor(ws, self.lock()); + changeWorkspace(ws, true, false, false); + } + } else + Debug::log(LOG, "Monitor {} was not on any workspace", szName); + if (!found) g_pCompositor->setActiveMonitor(self.lock()); @@ -273,6 +286,12 @@ void CMonitor::onDisconnect(bool destroy) { events.disconnect.emit(); + // record what workspace this monitor was on + if (activeWorkspace) { + Debug::log(LOG, "Disconnecting Monitor {} was on workspace {}", szName, activeWorkspace->m_iID); + g_pCompositor->m_mSeenMonitorWorkspaceMap[szName] = activeWorkspace->m_iID; + } + // Cleanup everything. Move windows back, snap cursor, shit. PHLMONITOR BACKUPMON = nullptr; for (auto const& m : g_pCompositor->m_vMonitors) { |
