From 995fb60fdeec169ef284798c9fa024c056cca6ba Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Thu, 1 Dec 2022 15:38:24 -0600 Subject: [PATCH] xwm: Propagate selection ownership immediately If we don't xcb_flush() when we set the selection owner, we end up with a ridiculous corner case where we can run use a command line X client like 'xclip -i -selection clipboard' to crash weston. Start weston, ensure Xwayland is running (set a selection with xclip), set the clipboard from a wayland client, then set the clipboard with xclip again. Since xclip doesn't do anything xwm notices except set the clipboard, it won't provoke a flush on our selection ownership change. xclip will take ownership, then we call xcb_convert_selection(), and THEN we flush, sending out our pending ownership change and the xcb_convert_selection() request. The ownership change takes place first, we attempt to get our own selection and weston explodes in a mess. Stop this from happening with a flush when changing selection ownership. Signed-off-by: Derek Foreman (cherry picked from commit 11bcad116f5cc1eb76c2de83d8c39af0cdb71a81) --- xwayland/selection.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xwayland/selection.c b/xwayland/selection.c index e12d2acf..6476c0d4 100644 --- a/xwayland/selection.c +++ b/xwayland/selection.c @@ -720,6 +720,8 @@ weston_wm_set_selection(struct wl_listener *listener, void *data) wm->selection_window, wm->atom.clipboard, XCB_TIME_CURRENT_TIME); + + xcb_flush(wm->conn); } void