diff --git a/hyprtester/src/tests/main/window.cpp b/hyprtester/src/tests/main/window.cpp index 0a2e31d0..fbaffa18 100644 --- a/hyprtester/src/tests/main/window.cpp +++ b/hyprtester/src/tests/main/window.cpp @@ -447,6 +447,39 @@ static void testBringActiveToTopMouseMovement() { Tests::killAllWindows(); } +static void testInitialFloatSize() { + NLog::log("{}Testing initial float size", Colors::GREEN); + + Tests::killAllWindows(); + OK(getFromSocket("/keyword windowrule match:class kitty, float yes")); + OK(getFromSocket("/keyword input:float_switch_override_focus 0")); + + EXPECT(spawnKitty("kitty"), true); + + { + // Kitty by default opens as 640x400, if this changes this test will break + auto str = getFromSocket("/clients"); + EXPECT(str.contains("size: 640,400"), true); + } + + OK(getFromSocket("/reload")); + + Tests::killAllWindows(); + + OK(getFromSocket("/dispatch exec [float yes]kitty")); + + Tests::waitUntilWindowsN(1); + + { + // Kitty by default opens as 640x400, if this changes this test will break + auto str = getFromSocket("/clients"); + EXPECT(str.contains("size: 640,400"), true); + EXPECT(str.contains("floating: 1"), true); + } + + Tests::killAllWindows(); +} + static bool test() { NLog::log("{}Testing windows", Colors::GREEN); @@ -877,12 +910,10 @@ static bool test() { Tests::killAllWindows(); testGroupRules(); - testMaximizeSize(); - testBringActiveToTopMouseMovement(); - testGroupFallbackFocus(); + testInitialFloatSize(); NLog::log("{}Reloading config", Colors::YELLOW); OK(getFromSocket("/reload")); diff --git a/nix/tests/default.nix b/nix/tests/default.nix index bdb3fe7c..df666e62 100644 --- a/nix/tests/default.nix +++ b/nix/tests/default.nix @@ -27,6 +27,9 @@ in { environment.etc."kitty/kitty.conf".text = '' confirm_os_window_close 0 + remember_window_size no + initial_window_width 640 + initial_window_height 400 ''; programs.hyprland = { diff --git a/src/desktop/rule/matchEngine/WorkspaceMatchEngine.cpp b/src/desktop/rule/matchEngine/WorkspaceMatchEngine.cpp index abaa1657..fea5c384 100644 --- a/src/desktop/rule/matchEngine/WorkspaceMatchEngine.cpp +++ b/src/desktop/rule/matchEngine/WorkspaceMatchEngine.cpp @@ -8,5 +8,5 @@ CWorkspaceMatchEngine::CWorkspaceMatchEngine(const std::string& s) : m_value(s) } bool CWorkspaceMatchEngine::match(PHLWORKSPACE ws) { - return ws->matchesStaticSelector(m_value); + return ws && ws->matchesStaticSelector(m_value); } diff --git a/src/desktop/rule/windowRule/WindowRuleApplicator.cpp b/src/desktop/rule/windowRule/WindowRuleApplicator.cpp index 0b6cba0f..cb3a6f67 100644 --- a/src/desktop/rule/windowRule/WindowRuleApplicator.cpp +++ b/src/desktop/rule/windowRule/WindowRuleApplicator.cpp @@ -537,7 +537,7 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyStaticRule(const return SRuleResult{}; } -void CWindowRuleApplicator::readStaticRules() { +void CWindowRuleApplicator::readStaticRules(bool preRead) { if (!m_window) return; @@ -592,7 +592,8 @@ void CWindowRuleApplicator::readStaticRules() { for (const auto& wr : execRules) { applyStaticRule(wr); applyDynamicRule(wr); - ruleEngine()->unregisterRule(wr); + if (!preRead) + ruleEngine()->unregisterRule(wr); } } diff --git a/src/desktop/rule/windowRule/WindowRuleApplicator.hpp b/src/desktop/rule/windowRule/WindowRuleApplicator.hpp index 121de727..5c1d4fd1 100644 --- a/src/desktop/rule/windowRule/WindowRuleApplicator.hpp +++ b/src/desktop/rule/windowRule/WindowRuleApplicator.hpp @@ -33,8 +33,7 @@ namespace Desktop::Rule { void propertiesChanged(std::underlying_type_t props); std::unordered_set resetProps(std::underlying_type_t props, Types::eOverridePriority prio = Types::PRIORITY_WINDOW_RULE); - void readStaticRules(); - void applyStaticRules(); + void readStaticRules(bool preRead = false); // static props struct { diff --git a/src/desktop/view/Window.cpp b/src/desktop/view/Window.cpp index 3031284c..a22f4a9d 100644 --- a/src/desktop/view/Window.cpp +++ b/src/desktop/view/Window.cpp @@ -2546,6 +2546,9 @@ void CWindow::unmapWindow() { void CWindow::commitWindow() { if (!m_isX11 && m_xdgSurface->m_initialCommit) { + // try to calculate static rules already for any floats + m_ruleApplicator->readStaticRules(true); + Vector2D predSize = g_pLayoutManager->getCurrentLayout()->predictSizeForNewWindow(m_self.lock()); Log::logger->log(Log::DEBUG, "Layout predicts size {} for {}", predSize, m_self.lock());