xwm: Don't crash when setting selection with no seat

It's possible to set the clipboard with no seat present - one way is to
use the RDP backend and then run 'xclip -i -selection clipboard' locally
without making an RDP connection.

Check if seat is NULL to prevent this from crashing.

Fixes #698

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2022-12-01 15:30:40 -06:00 committed by Marius Vlad
parent a04fd99212
commit bb993df236

View File

@ -199,6 +199,9 @@ weston_wm_get_selection_targets(struct weston_wm *wm)
char *logstr; char *logstr;
size_t logsize; size_t logsize;
if (!seat)
return;
cookie = xcb_get_property(wm->conn, cookie = xcb_get_property(wm->conn,
1, /* delete */ 1, /* delete */
wm->selection_window, wm->selection_window,
@ -631,6 +634,9 @@ weston_wm_handle_xfixes_selection_notify(struct weston_wm *wm,
xfixes_selection_notify->owner); xfixes_selection_notify->owner);
if (xfixes_selection_notify->owner == XCB_WINDOW_NONE) { if (xfixes_selection_notify->owner == XCB_WINDOW_NONE) {
if (!seat)
return 1;
if (wm->selection_owner != wm->selection_window) { if (wm->selection_owner != wm->selection_window) {
/* A real X client selection went away, not our /* A real X client selection went away, not our
* proxy selection. Clear the wayland selection. */ * proxy selection. Clear the wayland selection. */