backend: add wlr_backend.event_loop

Many objects depending on wlr_backend need access to the event
loop. Storing it here will simplify wlr_output when combined
with [1], and will allow wlr_renderer_autocreate() to have access
to the event loop.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4310
This commit is contained in:
Simon Ser 2023-08-21 16:34:13 +02:00
parent d3a339a03e
commit 3b3640dda4
9 changed files with 10 additions and 8 deletions

View file

@ -39,9 +39,10 @@
#define WAIT_SESSION_TIMEOUT 10000 // ms
void wlr_backend_init(struct wlr_backend *backend,
const struct wlr_backend_impl *impl) {
const struct wlr_backend_impl *impl, struct wl_event_loop *loop) {
*backend = (struct wlr_backend){
.impl = impl,
.event_loop = loop,
};
wl_signal_init(&backend->events.destroy);
wl_signal_init(&backend->events.new_input);

View file

@ -208,7 +208,7 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
wlr_log_errno(WLR_ERROR, "Allocation failed");
return NULL;
}
wlr_backend_init(&drm->backend, &backend_impl);
wlr_backend_init(&drm->backend, &backend_impl, wl_display_get_event_loop(display));
drm->session = session;
wl_list_init(&drm->fbs);

View file

@ -72,7 +72,7 @@ struct wlr_backend *wlr_headless_backend_create(struct wl_display *display) {
return NULL;
}
wlr_backend_init(&backend->backend, &backend_impl);
wlr_backend_init(&backend->backend, &backend_impl, wl_display_get_event_loop(display));
backend->display = display;
wl_list_init(&backend->outputs);

View file

@ -199,7 +199,7 @@ struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display,
wlr_log(WLR_ERROR, "Allocation failed: %s", strerror(errno));
return NULL;
}
wlr_backend_init(&backend->backend, &backend_impl);
wlr_backend_init(&backend->backend, &backend_impl, wl_display_get_event_loop(display));
wl_list_init(&backend->devices);

View file

@ -119,7 +119,7 @@ struct wlr_backend *wlr_multi_backend_create(struct wl_display *display) {
}
wl_list_init(&backend->backends);
wlr_backend_init(&backend->backend, &backend_impl);
wlr_backend_init(&backend->backend, &backend_impl, wl_display_get_event_loop(display));
wl_signal_init(&backend->events.backend_add);
wl_signal_init(&backend->events.backend_remove);

View file

@ -577,7 +577,7 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
return NULL;
}
wlr_backend_init(&wl->backend, &backend_impl);
wlr_backend_init(&wl->backend, &backend_impl, wl_display_get_event_loop(display));
wl->local_display = display;
wl_list_init(&wl->outputs);

View file

@ -400,7 +400,7 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
return NULL;
}
wlr_backend_init(&x11->backend, &backend_impl);
wlr_backend_init(&x11->backend, &backend_impl, wl_display_get_event_loop(display));
x11->wl_display = display;
wl_list_init(&x11->outputs);

View file

@ -19,6 +19,7 @@ struct wlr_backend_impl;
*/
struct wlr_backend {
const struct wlr_backend_impl *impl;
struct wl_event_loop *event_loop;
struct {
/** Raised when destroyed */

View file

@ -24,7 +24,7 @@ struct wlr_backend_impl {
* to the provided struct wlr_backend_impl reference.
*/
void wlr_backend_init(struct wlr_backend *backend,
const struct wlr_backend_impl *impl);
const struct wlr_backend_impl *impl, struct wl_event_loop *loop);
/**
* Emit the destroy event and clean up common backend state.
*/