diff options
-rw-r--r-- | include/wlr/xwayland.h | 2 | ||||
-rw-r--r-- | xwayland/xwayland.c | 53 | ||||
-rw-r--r-- | xwayland/xwm.c | 9 |
3 files changed, 39 insertions, 25 deletions
diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h index 455b1026..f6b43851 100644 --- a/include/wlr/xwayland.h +++ b/include/wlr/xwayland.h @@ -23,7 +23,7 @@ struct wlr_xwayland { time_t server_start; struct wl_event_source *sigusr1_source; - struct wl_listener destroy_listener; + struct wl_listener client_destroy; struct wl_listener display_destroy; struct wlr_xwm *xwm; struct wlr_xwayland_cursor *cursor; diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c index 778b959d..a4b79e73 100644 --- a/xwayland/xwayland.c +++ b/xwayland/xwayland.c @@ -125,39 +125,26 @@ static void exec_xwayland(struct wlr_xwayland *wlr_xwayland) { execvp("Xwayland", argv); } -static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland, - struct wl_display *wl_display, struct wlr_compositor *compositor); -static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland); - -static void xwayland_destroy_event(struct wl_listener *listener, void *data) { - struct wlr_xwayland *wlr_xwayland = wl_container_of(listener, wlr_xwayland, destroy_listener); - - /* don't call client destroy */ - wlr_xwayland->client = NULL; - wl_list_remove(&wlr_xwayland->destroy_listener.link); - wlr_xwayland_finish(wlr_xwayland); - - if (time(NULL) - wlr_xwayland->server_start > 5) { - wlr_xwayland_init(wlr_xwayland, wlr_xwayland->wl_display, - wlr_xwayland->compositor); - } -} - static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland) { if (!wlr_xwayland || wlr_xwayland->display == -1) { return; } + if (wlr_xwayland->cursor != NULL) { + free(wlr_xwayland->cursor); + } + + xwm_destroy(wlr_xwayland->xwm); + if (wlr_xwayland->client) { - wl_list_remove(&wlr_xwayland->destroy_listener.link); - wl_client_destroy(wlr_xwayland->client); + wl_list_remove(&wlr_xwayland->client_destroy.link); + // TODO: this segfaults in /usr/lib/libEGL_mesa.so.0 + //wl_client_destroy(wlr_xwayland->client); } if (wlr_xwayland->sigusr1_source) { wl_event_source_remove(wlr_xwayland->sigusr1_source); } - xwm_destroy(wlr_xwayland->xwm); - safe_close(wlr_xwayland->x_fd[0]); safe_close(wlr_xwayland->x_fd[1]); safe_close(wlr_xwayland->wl_fd[0]); @@ -176,6 +163,24 @@ static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland) { */ } +static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland, + struct wl_display *wl_display, struct wlr_compositor *compositor); + +static void handle_client_destroy(struct wl_listener *listener, void *data) { + struct wlr_xwayland *wlr_xwayland = + wl_container_of(listener, wlr_xwayland, client_destroy); + + /* don't call client destroy */ + wlr_xwayland->client = NULL; + wl_list_remove(&wlr_xwayland->client_destroy.link); + wlr_xwayland_finish(wlr_xwayland); + + if (time(NULL) - wlr_xwayland->server_start > 5) { + wlr_xwayland_init(wlr_xwayland, wlr_xwayland->wl_display, + wlr_xwayland->compositor); + } +} + static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_xwayland *wlr_xwayland = wl_container_of(listener, wlr_xwayland, display_destroy); @@ -264,9 +269,9 @@ static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland, wlr_xwayland->wl_fd[0] = -1; /* not ours anymore */ - wlr_xwayland->destroy_listener.notify = xwayland_destroy_event; + wlr_xwayland->client_destroy.notify = handle_client_destroy; wl_client_add_destroy_listener(wlr_xwayland->client, - &wlr_xwayland->destroy_listener); + &wlr_xwayland->client_destroy); struct wl_event_loop *loop = wl_display_get_event_loop(wl_display); wlr_xwayland->sigusr1_source = wl_event_loop_add_signal(loop, SIGUSR1, diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 562f2052..3250a97d 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -1045,6 +1045,12 @@ void xwm_destroy(struct wlr_xwm *xwm) { if (xwm->cursor) { xcb_free_cursor(xwm->xcb_conn, xwm->cursor); } + if (xwm->colormap) { + xcb_free_colormap(xwm->xcb_conn, xwm->colormap); + } + if (xwm->window) { + xcb_destroy_window(xwm->xcb_conn, xwm->window); + } if (xwm->event_source) { wl_event_source_remove(xwm->event_source); } @@ -1052,6 +1058,9 @@ void xwm_destroy(struct wlr_xwm *xwm) { wl_list_for_each_safe(xsurface, tmp, &xwm->surfaces, link) { wlr_xwayland_surface_destroy(xsurface); } + wl_list_for_each_safe(xsurface, tmp, &xwm->unpaired_surfaces, link) { + wlr_xwayland_surface_destroy(xsurface); + } wl_list_remove(&xwm->compositor_surface_create.link); xcb_disconnect(xwm->xcb_conn); |