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,
89 struct wl_object *global,
92 int wl_display_add_global(struct wl_display *display,
93 struct wl_object *object,
94 wl_global_bind_func_t func);
96 int wl_display_remove_global(struct wl_display *display,
97 struct wl_object *object);
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_post_global(struct wl_client *client, struct wl_object *object);
105 void wl_client_flush(struct wl_client *client);
108 struct wl_object object;
111 struct wl_shm_callbacks {
112 void (*buffer_created)(struct wl_buffer *buffer);
114 void (*buffer_damaged)(struct wl_buffer *buffer,
115 int32_t x, int32_t y,
116 int32_t width, int32_t height);
118 void (*buffer_destroyed)(struct wl_buffer *buffer);
121 struct wl_compositor {
122 struct wl_object object;
123 struct wl_visual argb_visual;
124 struct wl_visual premultiplied_argb_visual;
125 struct wl_visual rgb_visual;
129 struct wl_object object;
130 void (*destroy)(struct wl_resource *resource,
131 struct wl_client *client);
133 struct wl_list destroy_listener_list;
137 struct wl_resource resource;
138 struct wl_client *client;
139 struct wl_visual *visual;
140 int32_t width, height;
147 void (*func)(struct wl_listener *listener,
148 struct wl_resource *resource, uint32_t time);
152 struct wl_resource resource;
153 struct wl_client *client;
157 struct wl_grab_interface {
158 void (*motion)(struct wl_grab *grab,
159 uint32_t time, int32_t x, int32_t y);
160 void (*button)(struct wl_grab *grab,
161 uint32_t time, int32_t button, int32_t state);
162 void (*end)(struct wl_grab *grab, uint32_t time);
166 const struct wl_grab_interface *interface;
167 struct wl_input_device *input_device;
170 struct wl_input_device {
171 struct wl_object object;
172 struct wl_compositor *compositor;
173 struct wl_surface *pointer_focus;
174 struct wl_surface *keyboard_focus;
175 struct wl_array keys;
176 uint32_t pointer_focus_time;
177 uint32_t keyboard_focus_time;
178 struct wl_listener pointer_focus_listener;
179 struct wl_listener keyboard_focus_listener;
182 struct wl_grab *grab;
183 struct wl_grab motion_grab;
185 int32_t grab_x, grab_y;
186 uint32_t grab_button;
187 struct wl_listener grab_listener;
190 struct wl_drag_offer {
191 struct wl_object object;
195 struct wl_resource resource;
197 struct wl_drag_offer drag_offer;
198 struct wl_surface *source;
199 struct wl_surface *drag_focus;
200 struct wl_client *target;
201 int32_t x, y, sx, sy;
202 struct wl_array types;
204 uint32_t pointer_focus_time;
205 struct wl_listener drag_focus_listener;
208 struct wl_selection_offer {
209 struct wl_object object;
212 struct wl_selection {
213 struct wl_resource resource;
214 struct wl_client *client;
215 struct wl_input_device *input_device;
216 struct wl_selection_offer selection_offer;
217 struct wl_surface *selection_focus;
218 struct wl_client *target;
219 struct wl_array types;
220 struct wl_listener selection_focus_listener;
224 wl_client_post_event(struct wl_client *client,
225 struct wl_object *sender,
226 uint32_t event, ...);
229 wl_display_set_compositor(struct wl_display *display,
230 struct wl_compositor *compositor,
231 const struct wl_compositor_interface *implementation);
234 wl_display_post_frame(struct wl_display *display, struct wl_surface *surface,
238 wl_client_add_resource(struct wl_client *client,
239 struct wl_resource *resource);
242 wl_client_get_display(struct wl_client *client);
245 wl_resource_destroy(struct wl_resource *resource,
246 struct wl_client *client, uint32_t time);
249 wl_input_device_init(struct wl_input_device *device,
250 struct wl_compositor *compositor);
253 wl_input_device_set_pointer_focus(struct wl_input_device *device,
254 struct wl_surface *surface,
256 int32_t x, int32_t y,
257 int32_t sx, int32_t sy);
260 wl_input_device_set_keyboard_focus(struct wl_input_device *device,
261 struct wl_surface *surface,
265 wl_input_device_end_grab(struct wl_input_device *device, uint32_t time);
267 wl_input_device_start_grab(struct wl_input_device *device,
268 struct wl_grab *grab,
269 uint32_t button, uint32_t time);
271 wl_input_device_update_grab(struct wl_input_device *device,
272 struct wl_grab *grab,
273 struct wl_surface *surface, uint32_t time);
278 wl_shm_buffer_get_data(struct wl_buffer *buffer);
281 wl_shm_buffer_get_stride(struct wl_buffer *buffer);
284 wl_shm_buffer_create(struct wl_shm *shm, int width, int height,
285 int stride, struct wl_visual *visual,
289 wl_buffer_is_shm(struct wl_buffer *buffer);
292 wl_shm_init(struct wl_display *display,
293 const struct wl_shm_callbacks *callbacks);
296 wl_shm_finish(struct wl_shm *shm);
299 wl_compositor_init(struct wl_compositor *compositor,
300 const struct wl_compositor_interface *interface,
301 struct wl_display *display);