X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=staging%2Fwindowmanager.git;a=blobdiff_plain;f=src%2Flayers.hpp;fp=src%2Flayers.hpp;h=5d085a0d28f3417afed977cb9ef5ef4742e73eb5;hp=b20d356dcb472fa583060067bc6da8e310705df6;hb=a414f394e06111d761ca6ac0aa783d59a42c6ea8;hpb=69a5f240268953b43aa89fdf414589ae3421aefc diff --git a/src/layers.hpp b/src/layers.hpp index b20d356..5d085a0 100644 --- a/src/layers.hpp +++ b/src/layers.hpp @@ -39,9 +39,6 @@ struct split_layout { struct layer { using json = nlohmann::json; - // Min and max surface ID mapped to this layer - int id_min = -1; - int id_max = -1; // A more or less descriptive name? std::string name = ""; // The actual layer ID @@ -63,17 +60,13 @@ struct layer { explicit layer(nlohmann::json const &j); - bool operator<(struct layer const &rhs) const { - return this->id_max < rhs.id_max; - } - json to_json() const; }; struct layer_map { using json = nlohmann::json; - using storage_type = std::set; + using storage_type = std::map; using layers_type = std::vector; using role_to_layer_map = std::vector>; using addsurf_layer_map = std::map; @@ -93,19 +86,17 @@ struct layer_map { optional get_layer_id(std::string const &role); optional get_layout_state(int surface_id) { int layer_id = *this->get_layer_id(surface_id); - auto i = std::find_if( - std::begin(this->mapping), std::end(this->mapping), - [layer_id](struct layer const &l) { return layer_id == l.layer_id; }); - return i == this->mapping.end() ? nullopt : optional(&i->state); + auto i = this->mapping.find(layer_id); + return i == this->mapping.end() + ? nullopt + : optional(&i->second.state); } optional get_layer(int layer_id) { - auto i = std::find_if( - std::cbegin(this->mapping), std::cend(this->mapping), - [layer_id](struct layer const &l) { return layer_id == l.layer_id; }); - return i == this->mapping.end() ? nullopt : optional(*i); + auto i = this->mapping.find(layer_id); + return i == this->mapping.end() ? nullopt + : optional(i->second); } - optional get_layer_rect(int surface_id); layers_type::size_type get_layers_count() const { return this->layers.size(); }