wlroots-hyprland/xwayland
Tudor Brindus 2fa257313a xwayland/selection: use one target window per selection
Previously, the clipboard and primary selections shared the same window.
This was racey, and could have led to pasting failures.

On xfixes selection owner change notification, the logic for requesting
the supported mimetypes of the new owner's selection looks like:

  xcb_convert_selection(
    xwm->xcb_conn,
    selection->window,
    selection->atom,
    xwm->atoms[TARGETS],
    xwm->atoms[WL_SELECTION],
    selection->timestamp
  );

This means ask the selection owner to write its TARGETS for the
`selection->atom` selection (one of PRIMARY, CLIPBOARD, DND_SELECTION)
to `selection->window`'s WL_SELECTION atom.

However, `selection->window` is shared for both PRIMARY and CLIPBOARD
selections, and WL_SELECTION is used as the target atom in both cases.
So, there's a race when both selections change at the same time.

The CLIPBOARD selection might support mimetypes {A, B, C}, and the
PRIMARY only {A, B}. If the ConvertSelection requests/responses "cross
on the wire", so to speak, wlroots can end up believing that the PRIMARY
selection also supports C.

A Wayland client may then ask for the PRIMARY selection in C format,
which will fail with "convert selection failed".

This commit fixes this by using a separate window for PRIMARY and
CLIPBOARD target requests, so that WL_SELECTION can be used as the
target atom in both cases.
2021-02-04 17:06:14 +01:00
..
selection xwayland/selection: use one target window per selection 2021-02-04 17:06:14 +01:00
meson.build xwayland: split server 2020-05-19 22:07:47 +02:00
server.c xwayland: avoid crash on repeated server_finish_display() call 2020-12-19 10:39:31 +01:00
sockets.c meson: enable more compiler warnings 2019-03-01 09:20:23 +01:00
sockets.h xwayland: remove remaining SOCK_CLOEXEC 2019-02-20 17:04:00 +01:00
xwayland.c Free xwayland cursor in wlr_xwayland_destroy 2021-01-17 12:28:55 +01:00
xwm.c xwayland/selection: use one target window per selection 2021-02-04 17:06:14 +01:00