From b62ac611c8825f83c992843e3832474eaa2e4b72 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 23 Nov 2023 14:03:14 +0100 Subject: [PATCH] backend/x11: take wl_event_loop instead of wl_display --- backend/backend.c | 3 ++- backend/x11/backend.c | 18 ++++++++---------- backend/x11/output.c | 3 +-- include/backend/x11.h | 4 ++-- include/wlr/backend/x11.h | 2 +- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/backend/backend.c b/backend/backend.c index 9b384068..8a6ca7a5 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -211,7 +211,8 @@ static struct wlr_backend *attempt_wl_backend(struct wl_display *display) { static struct wlr_backend *attempt_x11_backend(struct wl_display *display, const char *x11_display) { #if WLR_HAS_X11_BACKEND - struct wlr_backend *backend = wlr_x11_backend_create(display, x11_display); + struct wl_event_loop *loop = wl_display_get_event_loop(display); + struct wlr_backend *backend = wlr_x11_backend_create(loop, x11_display); if (backend == NULL) { return NULL; } diff --git a/backend/x11/backend.c b/backend/x11/backend.c index c650712f..3c963a28 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -192,7 +192,7 @@ static void backend_destroy(struct wlr_backend *backend) { if (x11->event_source) { wl_event_source_remove(x11->event_source); } - wl_list_remove(&x11->display_destroy.link); + wl_list_remove(&x11->event_loop_destroy.link); wlr_drm_format_set_finish(&x11->primary_dri3_formats); wlr_drm_format_set_finish(&x11->primary_shm_formats); @@ -230,9 +230,8 @@ bool wlr_backend_is_x11(struct wlr_backend *backend) { return backend->impl == &backend_impl; } -static void handle_display_destroy(struct wl_listener *listener, void *data) { - struct wlr_x11_backend *x11 = - wl_container_of(listener, x11, display_destroy); +static void handle_event_loop_destroy(struct wl_listener *listener, void *data) { + struct wlr_x11_backend *x11 = wl_container_of(listener, x11, event_loop_destroy); backend_destroy(&x11->backend); } @@ -391,7 +390,7 @@ static void x11_get_argb32(struct wlr_x11_backend *x11) { free(reply); } -struct wlr_backend *wlr_x11_backend_create(struct wl_display *display, +struct wlr_backend *wlr_x11_backend_create(struct wl_event_loop *loop, const char *x11_display) { wlr_log(WLR_INFO, "Creating X11 backend"); @@ -401,7 +400,7 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display, } wlr_backend_init(&x11->backend, &backend_impl); - x11->wl_display = display; + x11->event_loop = loop; wl_list_init(&x11->outputs); x11->xcb = xcb_connect(x11_display, NULL); @@ -561,9 +560,8 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display, free(xi_reply); int fd = xcb_get_file_descriptor(x11->xcb); - struct wl_event_loop *ev = wl_display_get_event_loop(display); uint32_t events = WL_EVENT_READABLE | WL_EVENT_ERROR | WL_EVENT_HANGUP; - x11->event_source = wl_event_loop_add_fd(ev, fd, events, x11_event, x11); + x11->event_source = wl_event_loop_add_fd(loop, fd, events, x11_event, x11); if (!x11->event_source) { wlr_log(WLR_ERROR, "Could not create event source"); goto error_display; @@ -644,8 +642,8 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display, wlr_keyboard_init(&x11->keyboard, &x11_keyboard_impl, x11_keyboard_impl.name); - x11->display_destroy.notify = handle_display_destroy; - wl_display_add_destroy_listener(display, &x11->display_destroy); + x11->event_loop_destroy.notify = handle_event_loop_destroy; + wl_event_loop_add_destroy_listener(loop, &x11->event_loop_destroy); // Create an empty pixmap to be used as the cursor. The // default GC foreground is 0, and that is what it will be diff --git a/backend/x11/output.c b/backend/x11/output.c index db63f82f..0c4966c6 100644 --- a/backend/x11/output.c +++ b/backend/x11/output.c @@ -575,8 +575,7 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) { wlr_output_state_init(&state); wlr_output_state_set_custom_mode(&state, 1024, 768, 0); - wlr_output_init(wlr_output, &x11->backend, &output_impl, - wl_display_get_event_loop(x11->wl_display), &state); + wlr_output_init(wlr_output, &x11->backend, &output_impl, x11->event_loop, &state); wlr_output_state_finish(&state); size_t output_num = ++last_output_num; diff --git a/include/backend/x11.h b/include/backend/x11.h index 9eb208b1..fcea4d25 100644 --- a/include/backend/x11.h +++ b/include/backend/x11.h @@ -62,7 +62,7 @@ struct wlr_x11_touchpoint { struct wlr_x11_backend { struct wlr_backend backend; - struct wl_display *wl_display; + struct wl_event_loop *event_loop; bool started; xcb_connection_t *xcb; @@ -108,7 +108,7 @@ struct wlr_x11_backend { uint8_t present_opcode; uint8_t xinput_opcode; - struct wl_listener display_destroy; + struct wl_listener event_loop_destroy; }; struct wlr_x11_buffer { diff --git a/include/wlr/backend/x11.h b/include/wlr/backend/x11.h index 54d91c75..1791041c 100644 --- a/include/wlr/backend/x11.h +++ b/include/wlr/backend/x11.h @@ -17,7 +17,7 @@ struct wlr_input_device; * The `x11_display` argument is the name of the X Display socket. Set * to NULL for the default behaviour of XOpenDisplay(). */ -struct wlr_backend *wlr_x11_backend_create(struct wl_display *display, +struct wlr_backend *wlr_x11_backend_create(struct wl_event_loop *loop, const char *x11_display); /**