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.
17 #include "windowmanager-client.hpp"
18 #include "hmi-debug.h"
20 #define INVALID_SURFACE_ID 0
29 const vector<string> wm_events = {
30 // Private event for applications
31 "syncDraw", "flushDraw", "visible", "invisible", "active", "inactive", "error"};
33 static const char key_drawing_name[] = "drawing_name";
34 static const char key_role[] = "role";
36 WMClient::WMClient(const string &appid, unsigned layerID, unsigned surfaceID, const string &role)
41 role2surface[role] = surfaceID;
42 for (auto x : wm_events)
47 afb_event ev = afb_daemon_make_event(x.c_str());
53 WMClient::WMClient(const string &appid, const string &role)
59 role2surface[role] = INVALID_SURFACE_ID;
60 for (auto x : wm_events)
65 afb_event ev = afb_daemon_make_event(x.c_str());
75 string WMClient::appID()
80 void WMClient::registerLayer(unsigned layerID)
82 this->layer = layerID;
85 bool WMClient::addSurface(const string &role, unsigned surface)
87 HMI_DEBUG("wm", "Add role %s with surface %d", role.c_str(), surface);
88 if(0 != role2surface.count(role)){
89 HMI_NOTICE("wm", "override surfaceID %d with %d", role2surface[role], surface);
91 role2surface[role] = surface;
95 bool WMClient::removeSurfaceIfExist(unsigned surfaceID){
97 for (auto &x : role2surface)
99 if(surfaceID == x.second){
100 role2surface.erase(x.first);
108 bool WMClient::removeRole(const string& role){
110 if (role2surface.count(role) != 0)
112 role2surface.erase(role);
118 void WMClient::dumpInfo(){
119 DUMP("APPID : %s", id.c_str());
120 DUMP(" LAYER : %d", layer);
121 for(const auto& x : role2surface){
122 DUMP(" ROLE : %s , SURFACE : %d", x.first.c_str(), x.second);