Remove remnants of obsolete surface management by their IDs
[staging/windowmanager.git] / src / layers.hpp
index b20d356..5d085a0 100644 (file)
@@ -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<struct layer>;
+   using storage_type = std::map<int, struct layer>;
    using layers_type = std::vector<uint32_t>;
    using role_to_layer_map = std::vector<std::pair<std::string, int>>;
    using addsurf_layer_map = std::map<int, int>;
@@ -93,19 +86,17 @@ struct layer_map {
    optional<int> get_layer_id(std::string const &role);
    optional<struct LayoutState*> 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<struct LayoutState *>(&i->state);
+      auto i = this->mapping.find(layer_id);
+      return i == this->mapping.end()
+                ? nullopt
+                : optional<struct LayoutState *>(&i->second.state);
    }
    optional<struct layer> 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<struct layer>(*i);
+      auto i = this->mapping.find(layer_id);
+      return i == this->mapping.end() ? nullopt
+                                      : optional<struct layer>(i->second);
    }
 
-   optional<genivi::rect> get_layer_rect(int surface_id);
    layers_type::size_type get_layers_count() const {
       return this->layers.size();
    }