2 * Copyright © 2008 Kristian Høgsberg
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
31 #include "wayland-util.h"
32 #include "wayland-server-protocol.h"
35 WL_EVENT_READABLE = 0x01,
36 WL_EVENT_WRITEABLE = 0x02
40 struct wl_event_source;
41 typedef int (*wl_event_loop_fd_func_t)(int fd, uint32_t mask, void *data);
42 typedef int (*wl_event_loop_timer_func_t)(void *data);
43 typedef int (*wl_event_loop_signal_func_t)(int signal_number, void *data);
44 typedef void (*wl_event_loop_idle_func_t)(void *data);
46 struct wl_event_loop *wl_event_loop_create(void);
47 void wl_event_loop_destroy(struct wl_event_loop *loop);
48 struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *loop,
49 int fd, uint32_t mask,
50 wl_event_loop_fd_func_t func,
52 int wl_event_source_fd_update(struct wl_event_source *source, uint32_t mask);
53 struct wl_event_source *wl_event_loop_add_timer(struct wl_event_loop *loop,
54 wl_event_loop_timer_func_t func,
56 struct wl_event_source *
57 wl_event_loop_add_signal(struct wl_event_loop *loop,
59 wl_event_loop_signal_func_t func,
62 int wl_event_source_timer_update(struct wl_event_source *source,
64 int wl_event_source_remove(struct wl_event_source *source);
65 void wl_event_source_check(struct wl_event_source *source);
68 int wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout);
69 struct wl_event_source *wl_event_loop_add_idle(struct wl_event_loop *loop,
70 wl_event_loop_idle_func_t func,
72 int wl_event_loop_get_fd(struct wl_event_loop *loop);
76 struct wl_input_device;
78 struct wl_display *wl_display_create(void);
79 void wl_display_destroy(struct wl_display *display);
80 struct wl_event_loop *wl_display_get_event_loop(struct wl_display *display);
81 int wl_display_add_socket(struct wl_display *display, const char *name);
82 void wl_display_terminate(struct wl_display *display);
83 void wl_display_run(struct wl_display *display);
85 void wl_display_add_object(struct wl_display *display,
86 struct wl_object *object);
88 typedef void (*wl_global_bind_func_t)(struct wl_client *client, void *data,
89 uint32_t version, uint32_t id);
91 struct wl_global *wl_display_add_global(struct wl_display *display,
92 const struct wl_interface *interface,
94 wl_global_bind_func_t bind);
96 void wl_display_remove_global(struct wl_display *display,
97 struct wl_global *global);
99 struct wl_client *wl_client_create(struct wl_display *display, int fd);
100 void wl_client_destroy(struct wl_client *client);
101 void wl_client_post_error(struct wl_client *client, struct wl_object *object,
102 uint32_t code, const char *msg, ...);
103 void wl_client_post_no_memory(struct wl_client *client);
104 void wl_client_flush(struct wl_client *client);
107 wl_client_add_object(struct wl_client *client,
108 const struct wl_interface *interface,
109 const void *implementation, uint32_t id, void *data);
112 struct wl_object object;
113 void (*destroy)(struct wl_resource *resource);
115 struct wl_list destroy_listener_list;
116 struct wl_client *client;
121 struct wl_object object;
125 struct wl_shm_callbacks {
126 void (*buffer_created)(struct wl_buffer *buffer);
128 void (*buffer_damaged)(struct wl_buffer *buffer,
129 int32_t x, int32_t y,
130 int32_t width, int32_t height);
132 void (*buffer_destroyed)(struct wl_buffer *buffer);
135 struct wl_compositor {
136 const struct wl_compositor_interface *interface;
137 struct wl_visual argb_visual;
138 struct wl_visual premultiplied_argb_visual;
139 struct wl_visual rgb_visual;
143 struct wl_resource resource;
144 struct wl_visual *visual;
145 int32_t width, height;
152 void (*func)(struct wl_listener *listener,
153 struct wl_resource *resource, uint32_t time);
157 struct wl_resource resource;
161 struct wl_grab_interface {
162 void (*motion)(struct wl_grab *grab,
163 uint32_t time, int32_t x, int32_t y);
164 void (*button)(struct wl_grab *grab,
165 uint32_t time, int32_t button, int32_t state);
166 void (*end)(struct wl_grab *grab, uint32_t time);
170 const struct wl_grab_interface *interface;
171 struct wl_input_device *input_device;
174 struct wl_input_device {
175 struct wl_list resource_list;
176 struct wl_compositor *compositor;
177 struct wl_resource *pointer_focus_resource;
178 struct wl_surface *pointer_focus;
179 struct wl_resource *keyboard_focus_resource;
180 struct wl_surface *keyboard_focus;
181 struct wl_array keys;
182 uint32_t pointer_focus_time;
183 uint32_t keyboard_focus_time;
184 struct wl_listener pointer_focus_listener;
185 struct wl_listener keyboard_focus_listener;
188 struct wl_grab *grab;
189 struct wl_grab motion_grab;
191 int32_t grab_x, grab_y;
192 uint32_t grab_button;
193 struct wl_listener grab_listener;
196 struct wl_drag_offer {
197 struct wl_resource resource;
201 struct wl_resource resource;
203 struct wl_drag_offer drag_offer;
204 struct wl_surface *source;
205 struct wl_surface *drag_focus;
206 struct wl_client *target;
207 int32_t x, y, sx, sy;
208 struct wl_array types;
210 uint32_t pointer_focus_time;
211 struct wl_listener drag_focus_listener;
214 struct wl_selection_offer {
215 struct wl_resource resource;
218 struct wl_selection {
219 struct wl_resource resource;
220 struct wl_client *client;
221 struct wl_input_device *input_device;
222 struct wl_selection_offer selection_offer;
223 struct wl_surface *selection_focus;
224 struct wl_client *target;
225 struct wl_array types;
226 struct wl_listener selection_focus_listener;
230 wl_resource_post_event(struct wl_resource *resource, uint32_t opcode, ...);
233 wl_display_set_compositor(struct wl_display *display,
234 struct wl_compositor *compositor,
235 const struct wl_compositor_interface *implementation);
238 wl_display_post_frame(struct wl_display *display, struct wl_surface *surface,
242 wl_client_add_resource(struct wl_client *client,
243 struct wl_resource *resource);
246 wl_client_get_display(struct wl_client *client);
249 wl_resource_destroy(struct wl_resource *resource, uint32_t time);
252 wl_input_device_init(struct wl_input_device *device,
253 struct wl_compositor *compositor);
256 wl_input_device_set_pointer_focus(struct wl_input_device *device,
257 struct wl_surface *surface,
259 int32_t x, int32_t y,
260 int32_t sx, int32_t sy);
263 wl_input_device_set_keyboard_focus(struct wl_input_device *device,
264 struct wl_surface *surface,
268 wl_input_device_end_grab(struct wl_input_device *device, uint32_t time);
270 wl_input_device_start_grab(struct wl_input_device *device,
271 struct wl_grab *grab,
272 uint32_t button, uint32_t time);
274 wl_input_device_update_grab(struct wl_input_device *device,
275 struct wl_grab *grab,
276 struct wl_surface *surface, uint32_t time);
281 wl_shm_buffer_get_data(struct wl_buffer *buffer);
284 wl_shm_buffer_get_stride(struct wl_buffer *buffer);
287 wl_shm_buffer_create(struct wl_shm *shm, int width, int height,
288 int stride, struct wl_visual *visual,
292 wl_buffer_is_shm(struct wl_buffer *buffer);
295 wl_shm_init(struct wl_display *display,
296 const struct wl_shm_callbacks *callbacks);
299 wl_shm_finish(struct wl_shm *shm);
302 wl_compositor_init(struct wl_compositor *compositor,
303 const struct wl_compositor_interface *interface,
304 struct wl_display *display);