blob: ecc9de00f868e860609350bbefd1f10b2d025f56 [file] [log] [blame]
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -04001#ifndef WAYLAND_H
2#define WAYLAND_H
3
4#include <stdint.h>
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -05005#include "wayland-util.h"
Kristian Høgsbergb7a01922008-11-08 15:39:41 -05006
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -04007enum {
8 WL_EVENT_READABLE = 0x01,
9 WL_EVENT_WRITEABLE = 0x02
10};
11
12struct wl_event_loop;
13struct wl_event_source;
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040014typedef void (*wl_event_loop_fd_func_t)(int fd, uint32_t mask, void *data);
15typedef void (*wl_event_loop_idle_func_t)(void *data);
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040016
17struct wl_event_loop *wl_event_loop_create(void);
18void wl_event_loop_destroy(struct wl_event_loop *loop);
19struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *loop,
20 int fd, uint32_t mask,
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040021 wl_event_loop_fd_func_t func,
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040022 void *data);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040023int wl_event_loop_update_source(struct wl_event_loop *loop,
24 struct wl_event_source *source,
25 uint32_t mask);
26
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040027int wl_event_loop_remove_source(struct wl_event_loop *loop,
28 struct wl_event_source *source);
29int wl_event_loop_wait(struct wl_event_loop *loop);
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040030struct wl_event_source *wl_event_loop_add_idle(struct wl_event_loop *loop,
31 wl_event_loop_idle_func_t func,
32 void *data);
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040033
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040034struct wl_client;
35
36enum {
37 WL_ARGUMENT_UINT32,
38 WL_ARGUMENT_STRING,
39 WL_ARGUMENT_OBJECT,
40 WL_ARGUMENT_NEW_ID
41};
42
43struct wl_argument {
44 uint32_t type;
45 void *data;
46};
47
48struct wl_method {
49 const char *name;
50 void *func;
51 int argument_count;
52 const struct wl_argument *arguments;
53};
54
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040055struct wl_event {
56 const char *name;
57};
58
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040059struct wl_interface {
60 const char *name;
61 int version;
62 int method_count;
63 const struct wl_method *methods;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040064 int event_count;
65 const struct wl_event *events;
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040066};
67
68struct wl_object {
69 const struct wl_interface *interface;
70 uint32_t id;
71};
72
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040073struct wl_surface;
74struct wl_display;
75
Kristian Høgsberg05eff512008-10-07 10:10:36 -040076struct wl_map {
77 int32_t x, y, width, height;
78};
79
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040080struct wl_event_loop *wl_display_get_event_loop(struct wl_display *display);
81
Kristian Høgsberg05eff512008-10-07 10:10:36 -040082void wl_surface_set_data(struct wl_surface *surface, void *data);
83void *wl_surface_get_data(struct wl_surface *surface);
84
Kristian Høgsbergf9212892008-10-11 18:40:23 -040085struct wl_surface_iterator;
86struct wl_surface_iterator *
87wl_surface_iterator_create(struct wl_display *display, uint32_t mask);
88int wl_surface_iterator_next(struct wl_surface_iterator *iterator,
89 struct wl_surface **surface);
90void wl_surface_iterator_destroy(struct wl_surface_iterator *iterator);
91
Kristian Høgsbergf9bc7952008-11-02 10:12:29 -050092struct wl_object *
Kristian Høgsbergcddc0ad2008-11-24 00:31:49 -050093wl_input_device_create(struct wl_display *display, const char *path);
94
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -050095void
96wl_display_add_object(struct wl_display *display, struct wl_object *object);
Kristian Høgsberg14fcff72008-11-23 19:10:23 -050097int
98wl_display_add_global(struct wl_display *display, struct wl_object *object);
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -050099
Kristian Høgsbergf9bc7952008-11-02 10:12:29 -0500100void
101wl_display_post_relative_event(struct wl_display *display,
102 struct wl_object *source, int dx, int dy);
103void
104wl_display_post_absolute_event(struct wl_display *display,
105 struct wl_object *source, int x, int y);
106void
107wl_display_post_button_event(struct wl_display *display,
108 struct wl_object *source, int button, int state);
Kristian Høgsbergcddc0ad2008-11-24 00:31:49 -0500109void
110wl_display_post_key_event(struct wl_display *display,
111 struct wl_object *source, int key, int state);
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500112void
113wl_display_post_acknowledge(struct wl_display *display);
Kristian Høgsbergf9bc7952008-11-02 10:12:29 -0500114
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,
Kristian Høgsberg7f77bd82008-11-07 08:39:37 -0500125 struct wl_surface *surface,
126 uint32_t name,
127 uint32_t width, uint32_t height,
128 uint32_t stride);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400129 void (*notify_surface_map)(struct wl_compositor *compositor,
Kristian Høgsberg7f77bd82008-11-07 08:39:37 -0500130 struct wl_surface *surface,
131 struct wl_map *map);
132 void (*notify_surface_copy)(struct wl_compositor *compositor,
133 struct wl_surface *surface,
134 int32_t dst_x, int32_t dst_y,
135 uint32_t name, uint32_t stride,
136 int32_t x, int32_t y,
137 int32_t width, int32_t height);
138 void (*notify_surface_damage)(struct wl_compositor *compositor,
139 struct wl_surface *surface,
140 int32_t x, int32_t y,
141 int32_t width, int32_t height);
Kristian Høgsberg4c9f2c92008-11-21 19:25:44 -0500142 void (*notify_pointer_motion)(struct wl_compositor *compositor,
143 struct wl_object *source,
144 int32_t x, int32_t y);
Kristian Høgsbergcddc0ad2008-11-24 00:31:49 -0500145 void (*notify_key)(struct wl_compositor *compositor,
146 struct wl_object *source,
147 uint32_t key, uint32_t state);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400148};
149
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400150void wl_display_set_compositor(struct wl_display *display,
151 struct wl_compositor *compositor);
152
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500153struct wl_compositor *
154wl_compositor_create(struct wl_display *display);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400155
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -0400156#endif