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