From 930eeac900c60d147bf26491e15b0727605b3944 Mon Sep 17 00:00:00 2001 From: Jack Barnes <135401840+yuukibarns@users.noreply.github.com> Date: Tue, 6 May 2025 09:53:43 +0800 Subject: window: use stored size for new floating window when persistentsize is set (#10212) * fix(window): use stored size for new floating window when persistentsize is set. fix hyprwm#9422. * fix: replace `std::any_of` with `std::ranges:any_of` * fix: use initialClass and initialTitle when storing sizes on close * fix: add `xdgTag` as a new indicator * fix: no {} * fix: format with clang-format --- src/layout/IHyprLayout.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/layout/IHyprLayout.cpp') diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index e1077a93..96dea105 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -17,8 +17,7 @@ void IHyprLayout::onWindowCreated(PHLWINDOW pWindow, eDirection direction) { CBox desiredGeometry = g_pXWaylandManager->getGeometryForWindow(pWindow); - const bool HASPERSISTENTSIZE = - std::any_of(pWindow->m_matchedRules.begin(), pWindow->m_matchedRules.end(), [](const auto& rule) { return rule->m_ruleType == CWindowRule::RULE_PERSISTENTSIZE; }); + const bool HASPERSISTENTSIZE = std::ranges::any_of(pWindow->m_matchedRules, [](const auto& rule) { return rule->m_ruleType == CWindowRule::RULE_PERSISTENTSIZE; }); const auto STOREDSIZE = HASPERSISTENTSIZE ? g_pConfigManager->getStoredFloatingSize(pWindow) : std::nullopt; @@ -886,6 +885,17 @@ void IHyprLayout::requestFocusForWindow(PHLWINDOW pWindow) { Vector2D IHyprLayout::predictSizeForNewWindowFloating(PHLWINDOW pWindow) { // get all rules, see if we have any size overrides. Vector2D sizeOverride = {}; if (g_pCompositor->m_lastMonitor) { + + // If `persistentsize` is set, use the stored size if available. + const bool HASPERSISTENTSIZE = std::ranges::any_of(pWindow->m_matchedRules, [](const auto& rule) { return rule->m_ruleType == CWindowRule::RULE_PERSISTENTSIZE; }); + + const auto STOREDSIZE = HASPERSISTENTSIZE ? g_pConfigManager->getStoredFloatingSize(pWindow) : std::nullopt; + + if (STOREDSIZE.has_value()) { + Debug::log(LOG, "using stored size {}x{} for new floating window {}::{}", STOREDSIZE->x, STOREDSIZE->y, pWindow->m_class, pWindow->m_title); + return STOREDSIZE.value(); + } + for (auto const& r : g_pConfigManager->getMatchingRules(pWindow, true, true)) { if (r->m_ruleType != CWindowRule::RULE_SIZE) continue; -- cgit v1.2.3