From cd37a1533e0e86fffdd333e18bab0bb730c1dc25 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 5 Aug 2022 18:10:59 +0200 Subject: reject tiling windows that do not meet the max size requirement --- src/layout/MasterLayout.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/layout/MasterLayout.cpp') diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp index b7f03c3d..1f647c63 100644 --- a/src/layout/MasterLayout.cpp +++ b/src/layout/MasterLayout.cpp @@ -39,6 +39,8 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow) { static auto *const PNEWTOP = &g_pConfigManager->getConfigValuePtr("master:new_on_top")->intValue; + const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID); + const auto PNODE = *PNEWTOP ? &m_lMasterNodesData.emplace_front() : &m_lMasterNodesData.emplace_back(); PNODE->workspaceID = pWindow->m_iWorkspaceID; @@ -60,8 +62,26 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow) { PNODE->isMaster = true; PNODE->percMaster = lastSplitPercent; + + // first, check if it isn't too big. + if (const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(pWindow); MAXSIZE.x < PMONITOR->vecSize.x * lastSplitPercent || MAXSIZE.y < PMONITOR->vecSize.y) { + // we can't continue. make it floating. + pWindow->m_bIsFloating = true; + m_lMasterNodesData.remove(*PNODE); + g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(pWindow); + return; + } } else { PNODE->isMaster = false; + + // first, check if it isn't too big. + if (const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(pWindow); MAXSIZE.x < PMONITOR->vecSize.x * (1 - lastSplitPercent) || MAXSIZE.y < PMONITOR->vecSize.y * (1.f / (WINDOWSONWORKSPACE - 1))) { + // we can't continue. make it floating. + pWindow->m_bIsFloating = true; + m_lMasterNodesData.remove(*PNODE); + g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(pWindow); + return; + } } // recalc -- cgit v1.2.3