blob: ec28a44ede3dc08f6616ff394ff88b34ab2a2e79 [file] [log] [blame]
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -04001#ifndef WAYLAND_H
2#define WAYLAND_H
3
4#include <stdint.h>
5
Kristian Høgsbergf9bc7952008-11-02 10:12:29 -05006#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
7
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -04008enum {
9 WL_EVENT_READABLE = 0x01,
10 WL_EVENT_WRITEABLE = 0x02
11};
12
13struct wl_event_loop;
14struct wl_event_source;
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040015typedef void (*wl_event_loop_fd_func_t)(int fd, uint32_t mask, void *data);
16typedef void (*wl_event_loop_idle_func_t)(void *data);
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040017
18struct wl_event_loop *wl_event_loop_create(void);
19void wl_event_loop_destroy(struct wl_event_loop *loop);
20struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *loop,
21 int fd, uint32_t mask,
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040022 wl_event_loop_fd_func_t func,
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040023 void *data);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040024int wl_event_loop_update_source(struct wl_event_loop *loop,
25 struct wl_event_source *source,
26 uint32_t mask);
27
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040028int wl_event_loop_remove_source(struct wl_event_loop *loop,
29 struct wl_event_source *source);
30int wl_event_loop_wait(struct wl_event_loop *loop);
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040031struct wl_event_source *wl_event_loop_add_idle(struct wl_event_loop *loop,
32 wl_event_loop_idle_func_t func,
33 void *data);
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040034
35struct wl_hash {
36 struct wl_object **objects;
37 uint32_t count, alloc, id;
38};
39
40int wl_hash_insert(struct wl_hash *hash, struct wl_object *object);
41struct wl_object *wl_hash_lookup(struct wl_hash *hash, uint32_t id);
42void wl_hash_delete(struct wl_hash *hash, struct wl_object *object);
43
44struct wl_client;
45
46enum {
47 WL_ARGUMENT_UINT32,
48 WL_ARGUMENT_STRING,
49 WL_ARGUMENT_OBJECT,
50 WL_ARGUMENT_NEW_ID
51};
52
53struct wl_argument {
54 uint32_t type;
55 void *data;
56};
57
58struct wl_method {
59 const char *name;
60 void *func;
61 int argument_count;
62 const struct wl_argument *arguments;
63};
64
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040065struct wl_event {
66 const char *name;
67};
68
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040069struct wl_interface {
70 const char *name;
71 int version;
72 int method_count;
73 const struct wl_method *methods;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040074 int event_count;
75 const struct wl_event *events;
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040076};
77
78struct wl_object {
79 const struct wl_interface *interface;
80 uint32_t id;
81};
82
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040083struct wl_surface;
84struct wl_display;
85
Kristian Høgsberg05eff512008-10-07 10:10:36 -040086struct wl_map {
87 int32_t x, y, width, height;
88};
89
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040090struct wl_event_loop *wl_display_get_event_loop(struct wl_display *display);
91
Kristian Høgsberg05eff512008-10-07 10:10:36 -040092void wl_surface_set_data(struct wl_surface *surface, void *data);
93void *wl_surface_get_data(struct wl_surface *surface);
94
Kristian Høgsbergf9212892008-10-11 18:40:23 -040095struct wl_surface_iterator;
96struct wl_surface_iterator *
97wl_surface_iterator_create(struct wl_display *display, uint32_t mask);
98int wl_surface_iterator_next(struct wl_surface_iterator *iterator,
99 struct wl_surface **surface);
100void wl_surface_iterator_destroy(struct wl_surface_iterator *iterator);
101
Kristian Høgsbergf9bc7952008-11-02 10:12:29 -0500102struct wl_object *
103wl_input_device_create(struct wl_display *display,
104 const char *path, uint32_t id);
105void
106wl_display_post_relative_event(struct wl_display *display,
107 struct wl_object *source, int dx, int dy);
108void
109wl_display_post_absolute_event(struct wl_display *display,
110 struct wl_object *source, int x, int y);
111void
112wl_display_post_button_event(struct wl_display *display,
113 struct wl_object *source, int button, int state);
114
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400115struct wl_compositor {
Kristian Høgsberg5503bf82008-11-06 10:38:17 -0500116 const struct wl_compositor_interface *interface;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400117};
118
119struct wl_compositor_interface {
120 void (*notify_surface_create)(struct wl_compositor *compositor,
121 struct wl_surface *surface);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400122 void (*notify_surface_destroy)(struct wl_compositor *compositor,
123 struct wl_surface *surface);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400124 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);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400127 void (*notify_surface_map)(struct wl_compositor *compositor,
128 struct wl_surface *surface, struct wl_map *map);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400129};
130
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400131void wl_display_set_compositor(struct wl_display *display,
132 struct wl_compositor *compositor);
133
134
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -0400135#endif