remove some unnuecessary comments
[staging/windowmanager.git] / src / layers.hpp
1 /*
2  * Copyright (C) 2017 Mentor Graphics Development (Deutschland) GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef TMCAGLWM_LAYERS_H
18 #define TMCAGLWM_LAYERS_H
19
20 #include <json.hpp>
21 #include <set>
22 #include <string>
23
24 #include "result.hpp"
25 #include "wayland.hpp"
26
27 namespace wm {
28
29 struct layer {
30    using json = nlohmann::json;
31
32    // Min and max surface ID mapped to this layer
33    int id_min = -1;
34    int id_max = -1;
35    // A more or less descriptive name?
36    std::string name = "";
37    // The actual layer ID
38    int layer_id = -1;
39    // The rectangular region surfaces are allowed to draw on
40    // this layer, note however, width and hieght of the rect
41    // can be negative, in which case they specify that
42    // the actual value is computed using MAX + 1 - w
43    // That is; allow us to specify dimensions dependent on
44    // e.g. screen dimension, w/o knowing the actual screen size.
45    genivi::rect rect;
46    // XXX perhaps a zorder is needed here?
47
48    explicit layer(nlohmann::json const &j);
49
50    bool operator<(struct layer const &rhs) const {
51       return this->id_max < rhs.id_max;
52    }
53
54    json to_json() const;
55 };
56
57 // Actually, we shouldn't need a struct here ... but let's just keep it at that
58 // for now, to contain its mapping type and the _single_ useful method.
59 struct layer_map {
60    using json = nlohmann::json;
61
62    typedef std::set<struct layer> storage_type;
63    typedef std::vector<unsigned int> layers_type;
64
65    storage_type mapping;
66    layers_type layers;
67    int main_surface;
68
69    optional<int> get_layer_id(int surface_id);
70    optional<genivi::rect> get_layer_rect(int surface_id);
71    layers_type::size_type get_layers_count() const {
72       return this->layers.size();
73    }
74
75    json to_json() const;
76 };
77
78 struct result<struct layer_map> to_layer_map(nlohmann::json const &j);
79
80 }  // namespace wm
81
82 #endif  // TMCAGLWM_LAYERS_H