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>
23 #include <ilm/ilm_control.h>
24 #include "wm_error.hpp"
31 Screen(unsigned id, unsigned w, unsigned h) : _screen_id(id), _width(w), _height(h){}
32 unsigned width() const { return _width; }
33 unsigned height() const { return _height; }
34 unsigned id() const { return _screen_id; }
35 unsigned scale() const { return _scale; }
36 int offsetX() const { return _offset_x; }
37 int offsetY() const { return _offset_y; }
38 void setScale(double scl) { this->_scale = scl; }
39 void setOffset(int x, int y) { this->_offset_x = x; this->_offset_y = y; }
44 unsigned _pysical_width = 0;
45 unsigned _pysical_height = 0;
51 class LayerControlCallbacks {
53 LayerControlCallbacks() {};
54 ~LayerControlCallbacks() = default;
55 LayerControlCallbacks(const LayerControlCallbacks &obj) = default;
58 std::function<void(unsigned, unsigned)> surfaceCreated;
59 std::function<void(unsigned)> surfaceDestroyed;
61 std::function<void(unsigned)> layerCreated;
62 std::function<void(unsigned)> layerDestroyed;
74 explicit LayerControl(const std::string& root, const std::string& ecu_name);
75 ~LayerControl() = default;
76 WMError init(const LayerControlCallbacks& cb);
77 void createNewLayer(unsigned id);
78 void createNewRemoteLayer(unsigned id);
79 unsigned getNewLayerID(const std::string& role, std::string* layer_name);
80 std::shared_ptr<WMLayer> getWMLayer(unsigned layer);
81 std::shared_ptr<WMLayer> getWMLayer(std::string layer_name);
82 struct rect getAreaSize(const std::string& area);
83 void setupArea(const rectangle& base_rct, double scaling);
84 Screen getScreenInfo();
86 WMError updateLayer(LayerState& layer_state);
87 WMError renderLayers();
88 // WMError renderLayersRemote();
89 WMError setXDGSurfaceOriginSize(unsigned surface);
91 WMError layoutChange(const WMAction& action);
92 WMError visibilityChange(const WMAction &action);
93 const std::unordered_map<std::string, struct rect>& getAreaList() {return this->area2size;}
94 WMError updateAreaList(const ChangeAreaReq& req);
95 WMError getUpdateAreaList(ChangeAreaReq* req);
96 WMError changeAreaSize(std::shared_ptr<WMClient> client, const std::string& area);
97 void appTerminated(const std::shared_ptr<WMClient> client);
99 // Don't use this function.
100 void dispatchCreateEvent(ilmObjectType object, unsigned id, bool created);
101 void dispatchSurfacePropChangeEvent(unsigned id, struct ilmSurfaceProperties*, t_ilm_notification_mask);
102 void dispatchLayerPropChangeEvent(unsigned id, struct ilmLayerProperties*, t_ilm_notification_mask);
104 std::string hasRemoteLayer(unsigned layer);
105 std::string areaToRemoteLayer(const std::string& area);
107 WMError makeVisible(const std::shared_ptr<WMClient> client);
108 WMError makeInvisible(const std::shared_ptr<WMClient> client);
109 bool moveForeGround(const std::shared_ptr<WMClient> client);
110 bool moveBackGround(const std::shared_ptr<WMClient> client);
111 bool moveRemote(unsigned layer, const std::string& area);
112 bool moveLocal(unsigned layer);
113 int loadWestonSetting(const std::string &path);
114 WMError loadLayerSetting(const std::string& path);
115 WMError loadAreasConfigFile(const std::string& path, const std::string& ecu_name);
117 std::vector<std::shared_ptr<WMLayer>> wm_layers;
118 std::vector<std::string> wm_remoteLayerName;
119 std::vector<Screen> wm_screens;
120 std::unordered_map<unsigned, unsigned> lid2wmlid;
121 std::unordered_map<std::string, struct rect> area2size;
127 LayerControlCallbacks cb;