all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Robert Pluim <rpluim@gmail.com>
Cc: "Eli Zaretskii" <eliz@gnu.org>,
	72254@debbugs.gnu.org, "Sébastien Gendre" <seb@k-7.ch>,
	Visuwesh <visuweshm@gmail.com>
Subject: bug#72254: 29.4; Cannot yank media when image come from Gnome-shell screenshot
Date: Wed, 24 Jul 2024 17:29:54 +0800	[thread overview]
Message-ID: <87wmlbw31p.fsf@yahoo.com> (raw)
In-Reply-To: <87wmlb8djy.fsf@gmail.com> (Robert Pluim's message of "Wed, 24 Jul 2024 09:16:49 +0200")

Robert Pluim <rpluim@gmail.com> writes:

>>>>>> On Tue, 23 Jul 2024 19:16:23 +0200, Sébastien Gendre <seb@k-7.ch> said:
>
>     Sébastien> If I evaluate this `cl-defmethod', and then evaluate (gui-get-selection
>     Sébastien> 'CLIPBOARD 'TARGETS) from an Org-mode buffer after taking an screenshot,
>     Sébastien> I get this error:
>
> My bad. Try this instead:
>
> diff --git a/lisp/term/pgtk-win.el b/lisp/term/pgtk-win.el
> index 505174048f6..06f962ff714 100644
> --- a/lisp/term/pgtk-win.el
> +++ b/lisp/term/pgtk-win.el
> @@ -140,6 +140,14 @@ 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)))
> +    (if (vectorp sel)
> +        sel
> +      (vector sel))))
> +
>  
>  (defvar pgtk-preedit-overlay nil)
>  
>
> Po Lu, is this the right level to fix this? Or should we handle
> 'CLIPBOARD + 'TARGETS specially in `pgtk-get-selection-internal'? (And
> maybe we should add "&optional time_stamp terminal" to the
> `cl-defmethods' in pgtk-win.el)

I would prefer to treat this as a bug in GTK by installing a workaround,
perhaps in the spirit of:

diff --git a/src/pgtkselect.c b/src/pgtkselect.c
index c9f117126b2..0535482b8de 100644
--- a/src/pgtkselect.c
+++ b/src/pgtkselect.c
@@ -1644,10 +1644,24 @@ DEFUN ("pgtk-get-selection-internal", Fpgtk_get_selection_internal,
 
   if (NILP (val) && FRAME_LIVE_P (f))
     {
-      Lisp_Object frame;
+      Lisp_Object frame, val;
       XSETFRAME (frame, f);
-      return pgtk_get_foreign_selection (selection_symbol, target_type,
-					 time_stamp, frame);
+
+      val = pgtk_get_foreign_selection (selection_symbol, target_type,
+					time_stamp, frame);
+
+      /* A window property holding just one item is indistinguishable
+	 from an array of one element, and is always decoded as the
+	 former, producing issues with programs that expect the TARGETS
+	 property always to return vectors, even when the toolkit
+	 reports just one data type.  Though X sidesteps this ambiguity
+	 by defining TARGETS as returning at least two properties
+	 TARGETS and MULTIPLE, GTK knows no such scruples, and therefore
+	 symbol values (or nil) should be enclosed in vectors when
+	 TARGETS is being requested.  (bug#72254) */
+      if (EQ (target_type, QTARGETS) && (NILP (val) || SYMBOLP (val)))
+	val = make_vector (NILP (val) ? 0 : 1, &val);
+      return val;
     }
 
   if (CONSP (val) && SYMBOLP (XCAR (val)))





  reply	other threads:[~2024-07-24  9:29 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-23 10:57 bug#72254: 29.4; Cannot yank media when image come from Gnome-shell screenshot Sébastien Gendre
2024-07-23 11:21 ` Robert Pluim
2024-07-23 11:52   ` Eli Zaretskii
     [not found]   ` <87plr4qpqy.fsf@k-7.ch>
2024-07-23 12:26     ` Robert Pluim
     [not found]       ` <87ed7kqoe4.fsf@k-7.ch>
2024-07-23 12:50         ` Robert Pluim
     [not found]           ` <87ttggp8e0.fsf@k-7.ch>
2024-07-23 13:10             ` Robert Pluim
     [not found]               ` <87le1sp7ts.fsf@k-7.ch>
2024-07-23 14:48                 ` Robert Pluim
2024-07-23 16:34                   ` Visuwesh
     [not found]                     ` <87a5i8oyax.fsf@k-7.ch>
2024-07-23 17:00                       ` Robert Pluim
     [not found]                         ` <87sew058rc.fsf@k-7.ch>
2024-07-24  7:16                           ` Robert Pluim
2024-07-24  9:29                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-07-24 10:50                               ` Robert Pluim
2024-07-24 12:12                                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-24 13:35                                   ` Robert Pluim
2024-07-24 14:11                                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-20 10:12                                       ` Robert Pluim
2024-08-20 12:18                                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-20 13:15                                           ` Eli Zaretskii
2024-08-20 13:20                                             ` Robert Pluim
2024-08-20 13:30                                               ` Eli Zaretskii
2024-08-20 13:59                                                 ` Robert Pluim
2024-08-20 14:01                                                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-20 14:25                                                   ` Eli Zaretskii
2024-08-20 15:17                                                     ` Robert Pluim
2024-08-21  2:37                                                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-21 13:47                                                       ` Eli Zaretskii
2024-08-24 14:03                                                         ` Andrea Corallo
2024-09-12  0:20                                                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]                             ` <87wmlbul4a.fsf@k-7.ch>
2024-07-24 10:55                               ` Robert Pluim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wmlbw31p.fsf@yahoo.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=72254@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=luangruo@yahoo.com \
    --cc=rpluim@gmail.com \
    --cc=seb@k-7.ch \
    --cc=visuweshm@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.