blob: 2865cfe1ffd8d0d021097b04e145656eab7d2ab4 [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
6enum {
7 WL_EVENT_READABLE = 0x01,
8 WL_EVENT_WRITEABLE = 0x02
9};
10
11struct wl_event_loop;
12struct wl_event_source;
13typedef void (*wl_event_loop_func_t)(int fd, uint32_t mask, void *data);
14
15struct wl_event_loop *wl_event_loop_create(void);
16void wl_event_loop_destroy(struct wl_event_loop *loop);
17struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *loop,
18 int fd, uint32_t mask,
19 wl_event_loop_func_t func,
20 void *data);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040021int wl_event_loop_update_source(struct wl_event_loop *loop,
22 struct wl_event_source *source,
23 uint32_t mask);
24
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040025int wl_event_loop_remove_source(struct wl_event_loop *loop,
26 struct wl_event_source *source);
27int wl_event_loop_wait(struct wl_event_loop *loop);
28
29struct wl_hash {
30 struct wl_object **objects;
31 uint32_t count, alloc, id;
32};
33
34int wl_hash_insert(struct wl_hash *hash, struct wl_object *object);
35struct wl_object *wl_hash_lookup(struct wl_hash *hash, uint32_t id);
36void wl_hash_delete(struct wl_hash *hash, struct wl_object *object);
37
38struct wl_client;
39
40enum {
41 WL_ARGUMENT_UINT32,
42 WL_ARGUMENT_STRING,
43 WL_ARGUMENT_OBJECT,
44 WL_ARGUMENT_NEW_ID
45};
46
47struct wl_argument {
48 uint32_t type;
49 void *data;
50};
51
52struct wl_method {
53 const char *name;
54 void *func;
55 int argument_count;
56 const struct wl_argument *arguments;
57};
58
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040059struct wl_event {
60 const char *name;
61};
62
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040063struct wl_interface {
64 const char *name;
65 int version;
66 int method_count;
67 const struct wl_method *methods;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040068 int event_count;
69 const struct wl_event *events;
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040070};
71
72struct wl_object {
73 const struct wl_interface *interface;
74 uint32_t id;
75};
76
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040077struct wl_surface;
78struct wl_display;
79
Kristian Høgsberg05eff512008-10-07 10:10:36 -040080struct wl_map {
81 int32_t x, y, width, height;
82};
83
84void wl_surface_set_data(struct wl_surface *surface, void *data);
85void *wl_surface_get_data(struct wl_surface *surface);
86
Kristian Høgsbergf9212892008-10-11 18:40:23 -040087struct wl_surface_iterator;
88struct wl_surface_iterator *
89wl_surface_iterator_create(struct wl_display *display, uint32_t mask);
90int wl_surface_iterator_next(struct wl_surface_iterator *iterator,
91 struct wl_surface **surface);
92void wl_surface_iterator_destroy(struct wl_surface_iterator *iterator);
93
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040094struct wl_compositor {
95 struct wl_compositor_interface *interface;
96};
97
98struct wl_compositor_interface {
99 void (*notify_surface_create)(struct wl_compositor *compositor,
100 struct wl_surface *surface);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400101 void (*notify_surface_destroy)(struct wl_compositor *compositor,
102 struct wl_surface *surface);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400103 void (*notify_surface_attach)(struct wl_compositor *compositor,
104 struct wl_surface *surface, uint32_t name,
105 uint32_t width, uint32_t height, uint32_t stride);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400106 void (*notify_surface_map)(struct wl_compositor *compositor,
107 struct wl_surface *surface, struct wl_map *map);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400108};
109
Kristian Høgsbergf9212892008-10-11 18:40:23 -0400110struct wl_compositor *wl_compositor_create(struct wl_display *display);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400111
112void wl_display_set_compositor(struct wl_display *display,
113 struct wl_compositor *compositor);
114
115
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -0400116#endif