From eee9698ec90daee9e6f8e3b4f4b242f38287ff81 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 30 May 2022 20:44:14 +0200 Subject: move workspaces and not windows on mon disconnect --- src/events/Monitors.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/events/Monitors.cpp') diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index 13f99749..4487bf2f 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -309,14 +309,26 @@ void Events::listener_monitorDestroy(void* owner, void* data) { // snap cursor wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, BACKUPMON->vecPosition.x + BACKUPMON->vecTransformedSize.x / 2.f, BACKUPMON->vecPosition.y + BACKUPMON->vecTransformedSize.y / 2.f); - // move windows - for (auto& w : g_pCompositor->m_lWindows) { + // move workspaces + std::deque wspToMove; + for (auto& w : g_pCompositor->m_lWorkspaces) { if (w.m_iMonitorID == pMonitor->ID) { - g_pCompositor->moveWindowToWorkspace(&w, BACKUPWORKSPACE); + wspToMove.push_back(&w); } } - g_pCompositor->sanityCheckWorkspaces(); + for (auto& w : wspToMove) { + g_pCompositor->moveWorkspaceToMonitor(w, BACKUPMON); + w->startAnim(true, true, true); + } + + pMonitor->activeWorkspace = -1; + + for (auto it = g_pCompositor->m_lWorkspaces.begin(); it != g_pCompositor->m_lWorkspaces.end(); ++it) { + if (it->m_iMonitorID == pMonitor->ID) { + it = g_pCompositor->m_lWorkspaces.erase(it); + } + } Debug::log(LOG, "Removed monitor %s!", pMonitor->szName.c_str()); -- cgit v1.2.3