]> git.eshelyaron.com Git - emacs.git/commitdiff
Update the MULTIPLE property with conversion outcomes
authorVladimir Panteleev <git@cy.md>
Fri, 4 Feb 2022 02:46:50 +0000 (02:46 +0000)
committerPo Lu <luangruo@yahoo.com>
Sat, 5 Feb 2022 01:07:14 +0000 (09:07 +0800)
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

index 537be2ddd54367db7d78586734a2e6d506a35538..f2a64dd953410a76b5a876c52fb766024c5cf9c9 100644 (file)
@@ -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