2 * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
18 #include "wm_layer_control.hpp"
\r
19 #include "wm_layer.hpp"
\r
21 #define LC_AREA_PATH "/etc/area.db"
\r
22 #define LC_LAYER_SETTING_PATH "/etc/layer_setting.json"
\r
28 static void notification_static(ilmObjectType object,
\r
33 static_cast<LayerControl*>(data)->dispatchILMEvent(object, id, created);
\r
36 LayerControl::LayerControl(const std::string& root)
\r
38 string area_path = root + LC_AREA_PATH;
\r
39 string layer_path= root + LC_LAYER_SETTING_PATH;
\r
40 // load layers.setting.json
\r
44 WMError LayerControl::init()
\r
46 ilmErrorTypes rc = ilm_init();
\r
51 while (rc != ILM_SUCCESS)
\r
56 HMI_ERROR("Could not connect to compositor");
\r
59 HMI_ERROR("Wait to start weston ...");
\r
63 if(rc != ILM_SUCCESS) goto lc_init_error;
\r
65 rc = ilm_getScreenIDs(&num, &ids);
\r
67 if(rc != ILM_SUCCESS) goto lc_init_error;
\r
69 for(unsigned i = 0; i < num; i++)
\r
71 HMI_INFO("get screen: %d", ids[i]);
\r
73 // Currently, 0 is only available
\r
74 this->screenID = ids[0];
\r
76 rc = ilm_getPropertiesOfScreen(this->screenID, &this->screen_prop);
\r
78 if(rc != ILM_SUCCESS) goto lc_init_error;
\r
80 // Register Callback from ILM
\r
81 ilm_registerNotification(notification_static, this);
\r
83 return WMError::SUCCESS;
\r
86 HMI_ERROR("Failed to initialize. Terminate WM");
\r
88 return WMError::FAIL;
\r
91 unsigned LayerControl::getNewLayerID(const string& role)
\r
94 for(const auto& l: this->wm_layers)
\r
96 ret = l->getNewLayerID(role);
\r
105 WMError LayerControl::updateLayer(WMLayer& wm_layer)
\r
107 return WMError::SUCCESS;
\r
110 void LayerControl::commitChange() {}
\r
112 void LayerControl::undoUpdate() {}
\r
114 WMError LayerControl::load(const string &path)
\r
116 return WMError::SUCCESS;
\r
119 void LayerControl::dispatchILMEvent(ilmObjectType object, t_ilm_uint id, t_ilm_bool created)
\r