From fd3e6a3bfde6d44a62df4834ccae5b24a1f36469 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 3 May 2023 15:15:56 +0100 Subject: [PATCH] workspaces: restore monitor on re-plug --- src/helpers/Monitor.cpp | 10 ++++++++++ src/helpers/Workspace.hpp | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index f9209b8a..924aab1d 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -144,6 +144,14 @@ void CMonitor::onConnect(bool noRule) { setupDefaultWS(monitorRule); + for (auto& ws : g_pCompositor->m_vWorkspaces) { + if (ws->m_szLastMonitor == szName) { + g_pCompositor->moveWorkspaceToMonitor(ws.get(), this); + ws->startAnim(true, true, true); + ws->m_szLastMonitor = ""; + } + } + scale = monitorRule.scale; if (scale < 0.1) scale = getDefaultScale(); @@ -264,6 +272,7 @@ void CMonitor::onDisconnect() { } for (auto& w : wspToMove) { + w->m_szLastMonitor = szName; g_pCompositor->moveWorkspaceToMonitor(w, BACKUPMON); w->startAnim(true, true, true); } @@ -378,6 +387,7 @@ void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) { g_pCompositor->deactivateAllWLRWorkspaces(PNEWWORKSPACE->m_pWlrHandle); PNEWWORKSPACE->setActive(true); + PNEWWORKSPACE->m_szLastMonitor = ""; } void CMonitor::setMirror(const std::string& mirrorOf) { diff --git a/src/helpers/Workspace.hpp b/src/helpers/Workspace.hpp index 5ecbd483..b9de76d5 100644 --- a/src/helpers/Workspace.hpp +++ b/src/helpers/Workspace.hpp @@ -51,7 +51,10 @@ class CWorkspace { bool m_bDefaultPseudo = false; // don't destroy in sanity check - bool m_bIndestructible = false; + bool m_bIndestructible = false; + + // last monitor (used on reconnect) + std::string m_szLastMonitor = ""; void startAnim(bool in, bool left, bool instant = false); void setActive(bool on);