backend/wayland: use a separate event queue for busy loops

This avoids processing events which we're not interested in.
Specifically, this fixes a case where output_commit() could be
indirectly called from itself either from import_dmabuf() or while
waiting for a configure event when enabling the output.
This commit is contained in:
Kirill Primak 2025-01-24 19:36:47 +03:00 committed by Isaac Freund
parent 35ff09a754
commit b13fe9b3a1
3 changed files with 38 additions and 7 deletions

View file

@ -555,6 +555,7 @@ static void backend_destroy(struct wlr_backend *backend) {
wl_compositor_destroy(wl->compositor);
wl_registry_destroy(wl->registry);
wl_display_flush(wl->remote_display);
wl_event_queue_destroy(wl->busy_loop_queue);
if (wl->own_remote_display) {
wl_display_disconnect(wl->remote_display);
}
@ -610,10 +611,16 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_event_loop *loop,
wl->own_remote_display = true;
}
wl->busy_loop_queue = wl_display_create_queue(wl->remote_display);
if (wl->busy_loop_queue == NULL) {
wlr_log_errno(WLR_ERROR, "Could not create a Wayland event queue");
goto error_display;
}
wl->registry = wl_display_get_registry(wl->remote_display);
if (!wl->registry) {
wlr_log_errno(WLR_ERROR, "Could not obtain reference to remote registry");
goto error_display;
goto error_queue;
}
wl_registry_add_listener(wl->registry, &registry_listener, wl);
@ -715,6 +722,8 @@ error_registry:
xdg_wm_base_destroy(wl->xdg_wm_base);
}
wl_registry_destroy(wl->registry);
error_queue:
wl_event_queue_destroy(wl->busy_loop_queue);
error_display:
if (wl->own_remote_display) {
wl_display_disconnect(wl->remote_display);