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 <derek.foreman@collabora.com>
(cherry picked from commit 11bcad116f5cc1eb76c2de83d8c39af0cdb71a81)
dev
Derek Foreman 2 years ago committed by Marius Vlad
parent f5fafa05fc
commit 995fb60fde
  1. 2
      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

Loading…
Cancel
Save