windowrules: minor improvements to min/max size

fixes #5017
This commit is contained in:
Vaxry 2024-03-08 17:10:38 +00:00
parent d1c80c31c8
commit 4c34e4aac2
2 changed files with 16 additions and 4 deletions

View file

@ -691,7 +691,13 @@ void CWindow::applyDynamicRule(const SWindowRule& r) {
try { try {
if (!m_bIsFloating) if (!m_bIsFloating)
return; return;
m_sAdditionalConfigData.maxSize = configStringToVector2D(r.szRule.substr(8)); const auto VEC = configStringToVector2D(r.szRule.substr(8));
if (VEC.x < 1 || VEC.y < 1) {
Debug::log(ERR, "Invalid size for maxsize");
return;
}
m_sAdditionalConfigData.maxSize = VEC;
m_vRealSize = Vector2D(std::min((double)m_sAdditionalConfigData.maxSize.toUnderlying().x, m_vRealSize.goal().x), m_vRealSize = Vector2D(std::min((double)m_sAdditionalConfigData.maxSize.toUnderlying().x, m_vRealSize.goal().x),
std::min((double)m_sAdditionalConfigData.maxSize.toUnderlying().y, m_vRealSize.goal().y)); std::min((double)m_sAdditionalConfigData.maxSize.toUnderlying().y, m_vRealSize.goal().y));
g_pXWaylandManager->setWindowSize(this, m_vRealSize.goal()); g_pXWaylandManager->setWindowSize(this, m_vRealSize.goal());
@ -701,7 +707,13 @@ void CWindow::applyDynamicRule(const SWindowRule& r) {
try { try {
if (!m_bIsFloating) if (!m_bIsFloating)
return; return;
m_sAdditionalConfigData.minSize = configStringToVector2D(r.szRule.substr(8)); const auto VEC = configStringToVector2D(r.szRule.substr(8));
if (VEC.x < 1 || VEC.y < 1) {
Debug::log(ERR, "Invalid size for minsize");
return;
}
m_sAdditionalConfigData.minSize = VEC;
m_vRealSize = Vector2D(std::max((double)m_sAdditionalConfigData.minSize.toUnderlying().x, m_vRealSize.goal().x), m_vRealSize = Vector2D(std::max((double)m_sAdditionalConfigData.minSize.toUnderlying().x, m_vRealSize.goal().x),
std::max((double)m_sAdditionalConfigData.minSize.toUnderlying().y, m_vRealSize.goal().y)); std::max((double)m_sAdditionalConfigData.minSize.toUnderlying().y, m_vRealSize.goal().y));
g_pXWaylandManager->setWindowSize(this, m_vRealSize.goal()); g_pXWaylandManager->setWindowSize(this, m_vRealSize.goal());
@ -722,7 +734,7 @@ void CWindow::updateDynamicRules() {
if (!m_sAdditionalConfigData.forceOpaqueOverridden) if (!m_sAdditionalConfigData.forceOpaqueOverridden)
m_sAdditionalConfigData.forceOpaque = false; m_sAdditionalConfigData.forceOpaque = false;
m_sAdditionalConfigData.maxSize = Vector2D(std::numeric_limits<double>::max(), std::numeric_limits<double>::max()); m_sAdditionalConfigData.maxSize = Vector2D(std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
m_sAdditionalConfigData.minSize = Vector2D(1, 1); m_sAdditionalConfigData.minSize = Vector2D(20, 20);
m_sAdditionalConfigData.forceNoAnims = false; m_sAdditionalConfigData.forceNoAnims = false;
m_sAdditionalConfigData.animationStyle = std::string(""); m_sAdditionalConfigData.animationStyle = std::string("");
m_sAdditionalConfigData.rounding = -1; m_sAdditionalConfigData.rounding = -1;

View file

@ -156,7 +156,7 @@ struct SWindowAdditionalConfigData {
CWindowOverridableVar<bool> windowDanceCompat = false; CWindowOverridableVar<bool> windowDanceCompat = false;
CWindowOverridableVar<bool> noMaxSize = false; CWindowOverridableVar<bool> noMaxSize = false;
CWindowOverridableVar<Vector2D> maxSize = Vector2D(std::numeric_limits<double>::max(), std::numeric_limits<double>::max()); CWindowOverridableVar<Vector2D> maxSize = Vector2D(std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
CWindowOverridableVar<Vector2D> minSize = Vector2D(1, 1); CWindowOverridableVar<Vector2D> minSize = Vector2D(20, 20);
CWindowOverridableVar<bool> dimAround = false; CWindowOverridableVar<bool> dimAround = false;
CWindowOverridableVar<bool> forceRGBX = false; CWindowOverridableVar<bool> forceRGBX = false;
CWindowOverridableVar<bool> keepAspectRatio = false; CWindowOverridableVar<bool> keepAspectRatio = false;