From 8726a7363eb9213235e6e23657668e0daac39a5b Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Fri, 20 Mar 2026 13:52:37 -0400 Subject: config: cleanup the entire config infrastructure (#13785) Massively refactors the config infrastructure, sorely needed and will be req'd for the lua stuff --- src/desktop/state/FloatState.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/desktop/state/FloatState.cpp (limited to 'src/desktop/state/FloatState.cpp') diff --git a/src/desktop/state/FloatState.cpp b/src/desktop/state/FloatState.cpp new file mode 100644 index 00000000..2ec5be3a --- /dev/null +++ b/src/desktop/state/FloatState.cpp @@ -0,0 +1,30 @@ +#include "FloatState.hpp" + +using namespace Desktop; + +void CFloatStateCache::remember(PHLWINDOW window, const Vector2D& size) { + Log::logger->log(Log::DEBUG, "[floatStateCache] storing floating size {}x{} for window {}::{}", size.x, size.y, window->m_initialClass, window->m_initialTitle); + // true -> use m_initialClass and m_initialTitle + SFloatCacheKey id{window, true}; + m_storedSizes[id] = size; +} + +std::optional CFloatStateCache::get(PHLWINDOW window) { + // At startup, m_initialClass and m_initialTitle are undefined + // and m_class and m_title are just "initial" ones. + // false -> use m_class and m_title + SFloatCacheKey id{window, false}; + Log::logger->log(Log::DEBUG, "[floatStateCache] Hash for window {}::{} = {}", window->m_class, window->m_title, id.hash); + + if (m_storedSizes.contains(id)) { + Log::logger->log(Log::DEBUG, "[floatStateCache] got stored size {}x{} for window {}::{}", m_storedSizes[id].x, m_storedSizes[id].y, window->m_class, window->m_title); + return m_storedSizes[id]; + } + + return std::nullopt; +} + +UP& Desktop::floatState() { + static UP p = makeUnique(); + return p; +} -- cgit v1.2.3