layers: rename surface_id_to_layer and surface_id_to_layer_map
[staging/windowmanager.git] / src / layers.hpp
1 //
2 // Created by m on 7/27/17.
3 //
4
5 #ifndef TMCAGLWM_LAYERS_H
6 #define TMCAGLWM_LAYERS_H
7
8 #include <json.hpp>
9 #include <set>
10 #include <string>
11
12 #include "result.hpp"
13 #include "wayland.hpp"
14
15 namespace wm {
16
17 struct layer {
18    // Min and max surface ID mapped to this layer
19    int id_min = -1;
20    int id_max = -1;
21    // A more or less descriptive name?
22    std::string name = "";
23    // The actual layer ID
24    int layer_id = -1;
25    // The rectangular region surfaces are allowed to draw on
26    // this layer, note however, width and hieght of the rect
27    // can be negative, in which case they specify that
28    // the actual value is computed using MAX + 1 - w
29    // That is; allow us to specify dimensions dependent on
30    // e.g. screen dimension, w/o knowing the actual screen size.
31    genivi::rect rect;
32    // XXX perhaps a zorder is needed here?
33
34    explicit layer(nlohmann::json const &j);
35
36    bool operator<(struct layer const &rhs) const {
37       return this->id_max < rhs.id_max;
38    }
39 };
40
41 // Actually, we shouldn't need a struct here ... but let's just keep it at that
42 // for now, to contain its mapping type and the _single_ useful method.
43 struct layer_map {
44    typedef std::set<struct layer> storage_type;
45    typedef std::vector<unsigned int> layers_type;
46
47    storage_type mapping;
48    layers_type layers;
49
50    optional<int> get_layer_id(int surface_id);
51    optional<genivi::rect> get_layer_rect(int surface_id);
52    layers_type::size_type get_layers_count() const {
53       return this->layers.size();
54    }
55 };
56
57 struct result<struct layer_map> to_layer_map(nlohmann::json const &j);
58
59 }  // namespace wm
60
61 #endif  // TMCAGLWM_LAYERS_H