summaryrefslogtreecommitdiff
path: root/src/desktop/rule/layerRule/LayerRule.cpp
blob: eccd99142002637bef2b2debcce6dd066dd3782b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "LayerRule.hpp"
#include "../../../debug/log/Logger.hpp"
#include "../../view/LayerSurface.hpp"

using namespace Desktop;
using namespace Desktop::Rule;

CLayerRule::CLayerRule(const std::string& name) : IRule(name) {
    ;
}

eRuleType CLayerRule::type() {
    return RULE_TYPE_LAYER;
}

void CLayerRule::addEffect(CLayerRule::storageType e, const std::string& result) {
    m_effects.emplace_back(std::make_pair<>(e, result));
}

const std::vector<std::pair<CLayerRule::storageType, std::string>>& CLayerRule::effects() {
    return m_effects;
}

bool CLayerRule::matches(PHLLS ls) {
    if (m_matchEngines.empty())
        return false;

    for (const auto& [prop, engine] : m_matchEngines) {
        switch (prop) {
            default: {
                Log::logger->log(Log::TRACE, "CLayerRule::matches: skipping prop entry {}", sc<std::underlying_type_t<eRuleProperty>>(prop));
                break;
            }

            case RULE_PROP_NAMESPACE:
                if (!engine->match(ls->m_namespace))
                    return false;
                break;
        }
    }

    return true;
}