diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2026-03-20 13:52:37 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-20 17:52:37 +0000 |
| commit | 8726a7363eb9213235e6e23657668e0daac39a5b (patch) | |
| tree | 42eeb40f6f81a9ccec1455f308e56173e9dcce4b /src/desktop/state/FloatState.cpp | |
| parent | b940b0d2c197841b0f648598ee782dbaf9e0a89b (diff) | |
config: cleanup the entire config infrastructure (#13785)
Massively refactors the config infrastructure, sorely
needed and will be req'd for the lua stuff
Diffstat (limited to 'src/desktop/state/FloatState.cpp')
| -rw-r--r-- | src/desktop/state/FloatState.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
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<Vector2D> 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<CFloatStateCache>& Desktop::floatState() { + static UP<CFloatStateCache> p = makeUnique<CFloatStateCache>(); + return p; +} |
