1 // Copyright © 2017-2021 Rémi Thebault
2 /// bindings to wayland-server-core.h
3 module wayland.native.server;
4 
5 // Wayland server-core copyright:
6 /*
7  * Copyright © 2008 Kristian Høgsberg
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice (including the
18  * next paragraph) shall be included in all copies or substantial
19  * portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
25  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
26  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28  * SOFTWARE.
29  */
30 
31 import wayland.native.util;
32 import core.sys.posix.sys.types;
33 
34 extern(C)
35 {
36     struct wl_display;
37     struct wl_event_loop;
38     struct wl_event_source;
39     struct wl_client;
40     struct wl_global;
41     struct wl_resource;
42     struct wl_shm_buffer;
43     struct wl_shm_pool;
44     struct wl_protocol_logger;
45 
46     struct wl_protocol_logger_message {
47         wl_resource* resource;
48         int message_opcode;
49         const(wl_message)* message;
50         int arguments_count;
51         const(wl_argument)* arguments;
52     }
53 
54     struct wl_listener {
55         wl_list link;
56         wl_notify_func_t notify;
57     }
58 
59     struct wl_signal {
60         wl_list listener_list;
61     }
62 
63     enum {
64         WL_EVENT_READABLE = 0x01,
65         WL_EVENT_WRITABLE = 0x02,
66         WL_EVENT_HANGUP   = 0x04,
67         WL_EVENT_ERROR    = 0x08
68     }
69 
70     enum wl_protocol_logger_type {
71         WL_PROTOCOL_LOGGER_REQUEST,
72         WL_PROTOCOL_LOGGER_EVENT,
73     }
74 
75 
76     alias wl_event_loop_fd_func_t = int function (int fd, uint mask, void* data);
77     alias wl_event_loop_timer_func_t = int function (void* data);
78     alias wl_event_loop_signal_func_t = int function (int signal_number, void* data);
79     alias wl_event_loop_idle_func_t = void function (void* data);
80 
81     alias wl_notify_func_t = void function (wl_listener* listener, void* data);
82     alias wl_global_bind_func_t = void function (wl_client* client, void* data, uint ver, uint id);
83     alias wl_client_for_each_resource_iterator_func_t = wl_iterator_result function (wl_resource* resource, void* user_data);
84 
85     alias wl_display_global_filter_func_t = bool function (const(wl_client)* client, const(wl_global)* global, void* data);
86 
87     alias wl_resource_destroy_func_t = void function (wl_resource* resource);
88 
89     alias wl_protocol_logger_func_t = void function (void* user_data, wl_protocol_logger_type direction, const(wl_protocol_logger_message)* message);
90 }
91 
92 
93 /** Iterate over a list of clients. */
94 auto wlClientForEach(wl_list* list)
95 {
96     struct WlClientRange
97     {
98         wl_list* list;
99         wl_client* client;
100 
101         this(wl_list* list)
102         {
103             this.list = list;
104             this.client = wl_client_from_link(list.next);
105         }
106 
107         @property wl_client* front()
108         {
109             return client;
110         }
111 
112         @property bool empty()
113         {
114             return wl_client_get_link(client) == list;
115         }
116 
117         void popFront()
118         {
119             client = wl_client_from_link(wl_client_get_link(client).next);
120         }
121     }
122 
123     return WlClientRange(list);
124 }
125 
126 
127 /** Initialize a new \ref wl_signal for use.
128  *
129  * \param signal The signal that will be initialized
130  *
131  * \memberof wl_signal
132  */
133 void
134 wl_signal_init(wl_signal* signal)
135 {
136 	wl_list_init(&signal.listener_list);
137 }
138 
139 /** Add the specified listener to this signal.
140  *
141  * \param signal The signal that will emit events to the listener
142  * \param listener The listener to add
143  *
144  * \memberof wl_signal
145  */
146 void
147 wl_signal_add(wl_signal* signal, wl_listener* listener)
148 {
149 	wl_list_insert(signal.listener_list.prev, &listener.link);
150 }
151 
152 /** Gets the listener for the specified callback.
153  *
154  * \param signal The signal that contains the specified listener
155  * \param notify The listener that is the target of this search
156  * \return the list item that corresponds to the specified listener, or NULL
157  * if none was found
158  *
159  * \memberof wl_signal
160  */
161 wl_listener*
162 wl_signal_get(wl_signal* signal, wl_notify_func_t notify)
163 {
164     foreach(l; wl_range!(wl_listener.link)(&signal.listener_list))
165     {
166         if (l.notify == notify) return l;
167     }
168     return null;
169 }
170 
171 /** Emits this signal, notifying all registered listeners.
172  *
173  * \param signal The signal object that will emit the signal
174  * \param data The data that will be emitted with the signal
175  *
176  * \memberof wl_signal
177  */
178 void
179 wl_signal_emit(wl_signal* signal, void* data)
180 {
181     foreach(l; wl_range!(wl_listener.link)(&signal.listener_list))
182     {
183         l.notify(l, data);
184     }
185 }
186 
187 // #define wl_resource_for_each(resource, list)					\
188 //     for (resource = 0, resource = wl_resource_from_link((list)->next);	\
189 //         wl_resource_get_link(resource) != (list);				\
190 //         resource = wl_resource_from_link(wl_resource_get_link(resource)->next))
191 
192 // #define wl_resource_for_each_safe(resource, tmp, list)					\
193 //     for (resource = 0, tmp = 0,							\
194 //         resource = wl_resource_from_link((list)->next),	\
195 //         tmp = wl_resource_from_link((list)->next->next);	\
196 //         wl_resource_get_link(resource) != (list);				\
197 //         resource = tmp,							\
198 //         tmp = wl_resource_from_link(wl_resource_get_link(resource)->next))
199 
200 
201 version(WlDynamic)
202 {
203     extern(C) nothrow
204     {
205         alias da_wl_event_loop_create = wl_event_loop* function ();
206 
207         alias da_wl_event_loop_destroy = void function (wl_event_loop* loop);
208 
209         alias da_wl_event_loop_add_fd = wl_event_source* function (wl_event_loop* loop, int fd, uint mask, wl_event_loop_fd_func_t func, void* data);
210 
211         alias da_wl_event_source_fd_update = int function (wl_event_source* source, uint mask);
212 
213         alias da_wl_event_loop_add_timer = wl_event_source* function (wl_event_loop* loop, wl_event_loop_timer_func_t func, void* data);
214 
215         alias da_wl_event_loop_add_signal = wl_event_source* function (wl_event_loop* loop, int signal_number, wl_event_loop_signal_func_t func, void* data);
216 
217         alias da_wl_event_source_timer_update = int function (wl_event_source* source, int ms_delay);
218 
219         alias da_wl_event_source_remove = int function (wl_event_source* source);
220 
221         alias da_wl_event_source_check = void function (wl_event_source* source);
222 
223         alias da_wl_event_loop_dispatch = int function (wl_event_loop* loop, int timeout);
224 
225         alias da_wl_event_loop_dispatch_idle = void function (wl_event_loop* loop);
226 
227         alias da_wl_event_loop_add_idle = wl_event_source* function (wl_event_loop* loop, wl_event_loop_idle_func_t func, void* data);
228 
229         alias da_wl_event_loop_get_fd = int function (wl_event_loop* loop);
230 
231         alias da_wl_event_loop_add_destroy_listener = void function (wl_event_loop* loop, wl_listener* listener);
232 
233         alias da_wl_event_loop_get_destroy_listener = wl_listener* function (wl_event_loop* loop, wl_notify_func_t notify);
234 
235         alias da_wl_display_create = wl_display* function ();
236 
237         alias da_wl_display_destroy = void function (wl_display* display);
238 
239         alias da_wl_display_get_event_loop = wl_event_loop* function (wl_display* display);
240 
241         alias da_wl_display_add_socket = int function (wl_display* display, const(char)* name);
242 
243         alias da_wl_display_add_socket_auto = const(char)* function (wl_display* display);
244 
245         alias da_wl_display_add_socket_fd = int function (wl_display* display, int sock_fd);
246 
247         alias da_wl_display_terminate = void function (wl_display* display);
248 
249         alias da_wl_display_run = void function (wl_display* display);
250 
251         alias da_wl_display_flush_clients = void function (wl_display* display);
252 
253         alias da_wl_display_get_serial = uint function (wl_display* display);
254 
255         alias da_wl_display_next_serial = uint function (wl_display* display);
256 
257         alias da_wl_display_add_destroy_listener = void function (wl_display* display, wl_listener* listener);
258 
259         alias da_wl_display_add_client_created_listener = void function (wl_display* display, wl_listener* listener);
260 
261         alias da_wl_display_get_destroy_listener = wl_listener* function (wl_display* display, wl_notify_func_t notify);
262 
263         alias da_wl_global_create = wl_global* function (wl_display* display, const(wl_interface)* iface, int ver, void* data, wl_global_bind_func_t bind);
264 
265         alias da_wl_global_destroy = void function (wl_global* global);
266 
267         alias da_wl_display_set_global_filter = void function (wl_display* display, wl_display_global_filter_func_t filter, void* data);
268 
269         alias da_wl_global_get_interface = const(wl_interface)* function (const(wl_global)* global);
270 
271         alias da_wl_global_get_user_data = void* function (const(wl_global)* global);
272 
273         alias da_wl_client_create = wl_client* function (wl_display* display, int fd);
274 
275         alias da_wl_display_get_client_list = wl_list* function (wl_display* display);
276 
277         alias da_wl_client_get_link = wl_list* function (wl_client* client);
278 
279         alias da_wl_client_from_link = wl_client* function (wl_list* link);
280 
281         alias da_wl_client_destroy = void function (wl_client* client);
282 
283         alias da_wl_client_flush = void function (wl_client* client);
284 
285         alias da_wl_client_get_credentials = void function (wl_client* client, pid_t* pid, uid_t* uid, gid_t* gid);
286 
287         alias da_wl_client_get_fd = int function (wl_client* client);
288 
289         alias da_wl_client_add_destroy_listener = void function (wl_client* client, wl_listener* listener);
290 
291         alias da_wl_client_get_destroy_listener = wl_listener* function (wl_client* client, wl_notify_func_t notify);
292 
293         alias da_wl_client_get_object = wl_resource* function (wl_client* client, uint id);
294 
295         alias da_wl_client_post_no_memory = void function (wl_client* client);
296 
297         alias da_wl_client_add_resource_created_listener = void function (wl_client* client, wl_listener* listener);
298 
299         alias da_wl_client_for_each_resource = void function (wl_client* client, wl_client_for_each_resource_iterator_func_t iterator, void* user_data);
300 
301         alias da_wl_resource_post_event = void function (wl_resource* resource, uint opcode, ...);
302 
303         alias da_wl_resource_post_event_array = void function (wl_resource* resource, uint opcode, wl_argument* args);
304 
305         alias da_wl_resource_queue_event = void function (wl_resource* resource, uint opcode, ...);
306 
307         alias da_wl_resource_queue_event_array = void function (wl_resource* resource, uint opcode, wl_argument* args);
308 
309         alias da_wl_resource_post_error = void function (wl_resource* resource, uint code, const(char)* msg, ...);
310 
311         alias da_wl_resource_post_no_memory = void function (wl_resource* resource);
312 
313         alias da_wl_client_get_display = wl_display* function (wl_client* client);
314 
315         alias da_wl_resource_create = wl_resource* function (wl_client* client, const(wl_interface)* iface, int ver, uint id);
316 
317         alias da_wl_resource_set_implementation = void function (wl_resource* resource, const(void)* impl, void* data, wl_resource_destroy_func_t destroy);
318 
319         alias da_wl_resource_set_dispatcher = void function (wl_resource* resource, wl_dispatcher_func_t dispatcher, const(void)* impl, void* data, wl_resource_destroy_func_t destroy);
320 
321         alias da_wl_resource_destroy = void function (wl_resource* resource);
322 
323         alias da_wl_resource_get_id = uint function (wl_resource* resource);
324 
325         alias da_wl_resource_get_link = wl_list* function (wl_resource* resource);
326 
327         alias da_wl_resource_from_link = wl_resource* function (wl_list* resource);
328 
329         alias da_wl_resource_find_for_client = wl_resource* function (wl_list* list, wl_client* client);
330 
331         alias da_wl_resource_get_client = wl_client* function (wl_resource* resource);
332 
333         alias da_wl_resource_set_user_data = void function (wl_resource* resource, void* data);
334 
335         alias da_wl_resource_get_user_data = void* function (wl_resource* resource);
336 
337         alias da_wl_resource_get_version = int function (wl_resource* resource);
338 
339         alias da_wl_resource_set_destructor = void function (wl_resource* resource, wl_resource_destroy_func_t destroy);
340 
341         alias da_wl_resource_instance_of = int function (wl_resource* resource, const(wl_interface)* iface, const(void)* impl);
342 
343         alias da_wl_resource_get_class = const(char)* function (wl_resource* resource);
344 
345         alias da_wl_resource_add_destroy_listener = void function (wl_resource* resource, wl_listener* listener);
346 
347         alias da_wl_resource_get_destroy_listener = wl_listener* function (wl_resource* resource, wl_notify_func_t notify);
348 
349         alias da_wl_shm_buffer_get = wl_shm_buffer* function (wl_resource* resource);
350 
351         alias da_wl_shm_buffer_begin_access = void function (wl_shm_buffer* buffer);
352 
353         alias da_wl_shm_buffer_end_access = void function (wl_shm_buffer* buffer);
354 
355         alias da_wl_shm_buffer_get_data = void* function (wl_shm_buffer* buffer);
356 
357         alias da_wl_shm_buffer_get_stride = int function (wl_shm_buffer* buffer);
358 
359         alias da_wl_shm_buffer_get_format = uint function (wl_shm_buffer* buffer);
360 
361         alias da_wl_shm_buffer_get_width = int function (wl_shm_buffer* buffer);
362 
363         alias da_wl_shm_buffer_get_height = int function (wl_shm_buffer* buffer);
364 
365         alias da_wl_shm_buffer_ref_pool = wl_shm_pool* function (wl_shm_buffer* buffer);
366 
367         alias da_wl_shm_pool_unref = void function (wl_shm_pool* pool);
368 
369         alias da_wl_display_init_shm = int function (wl_display* display);
370 
371         alias da_wl_display_add_shm_format = uint* function (wl_display* display, uint format);
372 
373         alias da_wl_log_set_handler_server = void function (wl_log_func_t handler);
374 
375         alias da_wl_display_add_protocol_logger = wl_protocol_logger* function (wl_display* display, wl_protocol_logger_func_t, void* user_data);
376 
377         alias da_wl_protocol_logger_destroy = void function (wl_protocol_logger* logger);
378     }
379 
380     __gshared
381     {
382         da_wl_event_loop_create wl_event_loop_create;
383         da_wl_event_loop_destroy wl_event_loop_destroy;
384         da_wl_event_loop_add_fd wl_event_loop_add_fd;
385         da_wl_event_source_fd_update wl_event_source_fd_update;
386         da_wl_event_loop_add_timer wl_event_loop_add_timer;
387         da_wl_event_loop_add_signal wl_event_loop_add_signal;
388         da_wl_event_source_timer_update wl_event_source_timer_update;
389         da_wl_event_source_remove wl_event_source_remove;
390         da_wl_event_source_check wl_event_source_check;
391         da_wl_event_loop_dispatch wl_event_loop_dispatch;
392         da_wl_event_loop_dispatch_idle wl_event_loop_dispatch_idle;
393         da_wl_event_loop_add_idle wl_event_loop_add_idle;
394         da_wl_event_loop_get_fd wl_event_loop_get_fd;
395         da_wl_event_loop_add_destroy_listener wl_event_loop_add_destroy_listener;
396         da_wl_event_loop_get_destroy_listener wl_event_loop_get_destroy_listener;
397         da_wl_display_create wl_display_create;
398         da_wl_display_destroy wl_display_destroy;
399         da_wl_display_get_event_loop wl_display_get_event_loop;
400         da_wl_display_add_socket wl_display_add_socket;
401         da_wl_display_add_socket_auto wl_display_add_socket_auto;
402         da_wl_display_add_socket_fd wl_display_add_socket_fd;
403         da_wl_display_terminate wl_display_terminate;
404         da_wl_display_run wl_display_run;
405         da_wl_display_flush_clients wl_display_flush_clients;
406         da_wl_display_get_serial wl_display_get_serial;
407         da_wl_display_next_serial wl_display_next_serial;
408         da_wl_display_add_destroy_listener wl_display_add_destroy_listener;
409         da_wl_display_add_client_created_listener wl_display_add_client_created_listener;
410         da_wl_display_get_destroy_listener wl_display_get_destroy_listener;
411         da_wl_global_create wl_global_create;
412         da_wl_global_destroy wl_global_destroy;
413         da_wl_display_set_global_filter wl_display_set_global_filter;
414         da_wl_global_get_interface wl_global_get_interface;
415         da_wl_global_get_user_data wl_global_get_user_data;
416         da_wl_client_create wl_client_create;
417         da_wl_display_get_client_list wl_display_get_client_list;
418         da_wl_client_get_link wl_client_get_link;
419         da_wl_client_from_link wl_client_from_link;
420         da_wl_client_destroy wl_client_destroy;
421         da_wl_client_flush wl_client_flush;
422         da_wl_client_get_credentials wl_client_get_credentials;
423         da_wl_client_get_fd wl_client_get_fd;
424         da_wl_client_add_destroy_listener wl_client_add_destroy_listener;
425         da_wl_client_get_destroy_listener wl_client_get_destroy_listener;
426         da_wl_client_get_object wl_client_get_object;
427         da_wl_client_post_no_memory wl_client_post_no_memory;
428         da_wl_client_add_resource_created_listener wl_client_add_resource_created_listener;
429         da_wl_client_for_each_resource wl_client_for_each_resource;
430         da_wl_resource_post_event wl_resource_post_event;
431         da_wl_resource_post_event_array wl_resource_post_event_array;
432         da_wl_resource_queue_event wl_resource_queue_event;
433         da_wl_resource_queue_event_array wl_resource_queue_event_array;
434         da_wl_resource_post_error wl_resource_post_error;
435         da_wl_resource_post_no_memory wl_resource_post_no_memory;
436         da_wl_client_get_display wl_client_get_display;
437         da_wl_resource_create wl_resource_create;
438         da_wl_resource_set_implementation wl_resource_set_implementation;
439         da_wl_resource_set_dispatcher wl_resource_set_dispatcher;
440         da_wl_resource_destroy wl_resource_destroy;
441         da_wl_resource_get_id wl_resource_get_id;
442         da_wl_resource_get_link wl_resource_get_link;
443         da_wl_resource_from_link wl_resource_from_link;
444         da_wl_resource_find_for_client wl_resource_find_for_client;
445         da_wl_resource_get_client wl_resource_get_client;
446         da_wl_resource_set_user_data wl_resource_set_user_data;
447         da_wl_resource_get_user_data wl_resource_get_user_data;
448         da_wl_resource_get_version wl_resource_get_version;
449         da_wl_resource_set_destructor wl_resource_set_destructor;
450         da_wl_resource_instance_of wl_resource_instance_of;
451         da_wl_resource_get_class wl_resource_get_class;
452         da_wl_resource_add_destroy_listener wl_resource_add_destroy_listener;
453         da_wl_resource_get_destroy_listener wl_resource_get_destroy_listener;
454         da_wl_shm_buffer_get wl_shm_buffer_get;
455         da_wl_shm_buffer_begin_access wl_shm_buffer_begin_access;
456         da_wl_shm_buffer_end_access wl_shm_buffer_end_access;
457         da_wl_shm_buffer_get_data wl_shm_buffer_get_data;
458         da_wl_shm_buffer_get_stride wl_shm_buffer_get_stride;
459         da_wl_shm_buffer_get_format wl_shm_buffer_get_format;
460         da_wl_shm_buffer_get_width wl_shm_buffer_get_width;
461         da_wl_shm_buffer_get_height wl_shm_buffer_get_height;
462         da_wl_shm_buffer_ref_pool wl_shm_buffer_ref_pool;
463         da_wl_shm_pool_unref wl_shm_pool_unref;
464         da_wl_display_init_shm wl_display_init_shm;
465         da_wl_display_add_shm_format wl_display_add_shm_format;
466         da_wl_log_set_handler_server wl_log_set_handler_server;
467         da_wl_display_add_protocol_logger wl_display_add_protocol_logger;
468         da_wl_protocol_logger_destroy wl_protocol_logger_destroy;
469     }
470 }
471 
472 version(WlStatic)
473 {
474     extern(C) nothrow
475     {
476         wl_event_loop* wl_event_loop_create();
477 
478         void wl_event_loop_destroy(wl_event_loop* loop);
479 
480         wl_event_source* wl_event_loop_add_fd(wl_event_loop* loop, int fd, uint mask, wl_event_loop_fd_func_t func, void* data);
481 
482         int wl_event_source_fd_update(wl_event_source* source, uint mask);
483 
484         wl_event_source* wl_event_loop_add_timer(wl_event_loop* loop, wl_event_loop_timer_func_t func, void* data);
485 
486         wl_event_source* wl_event_loop_add_signal(wl_event_loop* loop, int signal_number, wl_event_loop_signal_func_t func, void* data);
487 
488         int wl_event_source_timer_update(wl_event_source* source, int ms_delay);
489 
490         int wl_event_source_remove(wl_event_source* source);
491 
492         void wl_event_source_check(wl_event_source* source);
493 
494         int wl_event_loop_dispatch(wl_event_loop* loop, int timeout);
495 
496         void wl_event_loop_dispatch_idle(wl_event_loop* loop);
497 
498         wl_event_source* wl_event_loop_add_idle(wl_event_loop* loop, wl_event_loop_idle_func_t func, void* data);
499 
500         int wl_event_loop_get_fd(wl_event_loop* loop);
501 
502         void wl_event_loop_add_destroy_listener(wl_event_loop* loop, wl_listener* listener);
503 
504         wl_listener* wl_event_loop_get_destroy_listener(wl_event_loop* loop, wl_notify_func_t notify);
505 
506         wl_display* wl_display_create();
507 
508         void wl_display_destroy(wl_display* display);
509 
510         wl_event_loop* wl_display_get_event_loop(wl_display* display);
511 
512         int wl_display_add_socket(wl_display* display, const(char)* name);
513 
514         const(char)* wl_display_add_socket_auto(wl_display* display);
515 
516         int wl_display_add_socket_fd(wl_display* display, int sock_fd);
517 
518         void wl_display_terminate(wl_display* display);
519 
520         void wl_display_run(wl_display* display);
521 
522         void wl_display_flush_clients(wl_display* display);
523 
524         uint wl_display_get_serial(wl_display* display);
525 
526         uint wl_display_next_serial(wl_display* display);
527 
528         void wl_display_add_destroy_listener(wl_display* display, wl_listener* listener);
529 
530         void wl_display_add_client_created_listener(wl_display* display, wl_listener* listener);
531 
532         wl_listener* wl_display_get_destroy_listener(wl_display* display, wl_notify_func_t notify);
533 
534         wl_global* wl_global_create(wl_display* display, const(wl_interface)* iface, int ver, void* data, wl_global_bind_func_t bind);
535 
536         void wl_global_destroy(wl_global* global);
537 
538         void wl_display_set_global_filter(wl_display* display, wl_display_global_filter_func_t filter, void* data);
539 
540         const(wl_interface)* wl_global_get_interface(const(wl_global)* global);
541 
542         void* wl_global_get_user_data(const(wl_global)* global);
543 
544         wl_client* wl_client_create(wl_display* display, int fd);
545 
546         wl_list* wl_display_get_client_list(wl_display* display);
547 
548         wl_list* wl_client_get_link(wl_client* client);
549 
550         wl_client* wl_client_from_link(wl_list* link);
551 
552         void wl_client_destroy(wl_client* client);
553 
554         void wl_client_flush(wl_client* client);
555 
556         void wl_client_get_credentials(wl_client* client, pid_t* pid, uid_t* uid, gid_t* gid);
557 
558         int wl_client_get_fd(wl_client* client);
559 
560         void wl_client_add_destroy_listener(wl_client* client, wl_listener* listener);
561 
562         wl_listener* wl_client_get_destroy_listener(wl_client* client, wl_notify_func_t notify);
563 
564         wl_resource* wl_client_get_object(wl_client* client, uint id);
565 
566         void wl_client_post_no_memory(wl_client* client);
567 
568         void wl_client_add_resource_created_listener(wl_client* client, wl_listener* listener);
569 
570         void wl_client_for_each_resource(wl_client* client, wl_client_for_each_resource_iterator_func_t iterator, void* user_data);
571 
572         void wl_resource_post_event(wl_resource* resource, uint opcode, ...);
573 
574         void wl_resource_post_event_array(wl_resource* resource, uint opcode, wl_argument* args);
575 
576         void wl_resource_queue_event(wl_resource* resource, uint opcode, ...);
577 
578         void wl_resource_queue_event_array(wl_resource* resource, uint opcode, wl_argument* args);
579 
580         /* msg is a printf format string, variable args are its args. */
581         void wl_resource_post_error(wl_resource* resource, uint code, const(char)* msg, ...);
582 
583         void wl_resource_post_no_memory(wl_resource* resource);
584 
585         wl_display* wl_client_get_display(wl_client* client);
586 
587         wl_resource* wl_resource_create(wl_client* client, const(wl_interface)* iface, int ver, uint id);
588 
589         void wl_resource_set_implementation(wl_resource* resource, const(void)* impl, void* data, wl_resource_destroy_func_t destroy);
590 
591         void wl_resource_set_dispatcher(wl_resource* resource, wl_dispatcher_func_t dispatcher, const(void)* impl, void* data, wl_resource_destroy_func_t destroy);
592 
593         void wl_resource_destroy(wl_resource* resource);
594 
595         uint wl_resource_get_id(wl_resource* resource);
596 
597         wl_list* wl_resource_get_link(wl_resource* resource);
598 
599         wl_resource* wl_resource_from_link(wl_list* resource);
600 
601         wl_resource* wl_resource_find_for_client(wl_list* list, wl_client* client);
602 
603         wl_client* wl_resource_get_client(wl_resource* resource);
604 
605         void wl_resource_set_user_data(wl_resource* resource, void* data);
606 
607         void* wl_resource_get_user_data(wl_resource* resource);
608 
609         int wl_resource_get_version(wl_resource* resource);
610 
611         void wl_resource_set_destructor(wl_resource* resource, wl_resource_destroy_func_t destroy);
612 
613         int wl_resource_instance_of(wl_resource* resource, const(wl_interface)* iface, const(void)* impl);
614 
615         const(char)* wl_resource_get_class(wl_resource* resource);
616 
617         void wl_resource_add_destroy_listener(wl_resource* resource, wl_listener* listener);
618 
619         wl_listener* wl_resource_get_destroy_listener(wl_resource* resource, wl_notify_func_t notify);
620 
621         wl_shm_buffer* wl_shm_buffer_get(wl_resource* resource);
622 
623         void wl_shm_buffer_begin_access(wl_shm_buffer* buffer);
624 
625         void wl_shm_buffer_end_access(wl_shm_buffer* buffer);
626 
627         void* wl_shm_buffer_get_data(wl_shm_buffer* buffer);
628 
629         int wl_shm_buffer_get_stride(wl_shm_buffer* buffer);
630 
631         uint wl_shm_buffer_get_format(wl_shm_buffer* buffer);
632 
633         int wl_shm_buffer_get_width(wl_shm_buffer* buffer);
634 
635         int wl_shm_buffer_get_height(wl_shm_buffer* buffer);
636 
637         wl_shm_pool* wl_shm_buffer_ref_pool(wl_shm_buffer* buffer);
638 
639         void wl_shm_pool_unref(wl_shm_pool* pool);
640 
641         int wl_display_init_shm(wl_display* display);
642 
643         uint* wl_display_add_shm_format(wl_display* display, uint format);
644 
645         void wl_log_set_handler_server(wl_log_func_t handler);
646 
647         wl_protocol_logger* wl_display_add_protocol_logger(wl_display* display, wl_protocol_logger_func_t, void* user_data);
648 
649         void wl_protocol_logger_destroy(wl_protocol_logger* logger);
650     }
651 }
652