From 257559d890d294cbbc1c036ec9a1855d81d0db8b Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 13 Dec 2017 21:48:59 +0100 Subject: [PATCH] Remove output instead of terminating display when a wayland backend view closed --- backend/wayland/output.c | 5 ++++- backend/wayland/wl_seat.c | 5 ++++- types/wlr_output.c | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/wayland/output.c b/backend/wayland/output.c index f940299e..fc09903e 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -154,6 +154,8 @@ static void wlr_wl_output_destroy(struct wlr_output *_output) { wl_signal_emit(&output->backend->backend.events.output_remove, &output->wlr_output); + wl_list_remove(&output->link); + if (output->cursor.buf_size != 0) { assert(output->cursor.data); assert(output->cursor.buffer); @@ -171,6 +173,7 @@ static void wlr_wl_output_destroy(struct wlr_output *_output) { if (output->frame_callback) { wl_callback_destroy(output->frame_callback); } + eglDestroySurface(output->backend->egl.display, output->surface); wl_egl_window_destroy(output->egl_window); zxdg_toplevel_v6_destroy(output->xdg_toplevel); @@ -233,7 +236,7 @@ static void xdg_toplevel_handle_close(void *data, struct zxdg_toplevel_v6 *xdg_t struct wlr_wl_backend_output *output = data; assert(output && output->xdg_toplevel == xdg_toplevel); - wl_display_terminate(output->backend->local_display); + wlr_output_destroy((struct wlr_output *)output); } static struct zxdg_toplevel_v6_listener xdg_toplevel_listener = { diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c index a2da8df5..3c20e6ca 100644 --- a/backend/wayland/wl_seat.c +++ b/backend/wayland/wl_seat.c @@ -21,7 +21,10 @@ static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer, struct wlr_wl_pointer *wlr_wl_pointer = (struct wlr_wl_pointer *)dev->pointer; struct wlr_wl_backend_output *output = wlr_wl_output_for_surface(wlr_wl_dev->backend, surface); - assert(output); + if (!output) { + // GNOME sends a pointer enter when the surface is being destroyed + return; + } wlr_wl_pointer->current_output = output; output->enter_serial = serial; wlr_wl_output_update_cursor(output); diff --git a/types/wlr_output.c b/types/wlr_output.c index a922b6f3..cb604021 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -272,9 +272,9 @@ void wlr_output_destroy(struct wlr_output *output) { struct wlr_output_mode *mode, *tmp_mode; wl_list_for_each_safe(mode, tmp_mode, &output->modes, link) { + wl_list_remove(&mode->link); free(mode); } - wl_list_remove(&output->modes); if (output->impl && output->impl->destroy) { output->impl->destroy(output); } else {