Subject: bug#72254: 29.4; Cannot yank media when image come from Gnome-shell screenshot

From: Robert Pluim <[email-masked]>
Date: Tue, 23 Jul 2024 19:00:34 +0200

>>>>> On Tue, 23 Jul 2024 18:41:58 +0200, Sébastien Gendre <[email-masked]> said:

    Sébastien> Yes, the Emacs version in Fedora repo is PGTK. And I use Wayland.

Ah, that would have been good to know from the beginning.

    Sébastien> But if I copy an image to clipboard from Firefox, I can past it into an
    Sébastien> org-mode buffer with `yank-media`.

Try this `cl-defmethod' instead.

diff --git a/lisp/term/pgtk-win.el b/lisp/term/pgtk-win.el
index 505174048f6..d0dbf11cc48 100644
--- a/lisp/term/pgtk-win.el
+++ b/lisp/term/pgtk-win.el
@@ -140,6 +140,15 @@ gui-backend-get-selection
                                          &context (window-system pgtk))
   (pgtk-get-selection-internal selection-symbol target-type))
 
+(cl-defmethod gui-backend-get-selection ((selection-symbol (eql 'CLIPBOARD))
+                                         (target-type (eql 'TARGETS))
+                                         &context (window-system pgtk))
+  (let ((sel (pgtk-get-selection-internal selection-symbol target-type
+                                          time-stamp terminal)))
+    (if (vectorp sel)
+        sel
+      (vector sel))))
+
 
 (defvar pgtk-preedit-overlay nil)

Robert
--