summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorent Charpentier <114689807+C0Florent@users.noreply.github.com>2026-01-22 02:56:51 +1100
committerGitHub <noreply@github.com>2026-01-21 15:56:51 +0000
commit22fc8136a21676472b232f9462318e16b1d16745 (patch)
treeeedc1bf29e2a4189e1ed202325e51184dee213ef /src
parente7985ca4c4fa6ca0d96a2f303c3f0395d2d27b31 (diff)
desktop/windowRule: allow expression in min_size/max_size (#12977)
Diffstat (limited to 'src')
-rw-r--r--src/desktop/rule/windowRule/WindowRuleApplicator.cpp21
-rw-r--r--src/managers/KeybindManager.cpp16
2 files changed, 28 insertions, 9 deletions
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()); }
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index a709b0ca..74da3572 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -3164,12 +3164,22 @@ SDispatchResult CKeybindManager::setProp(std::string args) {
try {
if (PROP == "max_size") {
- PWINDOW->m_ruleApplicator->maxSizeOverride(Desktop::Types::COverridableVar(configStringToVector2D(VAL), Desktop::Types::PRIORITY_SET_PROP));
+ const auto SIZE = PWINDOW->calculateExpression(VAL);
+ if (!SIZE) {
+ Log::logger->log(Log::ERR, "failed to parse {} as an expression", VAL);
+ throw "failed to parse expression";
+ }
+ PWINDOW->m_ruleApplicator->maxSizeOverride(Desktop::Types::COverridableVar(*SIZE, Desktop::Types::PRIORITY_SET_PROP));
PWINDOW->clampWindowSize(std::nullopt, PWINDOW->m_ruleApplicator->maxSize().value());
PWINDOW->setHidden(false);
} else if (PROP == "min_size") {
- PWINDOW->m_ruleApplicator->minSizeOverride(Desktop::Types::COverridableVar(configStringToVector2D(VAL), Desktop::Types::PRIORITY_SET_PROP));
- PWINDOW->clampWindowSize(std::nullopt, PWINDOW->m_ruleApplicator->minSize().value());
+ const auto SIZE = PWINDOW->calculateExpression(VAL);
+ if (!SIZE) {
+ Log::logger->log(Log::ERR, "failed to parse {} as an expression", VAL);
+ throw "failed to parse expression";
+ }
+ PWINDOW->m_ruleApplicator->minSizeOverride(Desktop::Types::COverridableVar(*SIZE, Desktop::Types::PRIORITY_SET_PROP));
+ PWINDOW->clampWindowSize(PWINDOW->m_ruleApplicator->minSize().value(), std::nullopt);
PWINDOW->setHidden(false);
} else if (PROP == "active_border_color" || PROP == "inactive_border_color") {
CGradientValueData colorData = {};