summaryrefslogtreecommitdiff
path: root/src/desktop/rule/windowRule/WindowRule.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/desktop/rule/windowRule/WindowRule.hpp')
-rw-r--r--src/desktop/rule/windowRule/WindowRule.hpp50
1 files changed, 39 insertions, 11 deletions
diff --git a/src/desktop/rule/windowRule/WindowRule.hpp b/src/desktop/rule/windowRule/WindowRule.hpp
index 875c9ece..19560c15 100644
--- a/src/desktop/rule/windowRule/WindowRule.hpp
+++ b/src/desktop/rule/windowRule/WindowRule.hpp
@@ -2,14 +2,42 @@
#include "../Rule.hpp"
#include "../../DesktopTypes.hpp"
+#include "../../types/OverridableVar.hpp"
#include "WindowRuleEffectContainer.hpp"
+#include "../../../config/shared/complex/ComplexDataTypes.hpp"
#include "../../../helpers/math/Math.hpp"
+#include <expected>
#include <unordered_set>
+#include <variant>
namespace Desktop::Rule {
constexpr const char* EXEC_RULE_ENV_NAME = "HL_EXEC_RULE_TOKEN";
+ struct SFullscreenStateRule {
+ int internal = 0;
+ std::optional<int> client;
+ };
+
+ struct SOpacityRule {
+ Types::SAlphaValue alpha;
+ Types::SAlphaValue alphaInactive;
+ Types::SAlphaValue alphaFullscreen;
+ };
+
+ struct SBorderColorRule {
+ Config::CGradientValueData active;
+ std::optional<Config::CGradientValueData> inactive;
+ };
+
+ using WindowRuleEffectValue = std::variant<std::monostate, bool, int64_t, float, std::string, std::vector<std::string>, SFullscreenStateRule, SOpacityRule, SBorderColorRule>;
+
+ struct SWindowRuleEffect {
+ CWindowRuleEffectContainer::storageType key = WINDOW_RULE_EFFECT_NONE;
+ std::string raw;
+ WindowRuleEffectValue value;
+ };
+
class CWindowRule : public IRule {
private:
using storageType = CWindowRuleEffectContainer::storageType;
@@ -22,22 +50,22 @@ namespace Desktop::Rule {
CWindowRule(CWindowRule&) = default;
CWindowRule(CWindowRule&&) = default;
- static SP<CWindowRule> buildFromExecString(std::string&&);
+ static std::expected<SP<CWindowRule>, std::string> buildFromExecString(std::string&&);
- virtual eRuleType type();
+ virtual eRuleType type();
- void addEffect(storageType e, const std::string& result);
- const std::vector<std::pair<storageType, std::string>>& effects();
- const std::unordered_set<storageType>& effectsSet();
+ std::expected<void, std::string> addEffect(storageType e, const std::string& result);
+ const std::vector<SWindowRuleEffect>& effects();
+ const std::unordered_set<storageType>& effectsSet();
- void setEnabled(bool enable);
- bool isEnabled() const;
+ void setEnabled(bool enable);
+ bool isEnabled() const;
- bool matches(PHLWINDOW w, bool allowEnvLookup = false);
+ bool matches(PHLWINDOW w, bool allowEnvLookup = false);
private:
- std::vector<std::pair<storageType, std::string>> m_effects;
- std::unordered_set<storageType> m_effectSet;
- bool m_enabled = true;
+ std::vector<SWindowRuleEffect> m_effects;
+ std::unordered_set<storageType> m_effectSet;
+ bool m_enabled = true;
};
};