summaryrefslogtreecommitdiff
path: root/src/desktop/Window.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-11-17 19:31:54 +0000
committerVaxry <vaxry@vaxry.net>2024-11-17 19:31:54 +0000
commitb735295d2b0025b26f88852c06f65514a963c711 (patch)
tree166560e38a396af304db4ec28ca14ba7bb7eedba /src/desktop/Window.cpp
parent8d5cdedbd350b4730a1aa57dc5491c88dff3415e (diff)
windows/xdg: minor cleanup of min/max size calculations
fixes #8495
Diffstat (limited to 'src/desktop/Window.cpp')
-rw-r--r--src/desktop/Window.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp
index 20fed565..e74e13a2 100644
--- a/src/desktop/Window.cpp
+++ b/src/desktop/Window.cpp
@@ -1601,3 +1601,29 @@ bool CWindow::isX11OverrideRedirect() {
bool CWindow::isModal() {
return (m_pXWaylandSurface && m_pXWaylandSurface->modal);
}
+
+Vector2D CWindow::requestedMinSize() {
+ if ((m_bIsX11 && !m_pXWaylandSurface->sizeHints) || (!m_bIsX11 && !m_pXDGSurface->toplevel))
+ return Vector2D(1, 1);
+
+ Vector2D minSize = m_bIsX11 ? Vector2D(m_pXWaylandSurface->sizeHints->min_width, m_pXWaylandSurface->sizeHints->min_height) : m_pXDGSurface->toplevel->layoutMinSize();
+
+ minSize = minSize.clamp({1, 1});
+
+ return minSize;
+}
+
+Vector2D CWindow::requestedMaxSize() {
+ constexpr int NO_MAX_SIZE_LIMIT = 99999;
+ if (((m_bIsX11 && !m_pXWaylandSurface->sizeHints) || (!m_bIsX11 && !m_pXDGSurface->toplevel) || m_sWindowData.noMaxSize.valueOrDefault()))
+ return Vector2D(NO_MAX_SIZE_LIMIT, NO_MAX_SIZE_LIMIT);
+
+ Vector2D maxSize = m_bIsX11 ? Vector2D(m_pXWaylandSurface->sizeHints->max_width, m_pXWaylandSurface->sizeHints->max_height) : m_pXDGSurface->toplevel->layoutMaxSize();
+
+ if (maxSize.x < 5)
+ maxSize.x = NO_MAX_SIZE_LIMIT;
+ if (maxSize.y < 5)
+ maxSize.y = NO_MAX_SIZE_LIMIT;
+
+ return maxSize;
+}