windowrules: rewrite completely (#12269)
Reworks the window rule syntax completely --------- Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
This commit is contained in:
parent
95ee08b340
commit
c2670e9ab9
93 changed files with 3574 additions and 2255 deletions
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 + "*"; });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
22
src/helpers/math/Expression.cpp
Normal file
22
src/helpers/math/Expression.cpp
Normal 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;
|
||||
}
|
||||
28
src/helpers/math/Expression.hpp
Normal file
28
src/helpers/math/Expression.hpp
Normal 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;
|
||||
};
|
||||
};
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <hyprutils/string/VarList.hpp>
|
||||
#include <hyprutils/string/VarList2.hpp>
|
||||
|
||||
//NOLINTNEXTLINE
|
||||
using namespace Hyprutils::String;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue