From b80b64cd6c913f8c8ac820a1e4ca615a62ff958f Mon Sep 17 00:00:00 2001 From: nyx Date: Fri, 7 Mar 2025 20:12:02 -0500 Subject: windowrules: add option to allow size persistence between app launches (#9422) --- src/config/ConfigManager.hpp | 52 +++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 13 deletions(-) (limited to 'src/config/ConfigManager.hpp') diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index d9ea413e..7ce378b1 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -138,6 +138,27 @@ struct SFirstExecRequest { bool withRules = false; }; +struct SFloatCache { + size_t hash; + + SFloatCache(PHLWINDOW window) { + hash = std::hash{}(window->m_szClass) ^ (std::hash{}(window->m_szTitle) << 1); + } + + bool operator==(const SFloatCache& other) const { + return hash == other.hash; + } +}; + +namespace std { + template <> + struct hash { + size_t operator()(const SFloatCache& id) const { + return id.hash; + } + }; +} + class CConfigManager { public: CConfigManager(); @@ -232,6 +253,9 @@ class CConfigManager { bool isLaunchingExecOnce = false; // For exec-once to skip initial ws tracking bool m_bLastConfigVerificationWasSuccessful = true; + void storeFloatingSize(PHLWINDOW window, const Vector2D& size); + std::optional getStoredFloatingSize(PHLWINDOW window); + private: UP m_pConfig; @@ -267,19 +291,21 @@ class CConfigManager { uint32_t m_configValueNumber = 0; // internal methods - void updateBlurredLS(const std::string&, const bool); - void setDefaultAnimationVars(); - std::optional resetHLConfig(); - std::optional generateConfig(std::string configPath); - std::optional verifyConfigExists(); - void postConfigReload(const Hyprlang::CParseResult& result); - SWorkspaceRule mergeWorkspaceRules(const SWorkspaceRule&, const SWorkspaceRule&); - - void registerConfigVar(const char* name, const Hyprlang::INT& val); - void registerConfigVar(const char* name, const Hyprlang::FLOAT& val); - void registerConfigVar(const char* name, const Hyprlang::VEC2& val); - void registerConfigVar(const char* name, const Hyprlang::STRING& val); - void registerConfigVar(const char* name, Hyprlang::CUSTOMTYPE&& val); + void updateBlurredLS(const std::string&, const bool); + void setDefaultAnimationVars(); + std::optional resetHLConfig(); + std::optional generateConfig(std::string configPath); + std::optional verifyConfigExists(); + void postConfigReload(const Hyprlang::CParseResult& result); + SWorkspaceRule mergeWorkspaceRules(const SWorkspaceRule&, const SWorkspaceRule&); + + void registerConfigVar(const char* name, const Hyprlang::INT& val); + void registerConfigVar(const char* name, const Hyprlang::FLOAT& val); + void registerConfigVar(const char* name, const Hyprlang::VEC2& val); + void registerConfigVar(const char* name, const Hyprlang::STRING& val); + void registerConfigVar(const char* name, Hyprlang::CUSTOMTYPE&& val); + + std::unordered_map m_mStoredFloatingSizes; friend struct SConfigOptionDescription; }; -- cgit v1.2.3