summaryrefslogtreecommitdiff
path: root/src/config
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
parent9813ba2f567a2e489b95bf15168cdcd26a31bec9 (diff)
added layer rules
Diffstat (limited to 'src/config')
-rw-r--r--src/config/ConfigManager.cpp45
-rw-r--r--src/config/ConfigManager.hpp4
2 files changed, 49 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;
diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp
index 2b8ea8ab..80971966 100644
--- a/src/config/ConfigManager.hpp
+++ b/src/config/ConfigManager.hpp
@@ -11,6 +11,7 @@
#include <algorithm>
#include <regex>
#include "../Window.hpp"
+#include "../helpers/WLClasses.hpp"
#include "defaultConfig.hpp"
#include "ConfigDataValues.hpp"
@@ -152,6 +153,7 @@ class CConfigManager {
std::string getBoundMonitorStringForWS(const std::string&);
std::vector<SWindowRule> getMatchingRules(CWindow*);
+ std::vector<SLayerRule> getMatchingRules(SLayerSurface*);
std::unordered_map<std::string, SMonitorAdditionalReservedArea> m_mAdditionalReservedAreas;
@@ -200,6 +202,7 @@ class CConfigManager {
std::deque<SMonitorRule> m_dMonitorRules;
std::deque<SWindowRule> m_dWindowRules;
+ std::deque<SLayerRule> m_dLayerRules;
std::deque<std::string> m_dBlurLSNamespaces;
bool firstExecDispatched = false;
@@ -224,6 +227,7 @@ class CConfigManager {
void handleBind(const std::string&, const std::string&);
void handleUnbind(const std::string&, const std::string&);
void handleWindowRule(const std::string&, const std::string&);
+ void handleLayerRule(const std::string&, const std::string&);
void handleWindowRuleV2(const std::string&, const std::string&);
void handleDefaultWorkspace(const std::string&, const std::string&);
void handleBezier(const std::string&, const std::string&);