diff options
Diffstat (limited to 'src/layers.cpp')
-rw-r--r-- | src/layers.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/layers.cpp b/src/layers.cpp index c814c22..b931870 100644 --- a/src/layers.cpp +++ b/src/layers.cpp @@ -42,6 +42,29 @@ layer::layer(nlohmann::json const &j) { jr["width"], jr["height"], jr["x"], jr["y"], }; } + auto split_layouts = j.find("split_layouts"); + if (split_layouts != j.end()) { + auto &sls = j["split_layouts"]; + this->layouts.reserve(sls.size()); + std::transform(std::cbegin(sls), std::cend(sls), + std::back_inserter(this->layouts), [](json const &sl) { + struct split_layout l {}; + l.name = sl["name"]; + l.main_match = sl["main_match"]; + l.sub_match = sl["sub_match"]; + l.prio = sl.value<int>("priority", 0); + logdebug( + "Added split_layout \"%s\" (main: \"%s\") (sub: " + "\"%s\") (prio: %d)", + l.name.c_str(), l.main_match.c_str(), + l.sub_match.c_str(), l.prio); + return l; + }); + std::sort(std::begin(this->layouts), std::end(this->layouts), + [](struct split_layout const &a, struct split_layout const &b) { + return a.prio < b.prio; + }); + } } struct result<struct layer_map> to_layer_map(nlohmann::json const &j) { @@ -179,12 +202,9 @@ json layer::to_json() const { } return { - {"id_min", this->id_min}, - {"id_max", this->id_max}, - {"name", this->name}, - {"role", this->role}, - {"layer_id", this->layer_id}, - {"area", r}, + {"id_min", this->id_min}, {"id_max", this->id_max}, + {"name", this->name}, {"role", this->role}, + {"layer_id", this->layer_id}, {"area", r}, }; } |