1
0
Fork 0
mirror of https://github.com/hyprwm/Hyprland synced 2025-04-10 09:52:19 +02:00

config: nuke windowrule v1 syntax

This commit is contained in:
Vaxry 2025-03-18 01:36:55 +00:00
parent 9171db1984
commit ec4bea7901
2 changed files with 33 additions and 65 deletions

View file

@ -293,7 +293,7 @@ static Hyprlang::CParseResult handleWindowRuleV2(const char* c, const char* v) {
const std::string VALUE = v;
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handleWindowRuleV2(COMMAND, VALUE);
const auto RESULT = g_pConfigManager->handleWindowRule(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
@ -2347,69 +2347,6 @@ std::optional<std::string> CConfigManager::handleUnbind(const std::string& comma
}
std::optional<std::string> CConfigManager::handleWindowRule(const std::string& command, const std::string& value) {
const auto RULE = trim(value.substr(0, value.find_first_of(',')));
const auto VALUE = trim(value.substr(value.find_first_of(',') + 1));
// check rule and value
if (RULE.empty() || VALUE.empty())
return "empty rule?";
if (RULE == "unset") {
std::erase_if(m_vWindowRules, [&](const auto& other) { return other->szValue == VALUE; });
return {};
}
auto newRule = makeShared<CWindowRule>(RULE, VALUE, false);
// verify we support a rule
if (newRule->ruleType == CWindowRule::RULE_INVALID) {
Debug::log(ERR, "Invalid rule found: {}", RULE);
return "Invalid rule: " + RULE;
}
newRule->rV1Regex = {VALUE.starts_with("title:") ? VALUE.substr(6) : VALUE};
if (RULE.starts_with("size") || RULE.starts_with("maxsize") || RULE.starts_with("minsize"))
m_vWindowRules.insert(m_vWindowRules.begin(), newRule);
else
m_vWindowRules.emplace_back(newRule);
return {};
}
std::optional<std::string> CConfigManager::handleLayerRule(const std::string& command, const std::string& value) {
const auto RULE = trim(value.substr(0, value.find_first_of(',')));
const auto VALUE = trim(value.substr(value.find_first_of(',') + 1));
// check rule and value
if (RULE.empty() || VALUE.empty())
return "empty rule?";
if (RULE == "unset") {
std::erase_if(m_vLayerRules, [&](const auto& other) { return other->targetNamespace == VALUE; });
return {};
}
auto rule = makeShared<CLayerRule>(RULE, VALUE);
if (rule->ruleType == CLayerRule::RULE_INVALID) {
Debug::log(ERR, "Invalid rule found: {}", RULE);
return "Invalid rule found: " + RULE;
}
rule->targetNamespaceRegex = {VALUE};
m_vLayerRules.emplace_back(rule);
for (auto const& m : g_pCompositor->m_vMonitors)
for (auto const& lsl : m->m_aLayerSurfaceLayers)
for (auto const& ls : lsl)
ls->applyRules();
return {};
}
std::optional<std::string> CConfigManager::handleWindowRuleV2(const std::string& command, const std::string& value) {
const auto RULE = trim(value.substr(0, value.find_first_of(',')));
const auto VALUE = value.substr(value.find_first_of(',') + 1);
@ -2608,6 +2545,38 @@ std::optional<std::string> CConfigManager::handleWindowRuleV2(const std::string&
return {};
}
std::optional<std::string> CConfigManager::handleLayerRule(const std::string& command, const std::string& value) {
const auto RULE = trim(value.substr(0, value.find_first_of(',')));
const auto VALUE = trim(value.substr(value.find_first_of(',') + 1));
// check rule and value
if (RULE.empty() || VALUE.empty())
return "empty rule?";
if (RULE == "unset") {
std::erase_if(m_vLayerRules, [&](const auto& other) { return other->targetNamespace == VALUE; });
return {};
}
auto rule = makeShared<CLayerRule>(RULE, VALUE);
if (rule->ruleType == CLayerRule::RULE_INVALID) {
Debug::log(ERR, "Invalid rule found: {}", RULE);
return "Invalid rule found: " + RULE;
}
rule->targetNamespaceRegex = {VALUE};
m_vLayerRules.emplace_back(rule);
for (auto const& m : g_pCompositor->m_vMonitors)
for (auto const& lsl : m->m_aLayerSurfaceLayers)
for (auto const& ls : lsl)
ls->applyRules();
return {};
}
void CConfigManager::updateBlurredLS(const std::string& name, const bool forceBlur) {
const bool BYADDRESS = name.starts_with("address:");
std::string matchName = name;

View file

@ -235,7 +235,6 @@ class CConfigManager {
std::optional<std::string> handleUnbind(const std::string&, const std::string&);
std::optional<std::string> handleWindowRule(const std::string&, const std::string&);
std::optional<std::string> handleLayerRule(const std::string&, const std::string&);
std::optional<std::string> handleWindowRuleV2(const std::string&, const std::string&);
std::optional<std::string> handleWorkspaceRules(const std::string&, const std::string&);
std::optional<std::string> handleBezier(const std::string&, const std::string&);
std::optional<std::string> handleAnimation(const std::string&, const std::string&);