Table of Contents
The open-source reference implementation of Wayland protocol is split in two C libraries, libwayland-client and libwayland-server. Their main responsibility is to handle the Inter-process communication (IPC) with each other, therefore guaranteeing the protocol objects marshaling and messages synchronization.
The server library is designed to work much like libwayland-client, although it is considerably complicated due to the server needing to support multiple versions of the protocol. It is best to learn libwayland-client first.
Each open socket to a client is represented by a wl_client. The equvalent of the wl_proxy that libwayland-client uses to represent an object is wl_resource for client-created objects, and wl_global for objects created by the server.
Often a server is also a client for another Wayland server, and thus must link with both libwayland-client and libwayland-server. This produces some type name conflicts (such as the client wl_display and server wl_display, but the duplicate-but-not-the-same types are opaque, and accessed only inside the correct library where it came from. Naturally that means that the program writer needs to always know if a pointer to a wl_display is for the server or client side and use the corresponding functions.
This union represents all of the basic data types that can be passed in the wayland wire format. It is used by dispatchers and runtime-friendly versions of the event and request marshaling functions.
void wl_client_flush(struct wl_client *client)
Events sent to clients are queued in a buffer and written to the socket later - typically when the compositor has handled all requests and goes back to block in the event loop. This function flushes all queued up events for a client immediately.
struct wl_display * wl_client_get_display(struct wl_client *client)
void wl_client_get_credentials(struct wl_client *client, pid_t *pid, uid_t *uid, gid_t *gid)
This function returns the process ID, the user ID and the group ID for the given client. The credentials come from getsockopt() with SO_PEERCRED, on the client socket fd. All the pointers can be NULL, if the caller is not interested in a particular ID.
Be aware that for clients that a compositor forks and execs and then connects using socketpair(), this function will return the credentials for the compositor. The credentials for the socketpair are set at creation time in the compositor.
int wl_client_get_fd(struct wl_client *client)
This function returns the file descriptor for the given client.
Be sure to use the file descriptor from the client for inspection only. If the caller does anything to the file descriptor that changes its state, it will likely cause problems.
See also wl_client_get_credentials(). It is recommended that you evaluate whether wl_client_get_credentials() can be applied to your use case instead of this function.
If you would like to distinguish just between the client and the compositor itself from the client's request, it can be done by getting the client credentials and by checking the PID of the client and the compositor's PID. Regarding the case in which the socketpair() is being used, you need to be careful. Please note the documentation for wl_client_get_credentials().
This function can be used for a compositor to validate a request from a client if there are additional information provided from the client's file descriptor. For instance, suppose you can get the security contexts from the client's file descriptor. The compositor can validate the client's request with the contexts and make a decision whether it permits or deny it.
struct wl_resource * wl_client_get_object(struct wl_client *client, uint32_t id)
This looks up an object in the client object name space by its object ID.
struct wl_list * wl_client_get_link(struct wl_client *client)
See also: wl_client_for_each() See also: wl_display_get_client_list() See also: wl_client_from_link()
struct wl_client * wl_client_from_link(struct wl_list *link)
See also: wl_client_for_each() See also: wl_display_get_client_list() See also: wl_client_get_link()
void wl_client_add_resource_created_listener(struct wl_client *client, struct wl_listener *listener)
When a new resource is created for this client the listener will be notified, carrying the new resource as the data argument.
void wl_client_for_each_resource(struct wl_client *client, wl_client_for_each_resource_iterator_func_t iterator, void *user_data)
The function pointed by iterator will be called for each resource owned by the client. The user_data will be passed as the second argument of the iterator function. If the iterator function returns WL_ITERATOR_CONTINUE the iteration will continue, if it returns WL_ITERATOR_STOP it will stop.
Creating and destroying resources while iterating is safe, but new resources may or may not be picked up by the iterator.
See also: wl_iterator_result
struct wl_client * wl_client_create(struct wl_display *display, int fd)
Given a file descriptor corresponding to one end of a socket, this function will create a wl_client struct and add the new client to the compositors client list. At that point, the client is initialized and ready to run, as if the client had connected to the servers listening socket. When the client eventually sends requests to the compositor, the wl_client argument to the request handler will be the wl_client returned from this function.
The other end of the socket can be passed to wl_display_connect_to_fd() on the client side or used with the WAYLAND_SOCKET environment variable on the client side.
Listeners added with wl_display_add_client_created_listener() will be notified by this function after the client is fully constructed.
On failure this function sets errno accordingly and returns NULL.
struct wl_display * wl_display_create(void)
This creates the wl_display object.
void wl_display_destroy(struct wl_display *display)
This function emits the wl_display destroy signal, releases all the sockets added to this display, free's all the globals associated with this display, free's memory of additional shared memory formats and destroy the display object.
See also: wl_display_add_destroy_listener
uint32_t wl_display_get_serial(struct wl_display *display)
This function returns the most recent serial number, but does not increment it.
uint32_t wl_display_next_serial(struct wl_display *display)
This function increments the display serial number and returns the new value.
int wl_display_add_socket_fd(struct wl_display *display, int sock_fd)
The existing socket fd must already be created, opened, and locked. The fd must be properly set to CLOEXEC and bound to a socket file with both bind() and listen() already called.
int wl_display_add_socket(struct wl_display *display, const char *name)
This adds a Unix socket to Wayland display which can be used by clients to connect to Wayland display.
If NULL is passed as name, then it would look for WAYLAND_DISPLAY env variable for the socket name. If WAYLAND_DISPLAY is not set, then default wayland-0 is used.
The Unix socket will be created in the directory pointed to by environment variable XDG_RUNTIME_DIR. If XDG_RUNTIME_DIR is not set, then this function fails and returns -1.
The length of socket path, i.e., the path set in XDG_RUNTIME_DIR and the socket name, must not exceed the maximum length of a Unix socket path. The function also fails if the user do not have write permission in the XDG_RUNTIME_DIR path or if the socket name is already in use.
struct wl_protocol_logger * wl_display_add_protocol_logger(struct wl_display *display, wl_protocol_logger_func_t func, void *user_data)
When a new protocol message arrives or is sent from the server all the protocol logger functions will be called, carrying the user_data pointer, the type of the message (request or event) and the actual message. The lifetime of the messages passed to the logger function ends when they return so the messages cannot be stored and accessed later.
errno is set on error.
See also: wl_protocol_logger_destroy
uint32_t * wl_display_add_shm_format(struct wl_display *display, uint32_t format)
Add the specified wl_shm format to the list of formats the wl_shm object advertises when a client binds to it. Adding a format to the list means that clients will know that the compositor supports this format and may use it for creating wl_shm buffers. The compositor must be able to handle the pixel format when a client requests it.
The compositor by default supports WL_SHM_FORMAT_ARGB8888 and WL_SHM_FORMAT_XRGB8888.
struct wl_list * wl_display_get_client_list(struct wl_display *display)
This function returns a pointer to the list of clients currently connected to the display. You can iterate on the list by using the wl_client_for_each macro. The returned value is valid for the lifetime of the display. You must not modify the returned list, but only access it.
See also: wl_client_for_each() See also: wl_client_get_link() See also: wl_client_from_link()
The list head is of "struct wl_list" type, and must be initialized using wl_list_init(). All entries in the list must be of the same type. The item type must have a "struct wl_list" member. This member will be initialized by wl_list_insert(). There is no need to call wl_list_init() on the individual item. To query if the list is empty in O(1), use wl_list_empty().
Let's call the list reference "struct wl_list foo_list", the item type as "item_t", and the item member as "struct wl_list link".
The following code will initialize a list:
struct wl_list foo_list; struct item_t { int foo; struct wl_list link; }; struct item_t item1, item2, item3; wl_list_init(&foo_list); wl_list_insert(&foo_list, &item1.link); // Pushes item1 at the head wl_list_insert(&foo_list, &item2.link); // Pushes item2 at the head wl_list_insert(&item2.link, &item3.link); // Pushes item3 after item2
The list now looks like [item2, item3, item1]
Iterate the list in ascending order:
item_t *item; wl_list_for_each(item, foo_list, link) { Do_something_with_item(item); }
wl_listener provides the means to listen for wl_signal notifications. Many Wayland objects use wl_listener for notification of significant events like object destruction.
Clients should create wl_listener objects manually and can register them as listeners to signals using wl_signal_add, assuming the signal is directly accessible. For opaque structs like wl_event_loop, adding a listener should be done through provided accessor methods. A listener can only listen to one signal at a time.
struct wl_listener your_listener; your_listener.notify = your_callback_method; // Direct access wl_signal_add(&some_object->destroy_signal, &your_listener); // Accessor access wl_event_loop *loop = ...; wl_event_loop_add_destroy_listener(loop, &your_listener);
If the listener is part of a larger struct, wl_container_of can be used to retrieve a pointer to it:
void your_listener(struct wl_listener *listener, void *data) { struct your_data *data; your_data = wl_container_of(listener, data, your_member_name); }
If you need to remove a listener from a signal, use wl_list_remove().
wl_list_remove(&your_listener.link);
See also: wl_signal
void wl_protocol_logger_destroy(struct wl_protocol_logger *logger)
This function destroys a protocol logger and removes it from the display it was added to with wl_display_add_protocol_logger. The logger object becomes invalid after calling this function.
See also: wl_display_add_protocol_logger
const char * wl_resource_get_class(struct wl_resource *resource)
struct wl_resource * wl_resource_create(struct wl_client *client, const struct wl_interface *interface, int version, uint32_t id)
Listeners added with wl_client_add_resource_created_listener will be notified at the end of this function.
void * wl_shm_buffer_get_data(struct wl_shm_buffer *buffer)
Returns a pointer which can be used to read the data contained in the given SHM buffer.
As this buffer is memory-mapped, reading from it may generate SIGBUS signals. This can happen if the client claims that the buffer is larger than it is or if something truncates the underlying file. To prevent this signal from causing the compositor to crash you should call wl_shm_buffer_begin_access and wl_shm_buffer_end_access around code that reads from the memory.
struct wl_shm_pool * wl_shm_buffer_ref_pool(struct wl_shm_buffer *buffer)
Returns a pointer to a buffer's shm_pool and increases the shm_pool refcount.
The compositor must remember to call wl_shm_pool_unref when it no longer needs the reference to ensure proper destruction of the pool.
See also: wl_shm_pool_unref
void wl_shm_buffer_begin_access(struct wl_shm_buffer *buffer)
An SHM buffer is a memory-mapped file given by the client. According to POSIX, reading from a memory-mapped region that extends off the end of the file will cause a SIGBUS signal to be generated. Normally this would cause the compositor to terminate. In order to make the compositor robust against clients that change the size of the underlying file or lie about its size, you should protect access to the buffer by calling this function before reading from the memory and call wl_shm_buffer_end_access afterwards. This will install a signal handler for SIGBUS which will prevent the compositor from crashing.
After calling this function the signal handler will remain installed for the lifetime of the compositor process. Note that this function will not work properly if the compositor is also installing its own handler for SIGBUS.
If a SIGBUS signal is received for an address within the range of the SHM pool of the given buffer then the client will be sent an error event when wl_shm_buffer_end_access is called. If the signal is for an address outside that range then the signal handler will reraise the signal which would will likely cause the compositor to terminate.
It is safe to nest calls to these functions as long as the nested calls are all accessing the same buffer. The number of calls to wl_shm_buffer_end_access must match the number of calls to wl_shm_buffer_begin_access. These functions are thread-safe and it is allowed to simultaneously access different buffers or the same buffer from multiple threads.
void wl_shm_buffer_end_access(struct wl_shm_buffer *buffer)
This should be called after wl_shm_buffer_begin_access once the buffer is no longer being accessed. If a SIGBUS signal was generated in-between these two calls then the resource for the given buffer will be sent an error.
void wl_shm_pool_unref(struct wl_shm_pool *pool)
Drops a reference to a wl_shm_pool object.
This is only necessary if the compositor has explicitly taken a reference with wl_shm_buffer_ref_pool(), otherwise the pool will be automatically destroyed when appropriate.
See also: wl_shm_buffer_ref_pool
Signals are recognized points where significant events can be observed. Compositors as well as the server can provide signals. Observers are wl_listener's that are added through wl_signal_add. Signals are emitted using wl_signal_emit, which will invoke all listeners until that listener is removed by wl_list_remove() (or whenever the signal is destroyed).
See also: wl_listener for more information on using wl_signal
static void wl_signal_init(struct wl_signal *signal)
static void wl_signal_add(struct wl_signal *signal, struct wl_listener *listener)
static struct wl_listener * wl_signal_get(struct wl_signal *signal, wl_notify_func_t notify)
static void wl_signal_emit(struct wl_signal *signal, void *data)
struct wl_event_loop* wl_event_loop_create(void)
void wl_event_loop_destroy(struct wl_event_loop *loop)
struct wl_event_source* wl_event_loop_add_fd(struct wl_event_loop *loop, int fd, uint32_t mask, wl_event_loop_fd_func_t func, void *data)
int wl_event_source_fd_update(struct wl_event_source *source, uint32_t mask)
struct wl_event_source* wl_event_loop_add_timer(struct wl_event_loop *loop, wl_event_loop_timer_func_t func, void *data)
struct wl_event_source* wl_event_loop_add_signal(struct wl_event_loop *loop, int signal_number, wl_event_loop_signal_func_t func, void *data)
int wl_event_source_timer_update(struct wl_event_source *source, int ms_delay)
int wl_event_source_remove(struct wl_event_source *source)
void wl_event_source_check(struct wl_event_source *source)
int wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout)
void wl_event_loop_dispatch_idle(struct wl_event_loop *loop)
struct wl_event_source* wl_event_loop_add_idle(struct wl_event_loop *loop, wl_event_loop_idle_func_t func, void *data)
int wl_event_loop_get_fd(struct wl_event_loop *loop)
void wl_event_loop_add_destroy_listener(struct wl_event_loop *loop, struct wl_listener *listener)
struct wl_listener* wl_event_loop_get_destroy_listener(struct wl_event_loop *loop, wl_notify_func_t notify)
struct wl_display* wl_display_create(void)
void wl_display_destroy(struct wl_display *display)
struct wl_event_loop* wl_display_get_event_loop(struct wl_display *display)
int wl_display_add_socket(struct wl_display *display, const char *name)
const char* wl_display_add_socket_auto(struct wl_display *display)
int wl_display_add_socket_fd(struct wl_display *display, int sock_fd)
void wl_display_terminate(struct wl_display *display)
void wl_display_run(struct wl_display *display)
void wl_display_flush_clients(struct wl_display *display)
uint32_t wl_display_get_serial(struct wl_display *display)
uint32_t wl_display_next_serial(struct wl_display *display)
void wl_display_add_destroy_listener(struct wl_display *display, struct wl_listener *listener)
void wl_display_add_client_created_listener(struct wl_display *display, struct wl_listener *listener)
When a new client object is created, listener will be notified, carrying a pointer to the new wl_client object.
wl_client_create wl_display wl_listener
struct wl_listener* wl_display_get_destroy_listener(struct wl_display *display, wl_notify_func_t notify)
struct wl_global* wl_global_create(struct wl_display *display, const struct wl_interface *interface, int version, void *data, wl_global_bind_func_t bind)
void wl_global_destroy(struct wl_global *global)
struct wl_client* wl_client_create(struct wl_display *display, int fd)
struct wl_list* wl_display_get_client_list(struct wl_display *display)
struct wl_list* wl_client_get_link(struct wl_client *client)
struct wl_client* wl_client_from_link(struct wl_list *link)
void wl_client_destroy(struct wl_client *client)
void wl_client_flush(struct wl_client *client)
void wl_client_get_credentials(struct wl_client *client, pid_t *pid, uid_t *uid, gid_t *gid)
int wl_client_get_fd(struct wl_client *client)
void wl_client_add_destroy_listener(struct wl_client *client, struct wl_listener *listener)
struct wl_listener* wl_client_get_destroy_listener(struct wl_client *client, wl_notify_func_t notify)
struct wl_resource* wl_client_get_object(struct wl_client *client, uint32_t id)
void wl_client_post_no_memory(struct wl_client *client)
void wl_client_add_resource_created_listener(struct wl_client *client, struct wl_listener *listener)
void wl_client_for_each_resource(struct wl_client *client, wl_client_for_each_resource_iterator_func_t iterator, void *user_data)
void wl_resource_post_event(struct wl_resource *resource, uint32_t opcode,...)
void wl_resource_post_event_array(struct wl_resource *resource, uint32_t opcode, union wl_argument *args)
void wl_resource_queue_event(struct wl_resource *resource, uint32_t opcode,...)
void wl_resource_queue_event_array(struct wl_resource *resource, uint32_t opcode, union wl_argument *args)
void wl_resource_post_error(struct wl_resource *resource, uint32_t code, const char *msg,...) WL_PRINTF(3
void void wl_resource_post_no_memory(struct wl_resource *resource)
struct wl_display* wl_client_get_display(struct wl_client *client)
struct wl_resource* wl_resource_create(struct wl_client *client, const struct wl_interface *interface, int version, uint32_t id)
void wl_resource_set_implementation(struct wl_resource *resource, const void *implementation, void *data, wl_resource_destroy_func_t destroy)
void wl_resource_set_dispatcher(struct wl_resource *resource, wl_dispatcher_func_t dispatcher, const void *implementation, void *data, wl_resource_destroy_func_t destroy)
void wl_resource_destroy(struct wl_resource *resource)
uint32_t wl_resource_get_id(struct wl_resource *resource)
struct wl_list* wl_resource_get_link(struct wl_resource *resource)
struct wl_resource* wl_resource_from_link(struct wl_list *resource)
struct wl_resource* wl_resource_find_for_client(struct wl_list *list, struct wl_client *client)
struct wl_client* wl_resource_get_client(struct wl_resource *resource)
void wl_resource_set_user_data(struct wl_resource *resource, void *data)
void* wl_resource_get_user_data(struct wl_resource *resource)
int wl_resource_get_version(struct wl_resource *resource)
void wl_resource_set_destructor(struct wl_resource *resource, wl_resource_destroy_func_t destroy)
int wl_resource_instance_of(struct wl_resource *resource, const struct wl_interface *interface, const void *implementation)
const char* wl_resource_get_class(struct wl_resource *resource)
void wl_resource_add_destroy_listener(struct wl_resource *resource, struct wl_listener *listener)
struct wl_listener* wl_resource_get_destroy_listener(struct wl_resource *resource, wl_notify_func_t notify)
struct wl_shm_buffer* wl_shm_buffer_get(struct wl_resource *resource)
void wl_shm_buffer_begin_access(struct wl_shm_buffer *buffer)
void wl_shm_buffer_end_access(struct wl_shm_buffer *buffer)
void* wl_shm_buffer_get_data(struct wl_shm_buffer *buffer)
int32_t wl_shm_buffer_get_stride(struct wl_shm_buffer *buffer)
uint32_t wl_shm_buffer_get_format(struct wl_shm_buffer *buffer)
int32_t wl_shm_buffer_get_width(struct wl_shm_buffer *buffer)
int32_t wl_shm_buffer_get_height(struct wl_shm_buffer *buffer)
struct wl_shm_pool* wl_shm_buffer_ref_pool(struct wl_shm_buffer *buffer)
void wl_shm_pool_unref(struct wl_shm_pool *pool)
int wl_display_init_shm(struct wl_display *display)
uint32_t* wl_display_add_shm_format(struct wl_display *display, uint32_t format)
struct wl_shm_buffer* wl_shm_buffer_create(struct wl_client *client, uint32_t id, int32_t width, int32_t height, int32_t stride, uint32_t format) WL_DEPRECATED
void wl_log_set_handler_server(wl_log_func_t handler)
struct wl_protocol_logger* wl_display_add_protocol_logger(struct wl_display *display, wl_protocol_logger_func_t, void *user_data)
void wl_protocol_logger_destroy(struct wl_protocol_logger *logger)
void wl_resource_post_event_array(struct wl_resource *resource, uint32_t opcode, union wl_argument *args)
void wl_resource_post_event(struct wl_resource *resource, uint32_t opcode,...)
void wl_resource_queue_event_array(struct wl_resource *resource, uint32_t opcode, union wl_argument *args)
void wl_resource_queue_event(struct wl_resource *resource, uint32_t opcode,...)
void wl_resource_post_error(struct wl_resource *resource, uint32_t code, const char *msg,...)
void wl_client_post_no_memory(struct wl_client *client)
void wl_resource_post_no_memory(struct wl_resource *resource)
void wl_resource_destroy(struct wl_resource *resource)
uint32_t wl_resource_get_id(struct wl_resource *resource)
struct wl_list* wl_resource_get_link(struct wl_resource *resource)
struct wl_resource* wl_resource_from_link(struct wl_list *link)
struct wl_resource* wl_resource_find_for_client(struct wl_list *list, struct wl_client *client)
struct wl_client* wl_resource_get_client(struct wl_resource *resource)
void wl_resource_set_user_data(struct wl_resource *resource, void *data)
void* wl_resource_get_user_data(struct wl_resource *resource)
int wl_resource_get_version(struct wl_resource *resource)
void wl_resource_set_destructor(struct wl_resource *resource, wl_resource_destroy_func_t destroy)
int wl_resource_instance_of(struct wl_resource *resource, const struct wl_interface *interface, const void *implementation)
void wl_resource_add_destroy_listener(struct wl_resource *resource, struct wl_listener *listener)
struct wl_listener* wl_resource_get_destroy_listener(struct wl_resource *resource, wl_notify_func_t notify)
void wl_client_add_destroy_listener(struct wl_client *client, struct wl_listener *listener)
struct wl_listener* wl_client_get_destroy_listener(struct wl_client *client, wl_notify_func_t notify)
void wl_client_destroy(struct wl_client *client)
struct wl_global* wl_global_create(struct wl_display *display, const struct wl_interface *interface, int version, void *data, wl_global_bind_func_t bind)
void wl_global_destroy(struct wl_global *global)
struct wl_event_loop* wl_display_get_event_loop(struct wl_display *display)
void wl_display_terminate(struct wl_display *display)
void wl_display_run(struct wl_display *display)
void wl_display_flush_clients(struct wl_display *display)
const char* wl_display_add_socket_auto(struct wl_display *display)
void wl_display_add_destroy_listener(struct wl_display *display, struct wl_listener *listener)
void wl_display_add_client_created_listener(struct wl_display *display, struct wl_listener *listener)
When a new client object is created, listener will be notified, carrying a pointer to the new wl_client object.
wl_client_create wl_display wl_listener
struct wl_listener* wl_display_get_destroy_listener(struct wl_display *display, wl_notify_func_t notify)
void wl_resource_set_implementation(struct wl_resource *resource, const void *implementation, void *data, wl_resource_destroy_func_t destroy)
void wl_resource_set_dispatcher(struct wl_resource *resource, wl_dispatcher_func_t dispatcher, const void *implementation, void *data, wl_resource_destroy_func_t destroy)
void wl_log_set_handler_server(wl_log_func_t handler)
uint32_t wl_client_add_resource(struct wl_client *client, struct wl_resource *resource) WL_DEPRECATED
struct wl_resource* wl_client_add_object(struct wl_client *client, const struct wl_interface *interface, const void *implementation, uint32_t id, void *data) WL_DEPRECATED
struct wl_resource* wl_client_new_object(struct wl_client *client, const struct wl_interface *interface, const void *implementation, void *data) WL_DEPRECATED
struct wl_global* wl_display_add_global(struct wl_display *display, const struct wl_interface *interface, void *data, wl_global_bind_func_t bind) WL_DEPRECATED
void wl_display_remove_global(struct wl_display *display, struct wl_global *global) WL_DEPRECATED
int wl_display_init_shm(struct wl_display *display)
struct wl_shm_buffer* wl_shm_buffer_get(struct wl_resource *resource)
int32_t wl_shm_buffer_get_stride(struct wl_shm_buffer *buffer)
uint32_t wl_shm_buffer_get_format(struct wl_shm_buffer *buffer)
int32_t wl_shm_buffer_get_width(struct wl_shm_buffer *buffer)
int32_t wl_shm_buffer_get_height(struct wl_shm_buffer *buffer)
void wl_list_init(struct wl_list *list)
void wl_list_insert(struct wl_list *list, struct wl_list *elm)
void wl_list_remove(struct wl_list *elm)
int wl_list_length(const struct wl_list *list)
int wl_list_empty(const struct wl_list *list)
void wl_list_insert_list(struct wl_list *list, struct wl_list *other)
void wl_array_init(struct wl_array *array)
void wl_array_release(struct wl_array *array)
void* wl_array_add(struct wl_array *array, size_t size)
int wl_array_copy(struct wl_array *array, struct wl_array *source)
This macro allows conversion from a pointer to a item to its containing struct. This is useful if you have a contained item like a wl_list, wl_listener, or wl_signal, provided via a callback or other means and would like to retrieve the struct that contains it.
To demonstrate, the following example retrieves a pointer to example_container given only its destroy_listener member:
struct example_container { struct wl_listener destroy_listener; // other members... }; void example_container_destroy(struct wl_listener *listener, void *data) { struct example_container *ctr; ctr = wl_container_of(listener, ctr, destroy_listener); // destroy ctr... }
typedef int(* wl_dispatcher_func_t) (const void *, void *, uint32_t, const struct wl_message *, union wl_argument *))(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *)
A dispatcher is a function that handles the emitting of callbacks in client code. For programs directly using the C library, this is done by using libffi to call function pointers. When binding to languages other than C, dispatchers provide a way to abstract the function calling process to be friendlier to other function calling systems.
A dispatcher takes five arguments: The first is the dispatcher-specific implementation data associated with the target object. The second is the object on which the callback is being invoked (either wl_proxy or wl_resource). The third and fourth arguments are the opcode the wl_message structure corresponding to the callback being emitted. The final argument is an array of arguments received from the other process via the wire protocol.
void wl_list_init(struct wl_list *list)
void wl_list_insert(struct wl_list *list, struct wl_list *elm)
void wl_list_remove(struct wl_list *elm)
int wl_list_length(const struct wl_list *list)
int wl_list_empty(const struct wl_list *list)
void wl_list_insert_list(struct wl_list *list, struct wl_list *other)
void wl_array_init(struct wl_array *array)
void wl_array_release(struct wl_array *array)
void* wl_array_add(struct wl_array *array, size_t size)
int wl_array_copy(struct wl_array *array, struct wl_array *source)