#pragma once #include #include #include #include #include "../../helpers/math/Math.hpp" #include "../DesktopTypes.hpp" #include "../view/Window.hpp" namespace Desktop { struct SFloatCacheKey { size_t hash; SFloatCacheKey(PHLWINDOW window, bool initial) { // Base hash from class/title size_t baseHash = initial ? (std::hash{}(window->m_initialClass) ^ (std::hash{}(window->m_initialTitle) << 1)) : (std::hash{}(window->m_class) ^ (std::hash{}(window->m_title) << 1)); // Use empty string as default tag value std::string tagValue = ""; if (auto xdgTag = window->xdgTag()) tagValue = xdgTag.value(); // Combine hashes hash = baseHash ^ (std::hash{}(tagValue) << 2); } bool operator==(const SFloatCacheKey& other) const { return hash == other.hash; } }; } namespace std { template <> struct hash { size_t operator()(const Desktop::SFloatCacheKey& id) const { return id.hash; } }; } namespace Desktop { class CFloatStateCache { public: CFloatStateCache() = default; ~CFloatStateCache() = default; void remember(PHLWINDOW window, const Vector2D& size); std::optional get(PHLWINDOW window); private: std::unordered_map m_storedSizes; }; UP& floatState(); }