From dad9543c510ac9075533a7de9e8b315bd17b3b9c Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Fri, 29 Dec 2017 15:56:26 +0100 Subject: Xwayland: remove xwm from selection seat listeners on destroy --- xwayland/xwm.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'xwayland/xwm.c') diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 849acff8..0b9ffac2 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -1114,6 +1114,10 @@ void xwm_destroy(struct wlr_xwm *xwm) { wl_list_for_each_safe(xsurface, tmp, &xwm->unpaired_surfaces, link) { wlr_xwayland_surface_destroy(xsurface); } + if (xwm->seat) { + wl_list_remove(&xwm->seat_selection.link); + wl_list_remove(&xwm->seat_primary_selection.link); + } wl_list_remove(&xwm->compositor_surface_create.link); xcb_disconnect(xwm->xcb_conn); -- cgit v1.2.3 From f8a346380c8d22a11c5acf72b74e35a6dca4f5a2 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Fri, 29 Dec 2017 15:56:39 +0100 Subject: xwayland xwm_get_render_format: free reply --- xwayland/xwm.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'xwayland/xwm.c') diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 0b9ffac2..facc5566 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -1274,10 +1274,12 @@ static void xwm_get_render_format(struct wlr_xwm *xwm) { if (format == NULL) { wlr_log(L_DEBUG, "No 32 bit render format"); + free(reply); return; } xwm->render_format_id = format->id; + free(reply); } void xwm_set_cursor(struct wlr_xwm *xwm, const uint8_t *pixels, uint32_t stride, -- cgit v1.2.3 From bb0d888f2500290693232704c2a477cf321cdec6 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Fri, 29 Dec 2017 16:30:59 +0100 Subject: xwayland selection: further cleanup on Xwayland exit This is necessary if our last primary/clipboard selection was on Xwayland, and we try to paste to native wayland after Xwayland died --- include/wlr/xwm.h | 1 + xwayland/selection.c | 24 ++++++++++++++++++++++++ xwayland/xwm.c | 8 +------- 3 files changed, 26 insertions(+), 7 deletions(-) (limited to 'xwayland/xwm.c') diff --git a/include/wlr/xwm.h b/include/wlr/xwm.h index cbc2f132..35c43b18 100644 --- a/include/wlr/xwm.h +++ b/include/wlr/xwm.h @@ -108,6 +108,7 @@ void xwm_set_cursor(struct wlr_xwm *xwm, const uint8_t *pixels, uint32_t stride, int xwm_handle_selection_event(struct wlr_xwm *xwm, xcb_generic_event_t *event); void xwm_selection_init(struct wlr_xwm *xwm); +void xwm_selection_finish(struct wlr_xwm *xwm); void xwm_set_seat(struct wlr_xwm *xwm, struct wlr_seat *seat); diff --git a/xwayland/selection.c b/xwayland/selection.c index 00e45182..79819565 100644 --- a/xwayland/selection.c +++ b/xwayland/selection.c @@ -826,6 +826,30 @@ void xwm_selection_init(struct wlr_xwm *xwm) { selection_init(xwm, &xwm->primary_selection, xwm->atoms[PRIMARY]); } +void xwm_selection_finish(struct wlr_xwm *xwm) { + if (!xwm) { + return; + } + if (xwm->selection_window) { + xcb_destroy_window(xwm->xcb_conn, xwm->selection_window); + } + if (xwm->seat) { + if (xwm->seat->selection_source && + xwm->seat->selection_source->cancel == data_source_cancel) { + wlr_seat_set_selection(xwm->seat, NULL, + wl_display_next_serial(xwm->xwayland->wl_display)); + } + if (xwm->seat->primary_selection_source && + xwm->seat->primary_selection_source->cancel == primary_selection_source_cancel) { + wlr_seat_set_primary_selection(xwm->seat, NULL, + wl_display_next_serial(xwm->xwayland->wl_display)); + } + wl_list_remove(&xwm->seat_selection.link); + wl_list_remove(&xwm->seat_primary_selection.link); + } + +} + static void xwm_selection_set_owner(struct wlr_xwm_selection *selection, bool set) { if (set) { diff --git a/xwayland/xwm.c b/xwayland/xwm.c index facc5566..5b710b85 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -1092,9 +1092,7 @@ void xwm_destroy(struct wlr_xwm *xwm) { if (!xwm) { return; } - if (xwm->selection_window) { - xcb_destroy_window(xwm->xcb_conn, xwm->selection_window); - } + xwm_selection_finish(xwm); if (xwm->cursor) { xcb_free_cursor(xwm->xcb_conn, xwm->cursor); } @@ -1114,10 +1112,6 @@ void xwm_destroy(struct wlr_xwm *xwm) { wl_list_for_each_safe(xsurface, tmp, &xwm->unpaired_surfaces, link) { wlr_xwayland_surface_destroy(xsurface); } - if (xwm->seat) { - wl_list_remove(&xwm->seat_selection.link); - wl_list_remove(&xwm->seat_primary_selection.link); - } wl_list_remove(&xwm->compositor_surface_create.link); xcb_disconnect(xwm->xcb_conn); -- cgit v1.2.3 From a6fb4b007b4cd1abb406acb57efc041fba3d78f7 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Fri, 29 Dec 2017 20:31:04 +0100 Subject: xwm_get_render_format: check NULL return value --- xwayland/xwm.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'xwayland/xwm.c') diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 5b710b85..470c4e63 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -1254,6 +1254,10 @@ static void xwm_get_render_format(struct wlr_xwm *xwm) { xcb_render_query_pict_formats(xwm->xcb_conn); xcb_render_query_pict_formats_reply_t *reply = xcb_render_query_pict_formats_reply(xwm->xcb_conn, cookie, NULL); + if (!reply) { + wlr_log(L_ERROR, "Did not get any reply from xcb_rrender_query_pict_formats"); + return; + } xcb_render_pictforminfo_iterator_t iter = xcb_render_query_pict_formats_formats_iterator(reply); xcb_render_pictforminfo_t *format = NULL; -- cgit v1.2.3 From 6ed1884c84f470707ed5e6b56a92d86b51034625 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Fri, 29 Dec 2017 21:23:55 +0100 Subject: xwm_get_render_format: fix typo in error message --- xwayland/xwm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xwayland/xwm.c') diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 470c4e63..53aac6a4 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -1255,7 +1255,7 @@ static void xwm_get_render_format(struct wlr_xwm *xwm) { xcb_render_query_pict_formats_reply_t *reply = xcb_render_query_pict_formats_reply(xwm->xcb_conn, cookie, NULL); if (!reply) { - wlr_log(L_ERROR, "Did not get any reply from xcb_rrender_query_pict_formats"); + wlr_log(L_ERROR, "Did not get any reply from xcb_render_query_pict_formats"); return; } xcb_render_pictforminfo_iterator_t iter = -- cgit v1.2.3