Add remote display support
[apps/agl-service-windowmanager.git] / src / wm_layer.hpp
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3  * Copyright (c) 2019 Konsulko Group
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #ifndef WM_LAYER_HPP
19 #define WM_LAYER_HPP
20
21 #include <string>
22 #include <vector>
23 #include <unordered_map>
24 #include <memory>
25 #include "wm_error.hpp"
26
27 struct json_object;
28
29 namespace wm
30 {
31
32 class WMClient;
33 class LayerState
34 {
35   public:
36     LayerState();
37     ~LayerState() = default;
38     const std::unordered_map<std::string, std::string> getCurrentState();
39     const std::vector<unsigned> getIviIdList();
40     void addLayer(unsigned layer);
41     void removeLayer(unsigned layer);
42     void attachAppToArea(const std::string& app, const std::string& area);
43
44     // Debug
45     void dump();
46
47   private:
48     std::vector<unsigned> render_order;
49     std::unordered_map<std::string, std::string> area2appid;
50 };
51
52 class WMLayer
53 {
54   public:
55     explicit WMLayer(json_object* j, unsigned wm_layer_id);
56     ~WMLayer() = default;
57
58     // Status & Setting API
59     unsigned getNewLayerID(const std::string& role);
60     unsigned idBegin() { return this->id_begin; }
61     unsigned idEnd()   { return this->id_end; }
62     unsigned getWMLayerID() { return this->wm_layer_id; }
63     const std::string& layerName();
64     void appendArea(const std::string& area);
65     LayerState& getLayerState() { return tmp_state; }
66     WMError setLayerState(const LayerState& l);
67     bool hasLayerID(unsigned id);
68     bool hasRole(const std::string& role);
69     void setRemote(const bool newRemote) { remote = newRemote; }
70     bool isRemote(void) { return remote; }
71
72     // Manipulation
73     void addLayerToState(unsigned layer);
74     void removeLayerFromState(unsigned layer);
75     void attachAppToArea(const std::string& app, const std::string& area);
76     std::string attachedApp(const std::string& area);
77     void update();
78     void undo();
79
80     // Event
81     void appTerminated(unsigned layer);
82
83     // Debug
84     void dump();
85
86   private:
87     LayerState tmp_state;
88     LayerState state;
89     unsigned wm_layer_id;
90     std::string name = ""; // Layer name
91     std::string role_list;
92     std::vector<std::string> area_list;
93     std::vector<unsigned>    id_list;
94     unsigned id_begin;
95     unsigned id_end;
96     bool remote = false;
97 };
98
99 } // namespace wm
100
101 #endif // WM_LAYER_HPP