From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#72254: 29.4; Cannot yank media when image come from Gnome-shell screenshot Date: Wed, 24 Jul 2024 17:29:54 +0800 Message-ID: <87wmlbw31p.fsf@yahoo.com> References: <87y15sqstb.fsf@k-7.ch> <87wmlc9wvz.fsf@gmail.com> <87plr4qpqy.fsf@k-7.ch> <87o76o9tvl.fsf@gmail.com> <87ed7kqoe4.fsf@k-7.ch> <87ed7k9srp.fsf@gmail.com> <87ttggp8e0.fsf@k-7.ch> <87a5i89run.fsf@gmail.com> <87le1sp7ts.fsf@k-7.ch> <875xsw9nac.fsf@gmail.com> <87ikww3w4s.fsf@gmail.com> <87a5i8oyax.fsf@k-7.ch> <871q3k9h71.fsf@gmail.com> <87sew058rc.fsf@k-7.ch> <87wmlb8djy.fsf@gmail.com> Reply-To: Po Lu Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31053"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , 72254@debbugs.gnu.org, =?UTF-8?Q?S=C3=A9bastien?= Gendre , Visuwesh To: Robert Pluim Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 24 11:31:31 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sWYLL-0007v5-J8 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Jul 2024 11:31:31 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWYKq-0007WO-Tn; Wed, 24 Jul 2024 05:31:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sWYKn-0007W5-QO for bug-gnu-emacs@gnu.org; Wed, 24 Jul 2024 05:30:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sWYKn-0006Tj-8v for bug-gnu-emacs@gnu.org; Wed, 24 Jul 2024 05:30:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sWYKr-00043G-S7 for bug-gnu-emacs@gnu.org; Wed, 24 Jul 2024 05:31:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Jul 2024 09:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72254 X-GNU-PR-Package: emacs Original-Received: via spool by 72254-submit@debbugs.gnu.org id=B72254.172181343015533 (code B ref 72254); Wed, 24 Jul 2024 09:31:01 +0000 Original-Received: (at 72254) by debbugs.gnu.org; 24 Jul 2024 09:30:30 +0000 Original-Received: from localhost ([127.0.0.1]:33143 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sWYKL-00042S-Nv for submit@debbugs.gnu.org; Wed, 24 Jul 2024 05:30:30 -0400 Original-Received: from sonic308-56.consmr.mail.ne1.yahoo.com ([66.163.187.31]:40498) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sWYKH-00042D-P1 for 72254@debbugs.gnu.org; Wed, 24 Jul 2024 05:30:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1721813414; bh=hcO+AOWB+j2OUeypew4u++e0FhXzfLkdaQ4h7lPckO8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=ePLczj1kD3bYS0hCROWVTR/GG6NFX2sI2Hwa2/K69lgHu7t+18jCrXm/g5n+MDMVxJXIiOGzbplDE3BUILjsSbSjojT0PX/hQQ+FLLPY2QdJ3uzROrICGw8iREWJZde29w8dJjDvEjVESAjij8Tu8/oHShId4LjcfFSQRLGt8C0oAv4JJcVByY9melKwiyAK4/w7A0TwxhM7CFMuIyrXMgz2EWngNo0PaOHAHXJuwmgVdOgjtAMDw3RLhriBL4opPu+l5nC5CkWDL7oACg3otpPSL1lwK6q0sYdU1H5eTB+c3iMkcfbgGsn6m5em3M/9Lx+xjG+FKDTWKXKQXogRhQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1721813414; bh=xxllf6haLeFyILWRVNmXw1VsAWm8zx83HH7AAXrv01Z=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=B/dxLA8BMYGKztpoisburYTEgBSIE8oA0wrmD4YAE9vMgcJ7dOBwyIsrhXJm7YcqECeMk9zbpn7wmAfW9t4HAD7C+fiOb7Fkwwg7+PL1E/sEUDu9IMCOq5nr2u7KFCj4z9VNq3fgXLv0Ok/rWJ0tBpXidUE9cev9MVApjOgHUEizJF/z5RCoFO/rO73xK3XSK9wb/6A0xERMJ3QvXHYJ1FoPC3CuFj3o5k0npzIEpZDh+WUOodIP9LLm0JSqrtXHafumv2tUhIQpvgjUdR1qqGUOTvtCmiR1dDMujRAwjEX/wp1xUlS5wQo0VxpWlhUxQKLZBQiFRLL5ETPsZTA7fA== X-YMail-OSG: MYc8Sb8VM1kZg2bsJV8c1D3kjBXTVKfULEGwTkXuVqybEaPansCEGbaUXTeZmK5 tzqimGpvB7MKbJ__2PXpxNdTqoeMkf38Dk7xgSnuPNNfaiUINeLaMcuqBJVabPVPy3wW5zCE5DTy j_GKdFX0gt5rgOn1Tf76YKxiibgrqqed7vXlQirjq9__oKFDV6VSn_S84nRBtXVA8J9Yk.lx131H 68Qzs3rUKzY9Y6sMT9Fr7Jq6cDk3PQfQK0EXJrnXQH0YnK2kyMMRsYvvTaa_ABJls6oKynzA4UF4 fI6xPeNqNRja4bm_KlutygGt5NFU47V6qsrCQD5sbcIAhl50EcUPjZH9hgMYODzE.vzg6yu_7HRG lldXzS2u8Ew6zSi.HuS1oHzYjr0nOjfzOaA5XzNHBvWqUdT.ivGslkFpmb_294l97ov4OZB0wQ6n 5r5kZtDdXuOIkA0BLvUdpnfo_Gm0Pijio3N4YCBRHviJRjAi45Duwsx1TvcmTTg8kmZlJjMm5.e7 frR132pjCgBQciCGLWuMROFK4PsobierifM0ixqtDUeyDYAI2_aiexm6Jj69SFyZyTRV_SMOkU30 DD9u16n45C8BiRApjM_3Qg0CCmjCoN7ZVIhq58cQ8XfVAnBu4jUTjfuX.WX1oT6ycq96zlFW1NBU GA1z94R_VrcRQDH9bymOT2HRDEL0a8OiBFM5JN4IJvI_9tzA3F5eQyBugZnRNYsZPYs92IxA5wnf v0q7uj96OMKHXljSUmSUISXbLlGwbN56EtLgm7jKvoFxEYrzZxBkm5Gp70cSp9zhAZ1HsMVrRFAZ PJvZW8EcBiqAqeHtbZRZxO6uWXqnh1jGXCFndxnJE4 X-Sonic-MF: X-Sonic-ID: 451e230f-e8e7-42e2-86a1-dcb8d2602ede Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.ne1.yahoo.com with HTTP; Wed, 24 Jul 2024 09:30:14 +0000 Original-Received: by hermes--production-sg3-85fdb5cfc8-8z4tk (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID ee7855d1599540c4db654440b1e0a870; Wed, 24 Jul 2024 09:30:12 +0000 (UTC) In-Reply-To: <87wmlb8djy.fsf@gmail.com> (Robert Pluim's message of "Wed, 24 Jul 2024 09:16:49 +0200") X-Mailer: WebService/1.1.22501 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:289206 Archived-At: Robert Pluim writes: >>>>>> On Tue, 23 Jul 2024 19:16:23 +0200, S=C3=A9bastien Gendre said: > > S=C3=A9bastien> If I evaluate this `cl-defmethod', and then evaluate = (gui-get-selection > S=C3=A9bastien> 'CLIPBOARD 'TARGETS) from an Org-mode buffer after ta= king an screenshot, > S=C3=A9bastien> 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)) >=20=20 > +(cl-defmethod gui-backend-get-selection ((selection-symbol (eql 'CLIPBOA= RD)) > + (target-type (eql 'TARGETS)) > + &context (window-system pgtk)) > + (let ((sel (pgtk-get-selection-internal selection-symbol target-type))) > + (if (vectorp sel) > + sel > + (vector sel)))) > + >=20=20 > (defvar pgtk-preedit-overlay nil) >=20=20 > > 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_sel= ection_internal, =20 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 =3D 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 =3D make_vector (NILP (val) ? 0 : 1, &val); + return val; } =20 if (CONSP (val) && SYMBOLP (XCAR (val)))