Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions hyprtester/src/tests/main/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,34 @@ static bool test() {
EXPECT(Tests::windowCount(), 0);
}

NLog::log("{}Testing minsize/maxsize rules", Colors::YELLOW);
{
// Disable size limits tiled and check if props are working and not getting skipped
OK(getFromSocket("/keyword misc:size_limits_tiled 0"));
OK(getFromSocket("/keyword windowrule[kitty-max-rule]:match:class kitty_maxsize"));
OK(getFromSocket("/keyword windowrule[kitty-max-rule]:max_size 1500 500"));
OK(getFromSocket("r/keyword windowrule[kitty-max-rule]:min_size 1200 500"));
if (!spawnKitty("kitty_maxsize"))
return false;

{
auto res = getFromSocket("/getprop active max_size");
EXPECT_CONTAINS(res, "1500");
EXPECT_CONTAINS(res, "500");
}

{
auto res = getFromSocket("/getprop active min_size");
EXPECT_CONTAINS(res, "1200");
EXPECT_CONTAINS(res, "500");
}

NLog::log("{}Reloading config", Colors::YELLOW);
OK(getFromSocket("/reload"));
Tests::killAllWindows();
EXPECT(Tests::windowCount(), 0);
}

NLog::log("{}Testing window rules", Colors::YELLOW);
if (!spawnKitty("wr_kitty"))
return false;
Expand Down
13 changes: 5 additions & 8 deletions src/desktop/rule/windowRule/WindowRuleApplicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,18 +265,16 @@ 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) {
Debug::log(ERR, "Invalid size for maxsize");
break;
}

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_minSize.first.value());
} catch (std::exception& e) { Debug::log(ERR, "maxsize rule \"{}\" failed with: {}", effect, e.what()); }
m_maxSize.second = rule->getPropertiesMask();
break;
Expand All @@ -288,17 +286,16 @@ 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) {
Debug::log(ERR, "Invalid size for maxsize");
break;
}

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(std::nullopt, m_minSize.first.value());
} catch (std::exception& e) { Debug::log(ERR, "minsize rule \"{}\" failed with: {}", effect, e.what()); }
m_minSize.second = rule->getPropertiesMask();
break;
Expand Down
Loading