internal: prevent premature destroy in moveworkspace

This commit is contained in:
vaxerski 2023-04-13 21:09:50 +01:00
parent 33d06fb0e5
commit 41c7d896e3
2 changed files with 15 additions and 3 deletions

View file

@ -1090,6 +1090,10 @@ CWorkspace* CCompositor::getWorkspaceByID(const int& id) {
void CCompositor::sanityCheckWorkspaces() { void CCompositor::sanityCheckWorkspaces() {
auto it = m_vWorkspaces.begin(); auto it = m_vWorkspaces.begin();
while (it != m_vWorkspaces.end()) { while (it != m_vWorkspaces.end()) {
if ((*it)->m_bIndestructible)
continue;
const auto WINDOWSONWORKSPACE = getWindowsOnWorkspace((*it)->m_iID); const auto WINDOWSONWORKSPACE = getWindowsOnWorkspace((*it)->m_iID);
if ((*it)->m_bIsSpecialWorkspace && WINDOWSONWORKSPACE == 0) { if ((*it)->m_bIsSpecialWorkspace && WINDOWSONWORKSPACE == 0) {
@ -1884,9 +1888,13 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
Debug::log(LOG, "moveWorkspaceToMonitor: Plugging gap with existing %d", nextWorkspaceOnMonitorID); Debug::log(LOG, "moveWorkspaceToMonitor: Plugging gap with existing %d", nextWorkspaceOnMonitorID);
pWorkspace->m_bIndestructible = true; // so that changeworkspace doesn't yeet it if it's empty
g_pKeybindManager->focusMonitor(std::to_string(POLDMON->ID)); g_pKeybindManager->focusMonitor(std::to_string(POLDMON->ID));
g_pKeybindManager->changeworkspace(std::to_string(nextWorkspaceOnMonitorID)); g_pKeybindManager->changeworkspace(std::to_string(nextWorkspaceOnMonitorID));
pWorkspace->m_bIndestructible = false;
// move the workspace // move the workspace
pWorkspace->m_iMonitorID = pMonitor->ID; pWorkspace->m_iMonitorID = pMonitor->ID;

View file

@ -3,7 +3,8 @@
#include "../defines.hpp" #include "../defines.hpp"
#include "AnimatedVariable.hpp" #include "AnimatedVariable.hpp"
enum eFullscreenMode : uint8_t { enum eFullscreenMode : uint8_t
{
FULLSCREEN_FULL = 0, FULLSCREEN_FULL = 0,
FULLSCREEN_MAXIMIZED FULLSCREEN_MAXIMIZED
}; };
@ -46,8 +47,11 @@ class CWorkspace {
CWindow* m_pLastFocusedWindow = nullptr; CWindow* m_pLastFocusedWindow = nullptr;
// user-set // user-set
bool m_bDefaultFloating = false; bool m_bDefaultFloating = false;
bool m_bDefaultPseudo = false; bool m_bDefaultPseudo = false;
// don't destroy in sanity check
bool m_bIndestructible = false;
void startAnim(bool in, bool left, bool instant = false); void startAnim(bool in, bool left, bool instant = false);
void setActive(bool on); void setActive(bool on);