diff --git a/src/events/events.cpp b/src/events/events.cpp index b1d396b..fee988c 100644 --- a/src/events/events.cpp +++ b/src/events/events.cpp @@ -555,7 +555,7 @@ CWindow* Events::remapWindow(int windowID, bool wasfloating, int forcemonitor) { // For master layout, add the index PWINDOWINARR->setMasterChildIndex(g_pWindowManager->getWindowsOnWorkspace(g_pWindowManager->activeWorkspaces[CURRENTSCREEN]) - 1); // and set master if needed - if (g_pWindowManager->getWindowsOnWorkspace(g_pWindowManager->activeWorkspaces[CURRENTSCREEN]) == 0) + if (g_pWindowManager->getWindowsOnWorkspace(g_pWindowManager->activeWorkspaces[CURRENTSCREEN]) == 1) // 1 because the current window is already in the arr PWINDOWINARR->setMaster(true); diff --git a/src/windowManager.cpp b/src/windowManager.cpp index 1d3e7f9..0fc54c1 100644 --- a/src/windowManager.cpp +++ b/src/windowManager.cpp @@ -1062,25 +1062,37 @@ void CWindowManager::recalcEntireWorkspace(const int& workspace) { // first, calc the size CWindow* pMaster = nullptr; for (auto& w : windows) { - if (w.getWorkspaceID() == workspace && w.getMaster() && !w.getDead()) { + if (w.getWorkspaceID() == workspace && w.getMaster() && !w.getDead() && !w.getIsFloating() && !w.getDock()) { pMaster = &w; break; } } + CWindow* pMasterContainer = nullptr; + for (auto& w : windows) { + if (w.getWorkspaceID() == workspace && w.getParentNodeID() == 0 && !w.getIsFloating() && !w.getDock()) { + pMasterContainer = &w; + break; + } + } + if (!pMaster) { Debug::log(ERR, "No master found on workspace???"); return; } // set the xy for master + float splitRatio = 1; + if (pMasterContainer) + splitRatio = pMasterContainer->getSplitRatio(); + pMaster->setPosition(Vector2D(0, 0) + PMONITOR->vecPosition); - pMaster->setSize(Vector2D(PMONITOR->vecSize.x / 2, PMONITOR->vecSize.y)); + pMaster->setSize(Vector2D(PMONITOR->vecSize.x / 2 * splitRatio, PMONITOR->vecSize.y)); // get children sorted std::vector children; for (auto& w : windows) { - if (w.getWorkspaceID() == workspace && !w.getMaster() && w.getDrawable() > 0 && !w.getDead()) + if (w.getWorkspaceID() == workspace && !w.getMaster() && w.getDrawable() > 0 && !w.getDead() && !w.getDock()) children.push_back(&w); } std::sort(children.begin(), children.end(), [](CWindow*& a, CWindow*& b) { @@ -1096,8 +1108,8 @@ void CWindowManager::recalcEntireWorkspace(const int& workspace) { // Children sorted, set xy int yoff = 0; for (const auto& child : children) { - child->setPosition(Vector2D(PMONITOR->vecSize.x / 2, yoff) + PMONITOR->vecPosition); - child->setSize(Vector2D(PMONITOR->vecSize.x / 2, PMONITOR->vecSize.y / children.size())); + child->setPosition(Vector2D(PMONITOR->vecSize.x / 2 * splitRatio, yoff) + PMONITOR->vecPosition); + child->setSize(Vector2D(PMONITOR->vecSize.x / 2 * (2 - splitRatio), PMONITOR->vecSize.y / children.size())); yoff += PMONITOR->vecSize.y / children.size(); } @@ -1296,7 +1308,7 @@ CWindow* CWindowManager::getMasterForWorkspace(const int& work) { if (!pMaster) { Debug::log(ERR, "No master found on workspace? Setting automatically"); for (auto& w : windows) { - if (w.getWorkspaceID() == work) { + if (w.getWorkspaceID() == work && !w.getDock() && !w.getIsFloating()) { pMaster = &w; w.setMaster(true); break; @@ -1314,7 +1326,7 @@ void CWindowManager::fixMasterWorkspaceOnClosed(CWindow* pWindow) { // get children sorted std::vector children; for (auto& w : windows) { - if (w.getWorkspaceID() == pWindow->getWorkspaceID() && !w.getMaster() && w.getDrawable() > 0 && w.getDrawable() != pWindow->getDrawable()) + if (w.getWorkspaceID() == pWindow->getWorkspaceID() && !w.getMaster() && w.getDrawable() > 0 && w.getDrawable() != pWindow->getDrawable() && !w.getDock()) children.push_back(&w); } std::sort(children.begin(), children.end(), [](CWindow*& a, CWindow*& b) {