output-layout: take wl_display in constructor

The output layout creates and destroys wl_output globals. We will
soon need the wl_display to do so.
This commit is contained in:
Simon Ser 2023-08-12 08:24:08 +02:00 committed by Isaac Freund
parent 63792b38e4
commit 6a7463bb8e
6 changed files with 22 additions and 9 deletions

View file

@ -9,17 +9,27 @@
static const struct wlr_addon_interface addon_impl;
struct wlr_output_layout *wlr_output_layout_create(void) {
static void output_layout_handle_display_destroy(struct wl_listener *listener,
void *data) {
struct wlr_output_layout *layout = wl_container_of(listener, layout, display_destroy);
wlr_output_layout_destroy(layout);
}
struct wlr_output_layout *wlr_output_layout_create(struct wl_display *display) {
struct wlr_output_layout *layout = calloc(1, sizeof(*layout));
if (layout == NULL) {
return NULL;
}
wl_list_init(&layout->outputs);
layout->display = display;
wl_signal_init(&layout->events.add);
wl_signal_init(&layout->events.change);
wl_signal_init(&layout->events.destroy);
layout->display_destroy.notify = output_layout_handle_display_destroy;
wl_display_add_destroy_listener(display, &layout->display_destroy);
return layout;
}
@ -45,6 +55,7 @@ void wlr_output_layout_destroy(struct wlr_output_layout *layout) {
output_layout_output_destroy(l_output);
}
wl_list_remove(&layout->display_destroy.link);
free(layout);
}