mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-03 13:41:59 -07:00
monitors: fix disconnected monitors are reconnected to an empty workspace (#9874)
--------- Co-authored-by: nyx <nnyyxxxx@protonmail.com>
This commit is contained in:
committed by
GitHub
parent
99ab3e19d9
commit
533bc5115e
@@ -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) {
|
||||
|
Reference in New Issue
Block a user