Skip to content

wayland-client: Add wl_display_get_default_queue

Mark Bolhuis requested to merge markbolhuis/wayland:default-queue into main

Signed-off-by: Mark Bolhuis

This adds a way to get the default event queue from a wl_display.

Why? For convenience - so that the client can use wl_display_dispatch_queue and friends instead of using wl_display_dispatch. This prevents unnecessary code duplication and wrapper functions.

For context I'm writing my own windowing abstraction library, and I'm abstracting an event queue into it's own type. Such an abstraction needs to reconcile with how Win32 handles message queues, where one and only one exists per thread. Thus my abstraction has to follow this design, which Wayland can support.

For the Wayland implementation of the library, each thread is implicitly assigned one and only one wl_event_queue, with the default assigned to the main thread.

For this library I've found that I'm having to write functions like so:

int queue_dispatch(struct queue *q) {
    if (q->wl_event_queue) {
        return wl_display_dispatch_queue(q->wl_display, q->wl_event_queue);
    return wl_display_dispatch(q->wl_display);

Getting the default wl_event_queue will avoid a lot of these unnecessary wrappers.

Merge request reports