desktop/windowRule: allow expression in min_size/max_size (#12977)
This commit is contained in:
parent
e7985ca4c4
commit
22fc8136a2
4 changed files with 48 additions and 10 deletions
|
|
@ -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()); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue