aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/wlr/types/wlr_output.h2
-rw-r--r--types/wlr_output.c11
2 files changed, 13 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index 42c46233..04662820 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -74,6 +74,8 @@ struct wlr_output {
// the output position in layout space reported to clients
int32_t lx, ly;
+ struct wl_listener display_destroy;
+
void *data;
};
diff --git a/types/wlr_output.c b/types/wlr_output.c
index ed74004d..dda63181 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -112,6 +112,12 @@ static void wl_output_bind(struct wl_client *wl_client, void *data,
wl_output_send_to_resource(wl_resource);
}
+static void handle_display_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_output *output =
+ wl_container_of(listener, output, display_destroy);
+ wlr_output_destroy_global(output);
+}
+
struct wl_global *wlr_output_create_global(struct wlr_output *wlr_output,
struct wl_display *display) {
if (wlr_output->wl_global != NULL) {
@@ -120,6 +126,10 @@ struct wl_global *wlr_output_create_global(struct wlr_output *wlr_output,
struct wl_global *wl_global = wl_global_create(display,
&wl_output_interface, 3, wlr_output, wl_output_bind);
wlr_output->wl_global = wl_global;
+
+ wlr_output->display_destroy.notify = handle_display_destroy;
+ wl_display_add_destroy_listener(display, &wlr_output->display_destroy);
+
return wl_global;
}
@@ -127,6 +137,7 @@ void wlr_output_destroy_global(struct wlr_output *wlr_output) {
if (wlr_output->wl_global == NULL) {
return;
}
+ wl_list_remove(&wlr_output->display_destroy.link);
struct wl_resource *resource, *tmp;
wl_resource_for_each_safe(resource, tmp, &wlr_output->wl_resources) {
struct wl_list *link = wl_resource_get_link(resource);