summaryrefslogtreecommitdiff
path: root/src/config/ConfigManager.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2023-01-25 15:34:13 +0000
committervaxerski <43317083+vaxerski@users.noreply.github.com>2023-01-25 15:34:13 +0000
commit8ae1fd01730ebd8382d850d1d5526fee0fb076f1 (patch)
tree04db54c3ef3cc62cc2a29b501329f1d127770252 /src/config/ConfigManager.cpp
parent9813ba2f567a2e489b95bf15168cdcd26a31bec9 (diff)
added layer rules
Diffstat (limited to 'src/config/ConfigManager.cpp')
-rw-r--r--src/config/ConfigManager.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 397ec6c9..0c8ca2f0 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -740,6 +740,10 @@ bool windowRuleValid(const std::string& RULE) {
RULE.find("rounding") != 0 && RULE.find("workspace") != 0 && RULE.find("bordercolor") != 0);
}
+bool layerRuleValid(const std::string& RULE) {
+ return !(RULE != "noanim");
+}
+
void CConfigManager::handleWindowRule(const std::string& command, const std::string& value) {
const auto RULE = removeBeginEndSpacesTabs(value.substr(0, value.find_first_of(',')));
const auto VALUE = removeBeginEndSpacesTabs(value.substr(value.find_first_of(',') + 1));
@@ -764,6 +768,29 @@ void CConfigManager::handleWindowRule(const std::string& command, const std::str
m_dWindowRules.push_back({RULE, VALUE});
}
+void CConfigManager::handleLayerRule(const std::string& command, const std::string& value) {
+ const auto RULE = removeBeginEndSpacesTabs(value.substr(0, value.find_first_of(',')));
+ const auto VALUE = removeBeginEndSpacesTabs(value.substr(value.find_first_of(',') + 1));
+
+ // check rule and value
+ if (RULE == "" || VALUE == "") {
+ return;
+ }
+
+ if (RULE == "unset") {
+ std::erase_if(m_dLayerRules, [&](const SLayerRule& other) { return other.targetNamespace == VALUE; });
+ return;
+ }
+
+ if (!layerRuleValid(RULE)) {
+ Debug::log(ERR, "Invalid rule found: %s", RULE.c_str());
+ parseError = "Invalid rule found: " + RULE;
+ return;
+ }
+
+ m_dLayerRules.push_back({VALUE, RULE});
+}
+
void CConfigManager::handleWindowRuleV2(const std::string& command, const std::string& value) {
const auto RULE = value.substr(0, value.find_first_of(','));
const auto VALUE = value.substr(value.find_first_of(',') + 1);
@@ -1009,6 +1036,8 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
handleWindowRule(COMMAND, VALUE);
else if (COMMAND == "windowrulev2")
handleWindowRuleV2(COMMAND, VALUE);
+ else if (COMMAND == "layerrule")
+ handleLayerRule(COMMAND, VALUE);
else if (COMMAND == "bezier")
handleBezier(COMMAND, VALUE);
else if (COMMAND == "animation")
@@ -1525,6 +1554,22 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
return returns;
}
+std::vector<SLayerRule> CConfigManager::getMatchingRules(SLayerSurface* pLS) {
+ std::vector<SLayerRule> returns;
+
+ for (auto& lr : m_dLayerRules) {
+ std::regex NSCHECK(lr.targetNamespace);
+
+ if (!pLS->layerSurface->_namespace || !std::regex_search(pLS->layerSurface->_namespace, NSCHECK))
+ continue;
+
+ // hit
+ returns.push_back(lr);
+ }
+
+ return returns;
+}
+
void CConfigManager::dispatchExecOnce() {
if (firstExecDispatched || isFirstLaunch)
return;