windowrules: rewrite completely (#12269)

Reworks the window rule syntax completely

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
This commit is contained in:
Vaxry 2025-11-17 18:34:02 +00:00 committed by GitHub
parent 95ee08b340
commit c2670e9ab9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
93 changed files with 3574 additions and 2255 deletions

View file

@ -975,3 +975,13 @@ std::string getBuiltSystemLibraryNames() {
result += std::format("Aquamarine: built against {}, system has {}\n", AQUAMARINE_VERSION, getSystemLibraryVersion("aquamarine"));
return result;
}
bool truthy(const std::string& str) {
if (str == "1")
return true;
std::string cpy = str;
std::ranges::transform(cpy, cpy.begin(), ::tolower);
return cpy.starts_with("true") || cpy.starts_with("yes") || cpy.starts_with("on");
}

View file

@ -46,6 +46,7 @@ std::expected<std::string, std::string> binaryNameForPid(pid_t pid);
std::string deviceNameToInternalString(std::string in);
std::string getSystemLibraryVersion(const std::string& name);
std::string getBuiltSystemLibraryNames();
bool truthy(const std::string& str);
template <typename... Args>
[[deprecated("use std::format instead")]] std::string getFormat(std::format_string<Args...> fmt, Args&&... args) {

View file

@ -177,7 +177,11 @@ void CMonitor::onConnect(bool noRule) {
m_forceSize = SIZE;
SMonitorRule rule = m_activeMonitorRule;
rule.resolution = SIZE;
if (SIZE == rule.resolution)
return;
rule.resolution = SIZE;
applyMonitorRule(&rule);
});

View file

@ -1,6 +1,6 @@
#include "TagKeeper.hpp"
bool CTagKeeper::isTagged(const std::string& tag, bool strict) {
bool CTagKeeper::isTagged(const std::string& tag, bool strict) const {
const bool NEGATIVE = tag.starts_with("negative");
const auto MATCH = NEGATIVE ? tag.substr(9) : tag;
const bool TAGGED = m_tags.contains(MATCH) || (!strict && m_tags.contains(MATCH + "*"));
@ -38,6 +38,6 @@ bool CTagKeeper::applyTag(const std::string& tag, bool dynamic) {
return true;
}
bool CTagKeeper::removeDynamicTags() {
return std::erase_if(m_tags, [](const auto& tag) { return tag.ends_with("*"); });
bool CTagKeeper::removeDynamicTag(const std::string& s) {
return std::erase_if(m_tags, [&s](const auto& tag) { return tag == s + "*"; });
}

View file

@ -5,9 +5,9 @@
class CTagKeeper {
public:
bool isTagged(const std::string& tag, bool strict = false);
bool isTagged(const std::string& tag, bool strict = false) const;
bool applyTag(const std::string& tag, bool dynamic = false);
bool removeDynamicTags();
bool removeDynamicTag(const std::string& tag);
const auto& getTags() const {
return m_tags;

View file

@ -0,0 +1,22 @@
#include "Expression.hpp"
#include "muParser.h"
#include "../../debug/Log.hpp"
using namespace Math;
CExpression::CExpression() : m_parser(makeUnique<mu::Parser>()) {
;
}
void CExpression::addVariable(const std::string& name, double val) {
m_parser->DefineConst(name, val);
}
std::optional<double> CExpression::compute(const std::string& expr) {
try {
m_parser->SetExpr(expr);
return m_parser->Eval();
} catch (mu::Parser::exception_type& e) { Debug::log(ERR, "CExpression::compute: mu threw: {}", e.GetMsg()); }
return std::nullopt;
}

View file

@ -0,0 +1,28 @@
#pragma once
#include "../memory/Memory.hpp"
#include <string>
#include <optional>
namespace mu {
class Parser;
};
namespace Math {
class CExpression {
public:
CExpression();
~CExpression() = default;
CExpression(const CExpression&) = delete;
CExpression(CExpression&) = delete;
CExpression(CExpression&&) = delete;
void addVariable(const std::string& name, double val);
std::optional<double> compute(const std::string& expr);
private:
UP<mu::Parser> m_parser;
};
};

View file

@ -1,6 +1,7 @@
#pragma once
#include <hyprutils/string/VarList.hpp>
#include <hyprutils/string/VarList2.hpp>
//NOLINTNEXTLINE
using namespace Hyprutils::String;