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 w, unsigned h) : _width(w), _height(h){}
31 unsigned width() { return _width; }
32 unsigned height() { return _height; }
36 unsigned _pysical_width = 0;
37 unsigned _pysical_height = 0;
40 class LayerControlCallbacks {
42 LayerControlCallbacks() {};
43 ~LayerControlCallbacks() = default;
44 LayerControlCallbacks(const LayerControlCallbacks &obj) = default;
47 std::function<void(unsigned, unsigned)> surfaceCreated;
48 std::function<void(unsigned)> surfaceDestroyed;
49 /* std::function<void(unsigned)> surfaceDestroyed;
50 std::function<void(unsigned)> layerCreated;
51 std::function<void(unsigned)> layerDestroyed; */
62 explicit LayerControl(const std::string& root);
63 ~LayerControl() = default;
64 WMError init(const LayerControlCallbacks& cb);
65 void createNewLayer(unsigned id);
66 unsigned getNewLayerID(const std::string& role, std::string* layer_name);
67 std::shared_ptr<WMLayer> getWMLayer(unsigned layer);
68 std::shared_ptr<WMLayer> getWMLayer(std::string layer_name);
69 struct rect getAreaSize(const std::string& area);
70 void setupArea(const rectangle& base_rct, double scaling);
71 Screen getScreenInfo();
73 // void setRenderOrder(const std::vector<unsigned> layer_render_order);
74 // std::vector<unsigned> getAllRenderOrder();
75 // std::vector<std::shared_ptr<WMLayer>>& getAllLayers();
76 // std::vector<unsigned> getRenderOrder(const std::string& layer_name);
77 WMError updateLayer(LayerState& layer_state);
78 WMError renderLayers();
79 WMError setXDGSurfaceOriginSize(unsigned surface);
80 // WMError renderWMLayers();
82 WMError layoutChange(const WMAction& action);
83 WMError visibilityChange(const WMAction &action);
84 void terminateApp(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 struct ilmScreenProperties screen_prop;
107 LayerControlCallbacks cb;