summaryrefslogtreecommitdiff
path: root/src/desktop
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2025-12-27 12:43:45 +0100
committerGitHub <noreply@github.com>2025-12-27 12:43:45 +0100
commit42447a50d6840c5e28bd58db1225bae2fd7d5ed0 (patch)
treee73584ecd482bf5320a3e35f963a12787ce7cce5 /src/desktop
parentd7f26038ee2b44f3d02fe2a7556bafb91a02f46e (diff)
rules/windowRuleApplicator: fix min/max size effects (#12491)
fixes #12412
Diffstat (limited to 'src/desktop')
-rw-r--r--src/desktop/rule/windowRule/WindowRuleApplicator.cpp12
-rw-r--r--src/desktop/view/WLSurface.cpp2
-rw-r--r--src/desktop/view/Window.cpp73
-rw-r--r--src/desktop/view/Window.hpp2
4 files changed, 49 insertions, 40 deletions
diff --git a/src/desktop/rule/windowRule/WindowRuleApplicator.cpp b/src/desktop/rule/windowRule/WindowRuleApplicator.cpp
index ab1c2a14..0b6cba0f 100644
--- a/src/desktop/rule/windowRule/WindowRuleApplicator.cpp
+++ b/src/desktop/rule/windowRule/WindowRuleApplicator.cpp
@@ -265,9 +265,6 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const
if (!m_window)
break;
- if (!m_window->m_isFloating && !sc<bool>(*PCLAMP_TILED))
- break;
-
const auto VEC = configStringToVector2D(effect);
if (VEC.x < 1 || VEC.y < 1) {
Log::logger->log(Log::ERR, "Invalid size for maxsize");
@@ -275,8 +272,9 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const
}
m_maxSize.first = Types::COverridableVar(VEC, Types::PRIORITY_WINDOW_RULE);
- m_window->clampWindowSize(std::nullopt, m_maxSize.first.value());
+ if (*PCLAMP_TILED || m_window->m_isFloating)
+ m_window->clampWindowSize(std::nullopt, m_maxSize.first.value());
} catch (std::exception& e) { Log::logger->log(Log::ERR, "maxsize rule \"{}\" failed with: {}", effect, e.what()); }
m_maxSize.second = rule->getPropertiesMask();
break;
@@ -288,9 +286,6 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const
if (!m_window)
break;
- if (!m_window->m_isFloating && !sc<bool>(*PCLAMP_TILED))
- break;
-
const auto VEC = configStringToVector2D(effect);
if (VEC.x < 1 || VEC.y < 1) {
Log::logger->log(Log::ERR, "Invalid size for maxsize");
@@ -298,7 +293,8 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const
}
m_minSize.first = Types::COverridableVar(VEC, Types::PRIORITY_WINDOW_RULE);
- m_window->clampWindowSize(std::nullopt, m_minSize.first.value());
+ if (*PCLAMP_TILED || m_window->m_isFloating)
+ m_window->clampWindowSize(m_minSize.first.value(), std::nullopt);
} catch (std::exception& e) { Log::logger->log(Log::ERR, "minsize rule \"{}\" failed with: {}", effect, e.what()); }
m_minSize.second = rule->getPropertiesMask();
break;
diff --git a/src/desktop/view/WLSurface.cpp b/src/desktop/view/WLSurface.cpp
index 9d46aad1..ae8a22e2 100644
--- a/src/desktop/view/WLSurface.cpp
+++ b/src/desktop/view/WLSurface.cpp
@@ -83,7 +83,7 @@ CRegion CWLSurface::computeDamage() const {
return {};
CRegion damage = m_resource->m_current.accumulateBufferDamage();
- damage.transform(wlTransformToHyprutils(m_resource->m_current.transform), m_resource->m_current.bufferSize.x, m_resource->m_current.bufferSize.y);
+ damage.transform(Math::wlTransformToHyprutils(m_resource->m_current.transform), m_resource->m_current.bufferSize.x, m_resource->m_current.bufferSize.y);
const auto BUFSIZE = m_resource->m_current.bufferSize;
const auto CORRECTVEC = correctSmallVecBuf();
diff --git a/src/desktop/view/Window.cpp b/src/desktop/view/Window.cpp
index 32a0086e..695ba81f 100644
--- a/src/desktop/view/Window.cpp
+++ b/src/desktop/view/Window.cpp
@@ -1574,41 +1574,13 @@ bool CWindow::isModal() {
return (m_xwaylandSurface && m_xwaylandSurface->m_modal);
}
-Vector2D CWindow::requestedMinSize() {
- bool hasSizeHints = m_xwaylandSurface ? m_xwaylandSurface->m_sizeHints : false;
- bool hasTopLevel = m_xdgSurface ? m_xdgSurface->m_toplevel : false;
- if ((m_isX11 && !hasSizeHints) || (!m_isX11 && !hasTopLevel))
- return Vector2D(1, 1);
-
- Vector2D minSize = m_isX11 ? Vector2D(m_xwaylandSurface->m_sizeHints->min_width, m_xwaylandSurface->m_sizeHints->min_height) : m_xdgSurface->m_toplevel->layoutMinSize();
-
- minSize = minSize.clamp({1, 1});
-
- return minSize;
-}
-
-Vector2D CWindow::requestedMaxSize() {
- constexpr int NO_MAX_SIZE_LIMIT = 99999;
- if (((m_isX11 && !m_xwaylandSurface->m_sizeHints) || (!m_isX11 && (!m_xdgSurface || !m_xdgSurface->m_toplevel)) || m_ruleApplicator->noMaxSize().valueOrDefault()))
- return Vector2D(NO_MAX_SIZE_LIMIT, NO_MAX_SIZE_LIMIT);
-
- Vector2D maxSize = m_isX11 ? Vector2D(m_xwaylandSurface->m_sizeHints->max_width, m_xwaylandSurface->m_sizeHints->max_height) : m_xdgSurface->m_toplevel->layoutMaxSize();
-
- if (maxSize.x < 5)
- maxSize.x = NO_MAX_SIZE_LIMIT;
- if (maxSize.y < 5)
- maxSize.y = NO_MAX_SIZE_LIMIT;
-
- return maxSize;
-}
-
Vector2D CWindow::realToReportSize() {
if (!m_isX11)
- return m_realSize->goal().clamp(Vector2D{0, 0}, Vector2D{std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity()});
+ return m_realSize->goal().clamp(Vector2D{0, 0}, Math::VECTOR2D_MAX);
static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling");
- const auto REPORTSIZE = m_realSize->goal().clamp(Vector2D{1, 1}, Vector2D{std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity()});
+ const auto REPORTSIZE = m_realSize->goal().clamp(Vector2D{1, 1}, Math::VECTOR2D_MAX);
const auto PMONITOR = m_monitor.lock();
if (*PXWLFORCESCALEZERO && PMONITOR)
@@ -1628,7 +1600,7 @@ Vector2D CWindow::xwaylandSizeToReal(Vector2D size) {
static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling");
const auto PMONITOR = m_monitor.lock();
- const auto SIZE = size.clamp(Vector2D{1, 1}, Vector2D{std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity()});
+ const auto SIZE = size.clamp(Vector2D{1, 1}, Math::VECTOR2D_MAX);
const auto SCALE = *PXWLFORCESCALEZERO ? PMONITOR->m_scale : 1.0f;
return SIZE / SCALE;
@@ -2718,3 +2690,42 @@ void CWindow::unmanagedSetGeometry() {
m_pendingReportedSize = m_realSize->goal();
}
}
+
+std::optional<Vector2D> CWindow::minSize() {
+ // first check for overrides
+ if (m_ruleApplicator->minSize().hasValue())
+ return m_ruleApplicator->minSize().value();
+
+ // then check if we have any proto overrides
+ bool hasSizeHints = m_xwaylandSurface ? m_xwaylandSurface->m_sizeHints : false;
+ bool hasTopLevel = m_xdgSurface ? m_xdgSurface->m_toplevel : false;
+ if ((m_isX11 && !hasSizeHints) || (!m_isX11 && !hasTopLevel))
+ return std::nullopt;
+
+ Vector2D minSize = m_isX11 ? Vector2D(m_xwaylandSurface->m_sizeHints->min_width, m_xwaylandSurface->m_sizeHints->min_height) : m_xdgSurface->m_toplevel->layoutMinSize();
+
+ minSize = minSize.clamp({1, 1});
+
+ return minSize;
+}
+
+std::optional<Vector2D> CWindow::maxSize() {
+ // first check for overrides
+ if (m_ruleApplicator->maxSize().hasValue())
+ return m_ruleApplicator->maxSize().value();
+
+ // then check if we have any proto overrides
+ if (((m_isX11 && !m_xwaylandSurface->m_sizeHints) || (!m_isX11 && (!m_xdgSurface || !m_xdgSurface->m_toplevel)) || m_ruleApplicator->noMaxSize().valueOrDefault()))
+ return std::nullopt;
+
+ constexpr const double NO_MAX_SIZE_LIMIT = std::numeric_limits<double>::max();
+
+ Vector2D maxSize = m_isX11 ? Vector2D(m_xwaylandSurface->m_sizeHints->max_width, m_xwaylandSurface->m_sizeHints->max_height) : m_xdgSurface->m_toplevel->layoutMaxSize();
+
+ if (maxSize.x < 5)
+ maxSize.x = NO_MAX_SIZE_LIMIT;
+ if (maxSize.y < 5)
+ maxSize.y = NO_MAX_SIZE_LIMIT;
+
+ return maxSize;
+}
diff --git a/src/desktop/view/Window.hpp b/src/desktop/view/Window.hpp
index d5c86aac..3c36283d 100644
--- a/src/desktop/view/Window.hpp
+++ b/src/desktop/view/Window.hpp
@@ -347,6 +347,8 @@ namespace Desktop::View {
SP<CWLSurfaceResource> getSolitaryResource();
Vector2D getReportedSize();
std::optional<Vector2D> calculateExpression(const std::string& s);
+ std::optional<Vector2D> minSize();
+ std::optional<Vector2D> maxSize();
CBox getWindowMainSurfaceBox() const {
return {m_realPosition->value().x, m_realPosition->value().y, m_realSize->value().x, m_realSize->value().y};