blob: 471ec7aff9b288d1af16ff82b6286fa99b6c017a [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;
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040013typedef void (*wl_event_loop_fd_func_t)(int fd, uint32_t mask, void *data);
14typedef void (*wl_event_loop_idle_func_t)(void *data);
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040015
16struct wl_event_loop *wl_event_loop_create(void);
17void wl_event_loop_destroy(struct wl_event_loop *loop);
18struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *loop,
19 int fd, uint32_t mask,
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040020 wl_event_loop_fd_func_t func,
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040021 void *data);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040022int wl_event_loop_update_source(struct wl_event_loop *loop,
23 struct wl_event_source *source,
24 uint32_t mask);
25
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040026int wl_event_loop_remove_source(struct wl_event_loop *loop,
27 struct wl_event_source *source);
28int wl_event_loop_wait(struct wl_event_loop *loop);
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040029struct wl_event_source *wl_event_loop_add_idle(struct wl_event_loop *loop,
30 wl_event_loop_idle_func_t func,
31 void *data);
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040032
33struct wl_hash {
34 struct wl_object **objects;
35 uint32_t count, alloc, id;
36};
37
38int wl_hash_insert(struct wl_hash *hash, struct wl_object *object);
39struct wl_object *wl_hash_lookup(struct wl_hash *hash, uint32_t id);
40void wl_hash_delete(struct wl_hash *hash, struct wl_object *object);
41
42struct wl_client;
43
44enum {
45 WL_ARGUMENT_UINT32,
46 WL_ARGUMENT_STRING,
47 WL_ARGUMENT_OBJECT,
48 WL_ARGUMENT_NEW_ID
49};
50
51struct wl_argument {
52 uint32_t type;
53 void *data;
54};
55
56struct wl_method {
57 const char *name;
58 void *func;
59 int argument_count;
60 const struct wl_argument *arguments;
61};
62
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040063struct wl_event {
64 const char *name;
65};
66
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040067struct wl_interface {
68 const char *name;
69 int version;
70 int method_count;
71 const struct wl_method *methods;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040072 int event_count;
73 const struct wl_event *events;
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040074};
75
76struct wl_object {
77 const struct wl_interface *interface;
78 uint32_t id;
79};
80
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040081struct wl_surface;
82struct wl_display;
83
Kristian Høgsberg05eff512008-10-07 10:10:36 -040084struct wl_map {
85 int32_t x, y, width, height;
86};
87
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040088struct wl_event_loop *wl_display_get_event_loop(struct wl_display *display);
89
Kristian Høgsberg05eff512008-10-07 10:10:36 -040090void wl_surface_set_data(struct wl_surface *surface, void *data);
91void *wl_surface_get_data(struct wl_surface *surface);
92
Kristian Høgsbergf9212892008-10-11 18:40:23 -040093struct wl_surface_iterator;
94struct wl_surface_iterator *
95wl_surface_iterator_create(struct wl_display *display, uint32_t mask);
96int wl_surface_iterator_next(struct wl_surface_iterator *iterator,
97 struct wl_surface **surface);
98void wl_surface_iterator_destroy(struct wl_surface_iterator *iterator);
99
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400100struct wl_compositor {
101 struct wl_compositor_interface *interface;
102};
103
104struct wl_compositor_interface {
105 void (*notify_surface_create)(struct wl_compositor *compositor,
106 struct wl_surface *surface);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400107 void (*notify_surface_destroy)(struct wl_compositor *compositor,
108 struct wl_surface *surface);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400109 void (*notify_surface_attach)(struct wl_compositor *compositor,
110 struct wl_surface *surface, uint32_t name,
111 uint32_t width, uint32_t height, uint32_t stride);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400112 void (*notify_surface_map)(struct wl_compositor *compositor,
113 struct wl_surface *surface, struct wl_map *map);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400114};
115
Kristian Høgsbergf9212892008-10-11 18:40:23 -0400116struct wl_compositor *wl_compositor_create(struct wl_display *display);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400117
118void wl_display_set_compositor(struct wl_display *display,
119 struct wl_compositor *compositor);
120
121
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -0400122#endif