diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 6abcaf5f..f779147e 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -246,6 +246,15 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) { OPENINGON = getFirstNodeOnWorkspace(PNODE->workspaceID); } + // first, check if OPENINGON isn't too big. + if (const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(pWindow); MAXSIZE.x < OPENINGON->size.x || MAXSIZE.y < OPENINGON->size.y) { + // we can't continue. make it floating. + pWindow->m_bIsFloating = true; + m_lDwindleNodesData.remove(*PNODE); + g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(pWindow); + return; + } + // if it's the first, it's easy. Make it fullscreen. if (!OPENINGON || OPENINGON->pWindow == pWindow) { PNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft; diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 48e6b005..bbe30e5b 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -184,14 +184,7 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) { } else { if (DRAGGINGWINDOW->m_bIsFloating) { - auto MAXSIZE = DRAGGINGWINDOW->m_bIsX11 ? - Vector2D(DRAGGINGWINDOW->m_uSurface.xwayland->size_hints->max_width, DRAGGINGWINDOW->m_uSurface.xwayland->size_hints->max_height) - : Vector2D(DRAGGINGWINDOW->m_uSurface.xdg->toplevel->current.max_width, DRAGGINGWINDOW->m_uSurface.xdg->toplevel->current.max_height); - - if (MAXSIZE.x < 5) - MAXSIZE.x = 99999; - if (MAXSIZE.y < 5) - MAXSIZE.y = 99999; + const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(DRAGGINGWINDOW); DRAGGINGWINDOW->m_vRealSize.setValueAndWarp(m_vBeginDragSizeXY + DELTA); DRAGGINGWINDOW->m_vRealSize.setValueAndWarp(Vector2D(std::clamp(DRAGGINGWINDOW->m_vRealSize.vec().x, (double)20, (double)MAXSIZE.x), std::clamp(DRAGGINGWINDOW->m_vRealSize.vec().y, (double)20, (double)MAXSIZE.y))); 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 diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index 11e32917..5688a849 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -230,4 +230,16 @@ void CHyprXWaylandManager::setWindowFullscreen(CWindow* pWindow, bool fullscreen if (pWindow->m_phForeignToplevel) wlr_foreign_toplevel_handle_v1_set_fullscreen(pWindow->m_phForeignToplevel, fullscreen); -} \ No newline at end of file +} + +Vector2D CHyprXWaylandManager::getMaxSizeForWindow(CWindow* pWindow) { + auto MAXSIZE = pWindow->m_bIsX11 ? Vector2D(pWindow->m_uSurface.xwayland->size_hints->max_width, pWindow->m_uSurface.xwayland->size_hints->max_height) + : Vector2D(pWindow->m_uSurface.xdg->toplevel->current.max_width, pWindow->m_uSurface.xdg->toplevel->current.max_height); + + if (MAXSIZE.x < 5) + MAXSIZE.x = 99999; + if (MAXSIZE.y < 5) + MAXSIZE.y = 99999; + + return MAXSIZE; +} diff --git a/src/managers/XWaylandManager.hpp b/src/managers/XWaylandManager.hpp index 561865e4..3d8f57f2 100644 --- a/src/managers/XWaylandManager.hpp +++ b/src/managers/XWaylandManager.hpp @@ -24,6 +24,7 @@ public: bool shouldBeFloated(CWindow*); void moveXWaylandWindow(CWindow*, const Vector2D&); void checkBorders(CWindow*); + Vector2D getMaxSizeForWindow(CWindow*); }; inline std::unique_ptr g_pXWaylandManager; \ No newline at end of file