mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-21 22:52:20 +00:00
backend/wayland: take wl_event_loop instead of wl_display
This commit is contained in:
parent
f5e8fa48f3
commit
ed0bba581b
@ -194,7 +194,8 @@ static struct wlr_auto_backend_monitor *auto_backend_monitor_create(
|
||||
}
|
||||
|
||||
static struct wlr_backend *attempt_wl_backend(struct wl_display *display) {
|
||||
struct wlr_backend *backend = wlr_wl_backend_create(display, NULL);
|
||||
struct wl_event_loop *loop = wl_display_get_event_loop(display);
|
||||
struct wlr_backend *backend = wlr_wl_backend_create(loop, NULL);
|
||||
if (backend == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -480,7 +480,7 @@ static void backend_destroy(struct wlr_backend *backend) {
|
||||
|
||||
wlr_backend_finish(backend);
|
||||
|
||||
wl_list_remove(&wl->local_display_destroy.link);
|
||||
wl_list_remove(&wl->event_loop_destroy.link);
|
||||
|
||||
wl_event_source_remove(wl->remote_display_src);
|
||||
|
||||
@ -561,13 +561,12 @@ bool wlr_backend_is_wl(struct wlr_backend *b) {
|
||||
return b->impl == &backend_impl;
|
||||
}
|
||||
|
||||
static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
||||
struct wlr_wl_backend *wl =
|
||||
wl_container_of(listener, wl, local_display_destroy);
|
||||
static void handle_event_loop_destroy(struct wl_listener *listener, void *data) {
|
||||
struct wlr_wl_backend *wl = wl_container_of(listener, wl, event_loop_destroy);
|
||||
backend_destroy(&wl->backend);
|
||||
}
|
||||
|
||||
struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
|
||||
struct wlr_backend *wlr_wl_backend_create(struct wl_event_loop *loop,
|
||||
struct wl_display *remote_display) {
|
||||
wlr_log(WLR_INFO, "Creating wayland backend");
|
||||
|
||||
@ -579,7 +578,7 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
|
||||
|
||||
wlr_backend_init(&wl->backend, &backend_impl);
|
||||
|
||||
wl->local_display = display;
|
||||
wl->event_loop = loop;
|
||||
wl_list_init(&wl->outputs);
|
||||
wl_list_init(&wl->seats);
|
||||
wl_list_init(&wl->buffers);
|
||||
@ -644,7 +643,6 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
|
||||
zwp_linux_dmabuf_feedback_v1_destroy(linux_dmabuf_feedback_v1);
|
||||
}
|
||||
|
||||
struct wl_event_loop *loop = wl_display_get_event_loop(wl->local_display);
|
||||
int fd = wl_display_get_fd(wl->remote_display);
|
||||
wl->remote_display_src = wl_event_loop_add_fd(loop, fd, WL_EVENT_READABLE,
|
||||
dispatch_events, wl);
|
||||
@ -666,8 +664,8 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
|
||||
wl->drm_fd = -1;
|
||||
}
|
||||
|
||||
wl->local_display_destroy.notify = handle_display_destroy;
|
||||
wl_display_add_destroy_listener(display, &wl->local_display_destroy);
|
||||
wl->event_loop_destroy.notify = handle_event_loop_destroy;
|
||||
wl_event_loop_add_destroy_listener(loop, &wl->event_loop_destroy);
|
||||
|
||||
const char *token = getenv("XDG_ACTIVATION_TOKEN");
|
||||
if (token != NULL) {
|
||||
|
@ -774,7 +774,7 @@ static struct wlr_wl_output *output_create(struct wlr_wl_backend *backend,
|
||||
wlr_output_state_set_custom_mode(&state, 1280, 720, 0);
|
||||
|
||||
wlr_output_init(wlr_output, &backend->backend, &output_impl,
|
||||
wl_display_get_event_loop(backend->local_display), &state);
|
||||
backend->event_loop, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
|
||||
wlr_output->adaptive_sync_status = WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED;
|
||||
@ -871,9 +871,8 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *wlr_backend) {
|
||||
&xdg_toplevel_listener, output);
|
||||
wl_surface_commit(output->surface);
|
||||
|
||||
struct wl_event_loop *event_loop = wl_display_get_event_loop(backend->local_display);
|
||||
while (!output->configured) {
|
||||
int ret = wl_event_loop_dispatch(event_loop, -1);
|
||||
int ret = wl_event_loop_dispatch(backend->event_loop, -1);
|
||||
if (ret < 0) {
|
||||
wlr_log(WLR_ERROR, "wl_event_loop_dispatch() failed");
|
||||
goto error;
|
||||
|
@ -159,7 +159,8 @@ int main(int argc, char *argv[]) {
|
||||
init_egl(remote_display);
|
||||
|
||||
struct wl_display *local_display = wl_display_create();
|
||||
struct wlr_backend *backend = wlr_wl_backend_create(local_display, remote_display);
|
||||
struct wl_event_loop *event_loop = wl_display_get_event_loop(local_display);
|
||||
struct wlr_backend *backend = wlr_wl_backend_create(event_loop, remote_display);
|
||||
struct wlr_renderer *renderer = wlr_renderer_autocreate(backend);
|
||||
wlr_renderer_init_wl_display(renderer, local_display);
|
||||
struct wlr_allocator *allocator = wlr_allocator_autocreate(backend, renderer);
|
||||
|
@ -20,12 +20,12 @@ struct wlr_wl_backend {
|
||||
|
||||
/* local state */
|
||||
bool started;
|
||||
struct wl_display *local_display;
|
||||
struct wl_event_loop *event_loop;
|
||||
struct wl_list outputs;
|
||||
int drm_fd;
|
||||
struct wl_list buffers; // wlr_wl_buffer.link
|
||||
size_t requested_outputs;
|
||||
struct wl_listener local_display_destroy;
|
||||
struct wl_listener event_loop_destroy;
|
||||
char *activation_token;
|
||||
|
||||
/* remote state */
|
||||
|
@ -15,7 +15,7 @@ struct wlr_input_device;
|
||||
* The remote_display argument is an existing libwayland-client struct wl_display
|
||||
* to use. Leave it NULL to create a new connection to the compositor.
|
||||
*/
|
||||
struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
|
||||
struct wlr_backend *wlr_wl_backend_create(struct wl_event_loop *loop,
|
||||
struct wl_display *remote_display);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user