Add README for the adventurous, allow evdev override from getenv().
[profile/ivi/wayland.git] / wayland.h
1 #ifndef WAYLAND_H
2 #define WAYLAND_H
3
4 #include <stdint.h>
5
6 #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
7
8 enum {
9         WL_EVENT_READABLE = 0x01,
10         WL_EVENT_WRITEABLE = 0x02
11 };
12
13 struct wl_event_loop;
14 struct wl_event_source;
15 typedef void (*wl_event_loop_fd_func_t)(int fd, uint32_t mask, void *data);
16 typedef void (*wl_event_loop_idle_func_t)(void *data);
17
18 struct wl_event_loop *wl_event_loop_create(void);
19 void wl_event_loop_destroy(struct wl_event_loop *loop);
20 struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *loop,
21                                              int fd, uint32_t mask,
22                                              wl_event_loop_fd_func_t func,
23                                              void *data);
24 int wl_event_loop_update_source(struct wl_event_loop *loop,
25                                 struct wl_event_source *source,
26                                 uint32_t mask);
27
28 int wl_event_loop_remove_source(struct wl_event_loop *loop,
29                                 struct wl_event_source *source);
30 int wl_event_loop_wait(struct wl_event_loop *loop);
31 struct wl_event_source *wl_event_loop_add_idle(struct wl_event_loop *loop,
32                                                wl_event_loop_idle_func_t func,
33                                                void *data);
34
35 struct wl_hash {
36         struct wl_object **objects;
37         uint32_t count, alloc, id;
38 };
39
40 int wl_hash_insert(struct wl_hash *hash, struct wl_object *object);
41 struct wl_object *wl_hash_lookup(struct wl_hash *hash, uint32_t id);
42 void wl_hash_delete(struct wl_hash *hash, struct wl_object *object);
43
44 struct wl_client;
45
46 enum {
47         WL_ARGUMENT_UINT32,
48         WL_ARGUMENT_STRING,
49         WL_ARGUMENT_OBJECT,
50         WL_ARGUMENT_NEW_ID
51 };
52
53 struct wl_argument {
54         uint32_t type;
55         void *data;
56 };
57
58 struct wl_method {
59         const char *name;
60         void *func;
61         int argument_count;
62         const struct wl_argument *arguments;
63 };
64
65 struct wl_event {
66         const char *name;
67 };
68
69 struct wl_interface {
70         const char *name;
71         int version;
72         int method_count;
73         const struct wl_method *methods;
74         int event_count;
75         const struct wl_event *events;
76 };
77
78 struct wl_object {
79         const struct wl_interface *interface;
80         uint32_t id;
81 };
82
83 struct wl_surface;
84 struct wl_display;
85
86 struct wl_map {
87         int32_t x, y, width, height;
88 };
89
90 struct wl_event_loop *wl_display_get_event_loop(struct wl_display *display);
91
92 void wl_surface_set_data(struct wl_surface *surface, void *data);
93 void *wl_surface_get_data(struct wl_surface *surface);
94
95 struct wl_surface_iterator;
96 struct wl_surface_iterator *
97 wl_surface_iterator_create(struct wl_display *display, uint32_t mask);
98 int wl_surface_iterator_next(struct wl_surface_iterator *iterator,
99                              struct wl_surface **surface);
100 void wl_surface_iterator_destroy(struct wl_surface_iterator *iterator);
101
102 struct wl_object *
103 wl_input_device_create(struct wl_display *display,
104                        const char *path, uint32_t id);
105 void
106 wl_display_post_relative_event(struct wl_display *display,
107                                struct wl_object *source, int dx, int dy);
108 void
109 wl_display_post_absolute_event(struct wl_display *display,
110                                struct wl_object *source, int x, int y);
111 void
112 wl_display_post_button_event(struct wl_display *display,
113                              struct wl_object *source, int button, int state);
114
115 struct wl_compositor {
116         struct wl_compositor_interface *interface;
117 };
118
119 struct wl_compositor_interface {
120         void (*notify_surface_create)(struct wl_compositor *compositor,
121                                       struct wl_surface *surface);
122         void (*notify_surface_destroy)(struct wl_compositor *compositor,
123                                        struct wl_surface *surface);
124         void (*notify_surface_attach)(struct wl_compositor *compositor,
125                                       struct wl_surface *surface, uint32_t name, 
126                                       uint32_t width, uint32_t height, uint32_t stride);
127         void (*notify_surface_map)(struct wl_compositor *compositor,
128                                    struct wl_surface *surface, struct wl_map *map);
129 };
130
131 struct wl_compositor *wl_compositor_create(struct wl_display *display);
132
133 void wl_display_set_compositor(struct wl_display *display,
134                                struct wl_compositor *compositor);
135
136
137 #endif