55d98649b4b5d4434f20985918d69e1f6f715b94
[apps/agl-service-windowmanager.git] / src / windowmanager-client.cpp
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 #include <iostream> // for debug
17 using std::cerr;    //debug
18 using std::cout;    //debug
19 using std::endl;    //debug
20 #include "windowmanager-client.hpp"
21
22 namespace wm
23 {
24
25 using std::string;
26
27 const std::vector<std::string> wm_events = {
28     // Private event for applications
29     "syncDraw", "flushDraw", "visible", "invisible", "active", "inactive"};
30
31 WMClient::WMClient(const string &appid, unsigned layerID, unsigned surfaceID, const string &role)
32     : id(appid),
33       layer(layerID),
34       roles(0),
35       surfaces(0)
36 {
37     roles.push_back(role);
38     surfaces.push_back(surfaceID);
39     for (auto x : wm_events)
40     {
41 #if GTEST_ENABLED
42         string ev = x;
43 #else
44         afb_event ev = afb_daemon_make_event(x.c_str());
45 #endif
46         event_list[x] = ev;
47     }
48 }
49
50 WMClient::WMClient(const string &appid, const string &role)
51     : id(appid),
52       layer(0),
53       roles(0),
54       surfaces(0),
55       event_list(0)
56 {
57     roles.push_back(role);
58     for (auto x : wm_events)
59     {
60 #if GTEST_ENABLED
61         string ev = x;
62 #else
63         afb_event ev = afb_daemon_make_event(x.c_str());
64 #endif
65         event_list[x] = ev;
66     }
67 }
68
69 WMClient::~WMClient()
70 {
71 }
72
73 string WMClient::appID()
74 {
75     return this->id;
76 }
77
78 } // namespace wm