aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2022-08-05 18:10:59 +0200
committervaxerski <[email protected]>2022-08-05 18:10:59 +0200
commitcd37a1533e0e86fffdd333e18bab0bb730c1dc25 (patch)
treefb32becc5c231a19b80fb911a8d60a1ce41869b1
parent575434f1a4cfce30cf89b62e5f1cce4b3c326b6e (diff)
downloadHyprland-cd37a1533e0e86fffdd333e18bab0bb730c1dc25.tar.gz
Hyprland-cd37a1533e0e86fffdd333e18bab0bb730c1dc25.zip
reject tiling windows that do not meet the max size requirement
-rw-r--r--src/layout/DwindleLayout.cpp9
-rw-r--r--src/layout/IHyprLayout.cpp9
-rw-r--r--src/layout/MasterLayout.cpp20
-rw-r--r--src/managers/XWaylandManager.cpp14
-rw-r--r--src/managers/XWaylandManager.hpp1
5 files changed, 44 insertions, 9 deletions
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<CHyprXWaylandManager> g_pXWaylandManager; \ No newline at end of file