From fd3ad3b9e42d9f2d1196a5c36b07763283729053 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Wed, 23 Aug 2017 23:11:44 +0200 Subject: [PATCH] xwayland: fix shutdown caused by Xwayland/client stop --- include/wlr/xwayland.h | 1 + xwayland/xwayland.c | 12 ++++-------- xwayland/xwm.c | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h index 4d1a726d..804e9962 100644 --- a/include/wlr/xwayland.h +++ b/include/wlr/xwayland.h @@ -18,6 +18,7 @@ struct wlr_xwayland { time_t server_start; struct wl_event_source *sigusr1_source; + struct wl_listener destroy_listener; struct wlr_xwm *xwm; struct wl_list displayable_windows; }; diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c index a28073d8..9c0b1839 100644 --- a/xwayland/xwayland.c +++ b/xwayland/xwayland.c @@ -107,8 +107,7 @@ static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland, static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland); static void xwayland_destroy_event(struct wl_listener *listener, void *data) { - struct wl_client *client = data; - struct wlr_xwayland *wlr_xwayland = wl_container_of(client, wlr_xwayland, client); + struct wlr_xwayland *wlr_xwayland = wl_container_of(listener, wlr_xwayland, destroy_listener); /* don't call client destroy */ wlr_xwayland->client = NULL; @@ -120,13 +119,9 @@ static void xwayland_destroy_event(struct wl_listener *listener, void *data) { } } -static struct wl_listener xwayland_destroy_listener = { - .notify = xwayland_destroy_event, -}; - static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland) { if (wlr_xwayland->client) { - wl_list_remove(&xwayland_destroy_listener.link); + wl_list_remove(&wlr_xwayland->destroy_listener.link); wl_client_destroy(wlr_xwayland->client); } @@ -224,7 +219,8 @@ static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland, return false; } - wl_client_add_destroy_listener(wlr_xwayland->client, &xwayland_destroy_listener); + wlr_xwayland->destroy_listener.notify = xwayland_destroy_event; + wl_client_add_destroy_listener(wlr_xwayland->client, &wlr_xwayland->destroy_listener); struct wl_event_loop *loop = wl_display_get_event_loop(wl_display); wlr_xwayland->sigusr1_source = wl_event_loop_add_signal(loop, SIGUSR1, xserver_handle_ready, wlr_xwayland); diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 02794e72..0e161330 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -240,7 +240,7 @@ static void create_surface_handler(struct wl_listener *listener, void *data) { } static void xcb_get_resources(struct wlr_xwm *xwm) { - int i; + size_t i; xcb_intern_atom_cookie_t cookies[ATOM_LAST]; for (i = 0; i < ATOM_LAST; i++) {