From 3d41dd6c256c274ac1e556d5092967c9dc904467 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 24 Mar 2022 19:05:25 +0100 Subject: [PATCH] fix dwindle monitors --- src/events/Windows.cpp | 6 +++--- src/layout/DwindleLayout.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 0ee5e158..07be7cb2 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -47,14 +47,14 @@ void Events::listener_mapWindow(wl_listener* listener, void* data) { try { const long int MONITOR = std::stoi(r.szRule.substr(r.szRule.find(" "))); - Debug::log(LOG, "Rule monitor, applying to window %x", PWINDOW); - if (MONITOR >= (long int)g_pCompositor->m_lMonitors.size() || MONITOR < (long int)0) PWINDOW->m_iMonitorID = 0; else PWINDOW->m_iMonitorID = MONITOR; PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)->activeWorkspace; + + Debug::log(LOG, "Rule monitor, applying to window %x -> mon: %i, workspace: %i", PWINDOW, PWINDOW->m_iMonitorID, PWINDOW->m_iWorkspaceID); } catch (...) { Debug::log(LOG, "Rule monitor failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str()); } @@ -106,7 +106,7 @@ void Events::listener_mapWindow(wl_listener* listener, void* data) { if (!PWINDOW->m_bIsModal) g_pCompositor->focusWindow(PWINDOW); - Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vRealPosition.x, PWINDOW->m_vRealPosition.y, PWINDOW->m_vRealSize.x, PWINDOW->m_vRealSize.y); + Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vEffectivePosition.x, PWINDOW->m_vEffectivePosition.y, PWINDOW->m_vEffectiveSize.x, PWINDOW->m_vEffectiveSize.y); } void Events::listener_unmapWindow(wl_listener* listener, void* data) { diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index adcc884c..b1975ea6 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -42,7 +42,7 @@ int CHyprDwindleLayout::getNodesOnWorkspace(const int& id) { SDwindleNodeData* CHyprDwindleLayout::getFirstNodeOnWorkspace(const int& id) { for (auto& n : m_lDwindleNodesData) { - if (n.workspaceID == id) + if (n.workspaceID == id && n.pWindow && g_pCompositor->windowValidMapped(n.pWindow)) return &n; } return nullptr; @@ -130,13 +130,15 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) { SDwindleNodeData* OPENINGON; const auto MONFROMCURSOR = g_pCompositor->getMonitorFromCursor(); - if (PMONITOR == MONFROMCURSOR) + if (PMONITOR->ID == MONFROMCURSOR->ID) OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal())); else - OPENINGON = getFirstNodeOnWorkspace(MONFROMCURSOR->activeWorkspace); + OPENINGON = getFirstNodeOnWorkspace(PMONITOR->activeWorkspace); + + Debug::log(LOG, "OPENINGON: %x, Workspace: %i, Monitor: %i", OPENINGON, PNODE->workspaceID, PMONITOR->ID); // if it's the first, it's easy. Make it fullscreen. - if (!OPENINGON) { + if (!OPENINGON || OPENINGON->pWindow == pWindow) { PNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft; PNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight; @@ -199,8 +201,6 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) { } void CHyprDwindleLayout::onWindowRemoved(CWindow* pWindow) { - if (!g_pCompositor->windowValidMapped(pWindow)) - return; const auto PNODE = getNodeFromWindow(pWindow);