workspaces: restore monitor on re-plug

This commit is contained in:
vaxerski 2023-05-03 15:15:56 +01:00
parent 0155b85950
commit fd3e6a3bfd
2 changed files with 14 additions and 1 deletions

View file

@ -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) {

View file

@ -53,6 +53,9 @@ class CWorkspace {
// don't destroy in sanity check
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);