2 * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <unordered_map>
22 #include <ilm/ilm_control.h>
23 #include "wm_error.hpp"
30 Screen(unsigned id, unsigned w, unsigned h) : _screen_id(id), _width(w), _height(h){}
31 unsigned width() const { return _width; }
32 unsigned height() const { return _height; }
33 unsigned id() const { return _screen_id; }
34 unsigned scale() const { return _scale; }
35 int offsetX() const { return _offset_x; }
36 int offsetY() const { return _offset_y; }
37 void setScale(double scl) { this->_scale = scl; }
38 void setOffset(int x, int y) { this->_offset_x = x; this->_offset_y = y; }
43 unsigned _pysical_width = 0;
44 unsigned _pysical_height = 0;
50 class LayerControlCallbacks {
52 LayerControlCallbacks() {};
53 ~LayerControlCallbacks() = default;
54 LayerControlCallbacks(const LayerControlCallbacks &obj) = default;
57 std::function<void(unsigned, unsigned)> surfaceCreated;
58 std::function<void(unsigned)> surfaceDestroyed;
60 std::function<void(unsigned)> layerCreated;
61 std::function<void(unsigned)> layerDestroyed;
73 explicit LayerControl(const std::string& root, const std::string& ecu_name);
74 ~LayerControl() = default;
75 WMError init(const LayerControlCallbacks& cb);
76 void createNewLayer(unsigned id);
77 void createNewRemoteLayer(unsigned id);
78 unsigned getNewLayerID(const std::string& role, std::string* layer_name);
79 std::shared_ptr<WMLayer> getWMLayer(unsigned layer);
80 std::shared_ptr<WMLayer> getWMLayer(std::string layer_name);
81 struct rect getAreaSize(const std::string& area);
82 void setupArea(const rectangle& base_rct, double scaling);
83 Screen getScreenInfo();
85 WMError updateLayer(LayerState& layer_state);
86 WMError renderLayers();
87 // WMError renderLayersRemote();
88 WMError setXDGSurfaceOriginSize(unsigned surface);
90 WMError layoutChange(const WMAction& action);
91 WMError visibilityChange(const WMAction &action);
92 const std::unordered_map<std::string, struct rect>& getAreaList() {return this->area2size;}
93 WMError updateAreaList(const ChangeAreaReq& req);
94 WMError getUpdateAreaList(ChangeAreaReq* req);
95 WMError changeAreaSize(std::shared_ptr<WMClient> client, const std::string& area);
96 void appTerminated(const std::shared_ptr<WMClient> client);
98 // Don't use this function.
99 void dispatchCreateEvent(ilmObjectType object, unsigned id, bool created);
100 void dispatchSurfacePropChangeEvent(unsigned id, struct ilmSurfaceProperties*, t_ilm_notification_mask);
101 void dispatchLayerPropChangeEvent(unsigned id, struct ilmLayerProperties*, t_ilm_notification_mask);
103 bool hasRemoteLayer(unsigned layer);
106 WMError makeVisible(const std::shared_ptr<WMClient> client);
107 WMError makeInvisible(const std::shared_ptr<WMClient> client);
108 bool moveForeGround(const std::shared_ptr<WMClient> client);
109 bool moveBackGround(const std::shared_ptr<WMClient> client);
110 bool moveRemote(unsigned layer, const std::string& area);
111 bool moveLocal(unsigned layer);
112 int loadWestonSetting(const std::string &path);
113 WMError loadLayerSetting(const std::string& path);
114 WMError loadAreasConfigFile(const std::string& path, const std::string& ecu_name);
116 std::vector<std::shared_ptr<WMLayer>> wm_layers;
117 std::vector<Screen> wm_screens;
118 std::unordered_map<unsigned, unsigned> lid2wmlid;
119 std::unordered_map<std::string, struct rect> area2size;
125 LayerControlCallbacks cb;