AFBClient: add license headers
[staging/windowmanager.git] / client-lib / AFBClient.h
1 /*
2  * Copyright (C) 2017 Mentor Graphics Development (Deutschland) GmbH
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
17 #ifndef AFBCLIENT_H
18 #define AFBCLIENT_H
19
20 #include <functional>
21
22 class AFBClient {
23     AFBClient();
24     ~AFBClient();
25
26     AFBClient(const AFBClient &) = delete;
27     AFBClient &operator=(const AFBClient &) = delete;
28
29 public:
30     using handler_fun = std::function<void(const char *)>;
31
32     enum EventType {
33         Event_Active = 1,
34         Event_Inactive,
35
36         Event_Visible,
37         Event_Invisible,
38
39         Event_SyncDraw,
40         Event_FlushDraw,
41     };
42
43     static AFBClient &instance();
44
45     int init(int port, char const *token);
46     int dispatch();
47
48     // WM API
49     int requestSurface(const char *label);
50     int activateSurface(const char *label);
51     int deactivateSurface(const char *label);
52     int endDraw(const char *label);
53
54     void set_event_handler(enum EventType et, handler_fun f);
55
56     struct Impl;
57
58 private:
59     Impl *const d;
60 };
61 #endif // AFBCLIENT_H