From 22fc8136a21676472b232f9462318e16b1d16745 Mon Sep 17 00:00:00 2001 From: Florent Charpentier <114689807+C0Florent@users.noreply.github.com> Date: Thu, 22 Jan 2026 02:56:51 +1100 Subject: desktop/windowRule: allow expression in min_size/max_size (#12977) --- .../rule/windowRule/WindowRuleApplicator.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/desktop/rule/windowRule/WindowRuleApplicator.cpp') diff --git a/src/desktop/rule/windowRule/WindowRuleApplicator.cpp b/src/desktop/rule/windowRule/WindowRuleApplicator.cpp index 9a3f4f63..037f8938 100644 --- a/src/desktop/rule/windowRule/WindowRuleApplicator.cpp +++ b/src/desktop/rule/windowRule/WindowRuleApplicator.cpp @@ -265,13 +265,17 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const if (!m_window) break; - const auto VEC = configStringToVector2D(effect); - if (VEC.x < 1 || VEC.y < 1) { + const auto VEC = m_window->calculateExpression(effect); + if (!VEC) { + Log::logger->log(Log::ERR, "failed to parse {} as an expression", effect); + break; + } + if (VEC->x < 1 || VEC->y < 1) { Log::logger->log(Log::ERR, "Invalid size for maxsize"); break; } - m_maxSize.first = Types::COverridableVar(VEC, Types::PRIORITY_WINDOW_RULE); + m_maxSize.first = Types::COverridableVar(*VEC, Types::PRIORITY_WINDOW_RULE); if (*PCLAMP_TILED || m_window->m_isFloating) m_window->clampWindowSize(std::nullopt, m_maxSize.first.value()); @@ -286,13 +290,18 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const if (!m_window) break; - const auto VEC = configStringToVector2D(effect); - if (VEC.x < 1 || VEC.y < 1) { + const auto VEC = m_window->calculateExpression(effect); + if (!VEC) { + Log::logger->log(Log::ERR, "failed to parse {} as an expression", effect); + break; + } + + if (VEC->x < 1 || VEC->y < 1) { Log::logger->log(Log::ERR, "Invalid size for maxsize"); break; } - m_minSize.first = Types::COverridableVar(VEC, Types::PRIORITY_WINDOW_RULE); + m_minSize.first = Types::COverridableVar(*VEC, Types::PRIORITY_WINDOW_RULE); 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()); } -- cgit v1.2.3