Guard dispatch using a mutex, remove dipatch() timeout parameter
[staging/windowmanager.git] / AFBClient.h
1 #ifndef AFBCLIENT_H
2 #define AFBCLIENT_H
3
4 #include <functional>
5
6 struct json_object;
7 struct afb_wsj1;
8 struct sd_event;
9
10 class AFBClient
11 {
12     AFBClient();
13     ~AFBClient();
14
15     AFBClient(const AFBClient &) = delete;
16     AFBClient &operator=(const AFBClient &) = delete;
17
18 public:
19     enum EventType {
20        Event_Active = 1,
21        Event_Inactive,
22        Event_Visible,
23        Event_Invisible,
24        Event_SyncDraw,
25        Event_FlushDraw,
26     };
27
28     static AFBClient &instance();
29
30     int init(int port, char const *token);
31     int dispatch();
32
33     // WM API
34     int requestSurface(const char *label);
35     int activateSurface(const char *label);
36     int deactivateSurface(const char *label);
37     int endDraw(const char *label);
38
39     void set_event_handler(enum EventType et,
40           std::function<void(char const *label)> f);
41
42 private:
43     struct afb_wsj1 *wsj1;
44     struct sd_event *loop;
45 };
46 #endif // AFBCLIENT_H