layers: clang-format
[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
14 namespace wm {
15
16 struct surface_id_to_layer {
17    int id_min = -1;
18    int id_max = -1;
19    std::string name = "";
20    int layer_id = -1;
21
22    explicit surface_id_to_layer(nlohmann::json const &j);
23
24    bool operator<(struct surface_id_to_layer const &rhs) const {
25       return this->id_max < rhs.id_max;
26    }
27 };
28
29 // Actually, we shouldn't need a struct here ... but let's just keep it at that
30 // for now, to contain its mapping type and the _single_ useful method.
31 struct surface_id_to_layer_map {
32    typedef std::set<struct surface_id_to_layer> surface_to_layer_map_type;
33    typedef std::vector<unsigned int> layers_type;
34
35    surface_to_layer_map_type mapping;
36    layers_type layers;
37
38    optional<int> get_layer_for_surface(int surface_id);
39    layers_type::size_type get_layers_count() const {
40       return this->layers.size();
41    }
42 };
43
44 struct result<struct surface_id_to_layer_map> to_surface_id_to_layer_map(
45    nlohmann::json const &j);
46
47 }  // namespace wm
48
49 #endif  // TMCAGLWM_LAYERS_H