2 * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3 * Copyright (c) 2019 Konsulko Group
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <unordered_map>
23 #include <ilm/ilm_control.h>
24 #include "wm_error.hpp"
31 Screen(unsigned w, unsigned h) : _width(w), _height(h){}
32 unsigned width() { return _width; }
33 unsigned height() { return _height; }
37 unsigned _pysical_width = 0;
38 unsigned _pysical_height = 0;
41 class LayerControlCallbacks {
43 LayerControlCallbacks() {};
44 ~LayerControlCallbacks() = default;
45 LayerControlCallbacks(const LayerControlCallbacks &obj) = default;
48 std::function<void(unsigned, unsigned)> surfaceCreated;
49 std::function<void(unsigned)> surfaceDestroyed;
51 std::function<void(unsigned)> layerCreated;
52 std::function<void(unsigned)> layerDestroyed;
64 explicit LayerControl(const std::string& root);
65 ~LayerControl() = default;
66 WMError init(const LayerControlCallbacks& cb);
67 void createNewLayer(unsigned id, bool remote = false);
68 unsigned getNewLayerID(const std::string& role, std::string* layer_name = nullptr);
69 std::shared_ptr<WMLayer> getWMLayer(unsigned layer);
70 std::shared_ptr<WMLayer> getWMLayer(std::string layer_name);
71 struct rect getAreaSize(const std::string& area);
72 void setupArea(const rectangle& base_rct, double scaling);
73 Screen getScreenInfo();
75 WMError renderLayers();
76 WMError setXDGSurfaceOriginSize(unsigned surface);
78 WMError layoutChange(const WMAction& action);
79 WMError visibilityChange(const WMAction &action);
80 const std::unordered_map<std::string, struct rect>& getAreaList() {return this->area2size;}
81 WMError updateAreaList(const ChangeAreaReq& req);
82 WMError getUpdateAreaList(ChangeAreaReq* req);
83 WMError changeAreaSize(std::shared_ptr<WMClient> client, const std::string& area);
84 void appTerminated(const std::shared_ptr<WMClient> client);
86 // Don't use this function.
87 void dispatchCreateEvent(ilmObjectType object, unsigned id, bool created);
88 void dispatchSurfacePropChangeEvent(unsigned id, struct ilmSurfaceProperties*, t_ilm_notification_mask);
89 void dispatchLayerPropChangeEvent(unsigned id, struct ilmLayerProperties*, t_ilm_notification_mask);
92 WMError makeVisible(const std::shared_ptr<WMClient> client);
93 WMError makeInvisible(const std::shared_ptr<WMClient> client);
94 bool moveForeGround(const std::shared_ptr<WMClient> client);
95 bool moveBackGround(const std::shared_ptr<WMClient> client);
96 WMError loadLayerSetting(const std::string& path);
97 WMError loadAreaDb(const std::string& path);
99 std::vector<std::shared_ptr<WMLayer>> wm_layers;
100 std::unordered_map<unsigned, unsigned> lid2wmlid;
101 std::unordered_map<std::string, struct rect> area2size;
103 signed remoteScreenID;
104 struct ilmScreenProperties screen_prop;
108 LayerControlCallbacks cb;