From b52462885ae6b1710bc691f179f53a6cc52f55ea Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Fri, 4 Feb 2022 02:46:50 +0000 Subject: [PATCH 2/2] Update the MULTIPLE property with conversion outcomes Per the ICCCM spec: > If the owner fails to convert the target named by an atom in the > MULTIPLE property, it should replace that atom in the property with > None. * src/xselect.c (x_handle_selection_request): Do it. --- src/xselect.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/xselect.c b/src/xselect.c index 8f47aa84cc..c0fd9e322a 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -795,6 +795,7 @@ x_handle_selection_request (struct selection_input_event *event) Window requestor = SELECTION_EVENT_REQUESTOR (event); Lisp_Object multprop; ptrdiff_t j, nselections; + struct selection_data cs; if (property == None) goto DONE; multprop @@ -811,11 +812,19 @@ x_handle_selection_request (struct selection_input_event *event) Lisp_Object subtarget = AREF (multprop, 2*j); Atom subproperty = symbol_to_x_atom (dpyinfo, AREF (multprop, 2*j+1)); + bool subsuccess = false; if (subproperty != None) - x_convert_selection (selection_symbol, subtarget, - subproperty, true, dpyinfo); + subsuccess = x_convert_selection (selection_symbol, subtarget, + subproperty, true, dpyinfo); + if (!subsuccess) + ASET (multprop, 2*j+1, Qnil); } + /* Save conversion results */ + lisp_data_to_selection_data (dpyinfo, multprop, &cs); + XChangeProperty (dpyinfo->display, requestor, property, + cs.type, cs.format, PropModeReplace, + cs.data, cs.size); success = true; } else -- 2.34.1