aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-11-23 13:42:11 +0100
committerKirill Primak <vyivel@eclair.cafe>2024-01-25 15:05:36 +0000
commit682dbf36e53a36b09a2cc37ef6bdaf21fa8d35b5 (patch)
treee084ad677654a2f874907a646d21740b14545d1e
parent0867dd4e6bf1c0ff8d947d563bdd333464a1c0a8 (diff)
backend/headless: take wl_event_loop instead of wl_display
-rw-r--r--backend/backend.c3
-rw-r--r--backend/headless/backend.c14
-rw-r--r--backend/headless/output.c6
-rw-r--r--include/backend/headless.h4
-rw-r--r--include/wlr/backend/headless.h2
5 files changed, 14 insertions, 15 deletions
diff --git a/backend/backend.c b/backend/backend.c
index 05a40c04..0843d180 100644
--- a/backend/backend.c
+++ b/backend/backend.c
@@ -229,7 +229,8 @@ static struct wlr_backend *attempt_x11_backend(struct wl_display *display,
static struct wlr_backend *attempt_headless_backend(
struct wl_display *display) {
- struct wlr_backend *backend = wlr_headless_backend_create(display);
+ struct wl_event_loop *loop = wl_display_get_event_loop(display);
+ struct wlr_backend *backend = wlr_headless_backend_create(loop);
if (backend == NULL) {
return NULL;
}
diff --git a/backend/headless/backend.c b/backend/headless/backend.c
index 8ab7d039..e643a06e 100644
--- a/backend/headless/backend.c
+++ b/backend/headless/backend.c
@@ -40,7 +40,7 @@ static void backend_destroy(struct wlr_backend *wlr_backend) {
wlr_output_destroy(&output->wlr_output);
}
- wl_list_remove(&backend->display_destroy.link);
+ wl_list_remove(&backend->event_loop_destroy.link);
free(backend);
}
@@ -57,13 +57,13 @@ static const struct wlr_backend_impl backend_impl = {
.get_buffer_caps = get_buffer_caps,
};
-static void handle_display_destroy(struct wl_listener *listener, void *data) {
+static void handle_event_loop_destroy(struct wl_listener *listener, void *data) {
struct wlr_headless_backend *backend =
- wl_container_of(listener, backend, display_destroy);
+ wl_container_of(listener, backend, event_loop_destroy);
backend_destroy(&backend->backend);
}
-struct wlr_backend *wlr_headless_backend_create(struct wl_display *display) {
+struct wlr_backend *wlr_headless_backend_create(struct wl_event_loop *loop) {
wlr_log(WLR_INFO, "Creating headless backend");
struct wlr_headless_backend *backend = calloc(1, sizeof(*backend));
@@ -74,11 +74,11 @@ struct wlr_backend *wlr_headless_backend_create(struct wl_display *display) {
wlr_backend_init(&backend->backend, &backend_impl);
- backend->display = display;
+ backend->event_loop = loop;
wl_list_init(&backend->outputs);
- backend->display_destroy.notify = handle_display_destroy;
- wl_display_add_destroy_listener(display, &backend->display_destroy);
+ backend->event_loop_destroy.notify = handle_event_loop_destroy;
+ wl_event_loop_add_destroy_listener(loop, &backend->event_loop_destroy);
return &backend->backend;
}
diff --git a/backend/headless/output.c b/backend/headless/output.c
index b3ac279e..5aaf1bd8 100644
--- a/backend/headless/output.c
+++ b/backend/headless/output.c
@@ -119,8 +119,7 @@ struct wlr_output *wlr_headless_add_output(struct wlr_backend *wlr_backend,
wlr_output_state_init(&state);
wlr_output_state_set_custom_mode(&state, width, height, 0);
- wlr_output_init(wlr_output, &backend->backend, &output_impl,
- wl_display_get_event_loop(backend->display), &state);
+ wlr_output_init(wlr_output, &backend->backend, &output_impl, backend->event_loop, &state);
wlr_output_state_finish(&state);
output_update_refresh(output, 0);
@@ -135,8 +134,7 @@ struct wlr_output *wlr_headless_add_output(struct wlr_backend *wlr_backend,
snprintf(description, sizeof(description), "Headless output %zu", output_num);
wlr_output_set_description(wlr_output, description);
- struct wl_event_loop *ev = wl_display_get_event_loop(backend->display);
- output->frame_timer = wl_event_loop_add_timer(ev, signal_frame, output);
+ output->frame_timer = wl_event_loop_add_timer(backend->event_loop, signal_frame, output);
wl_list_insert(&backend->outputs, &output->link);
diff --git a/include/backend/headless.h b/include/backend/headless.h
index 4c71fb60..21df86ea 100644
--- a/include/backend/headless.h
+++ b/include/backend/headless.h
@@ -8,9 +8,9 @@
struct wlr_headless_backend {
struct wlr_backend backend;
- struct wl_display *display;
+ struct wl_event_loop *event_loop;
struct wl_list outputs;
- struct wl_listener display_destroy;
+ struct wl_listener event_loop_destroy;
bool started;
};
diff --git a/include/wlr/backend/headless.h b/include/wlr/backend/headless.h
index 2516f3a6..126f1ff2 100644
--- a/include/wlr/backend/headless.h
+++ b/include/wlr/backend/headless.h
@@ -16,7 +16,7 @@
* Creates a headless backend. A headless backend has no outputs or inputs by
* default.
*/
-struct wlr_backend *wlr_headless_backend_create(struct wl_display *display);
+struct wlr_backend *wlr_headless_backend_create(struct wl_event_loop *loop);
/**
* Create a new headless output.
*