unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#20804: 24.4; XdndDrop does not use time stamp
@ 2015-06-13  8:42 Urs Fleisch
  2019-08-01 21:40 ` Lars Ingebrigtsen
  2020-01-20  7:44 ` Paul Eggert
  0 siblings, 2 replies; 3+ messages in thread
From: Urs Fleisch @ 2015-06-13  8:42 UTC (permalink / raw)
  To: 20804

[-- Attachment #1: Type: text/plain, Size: 8870 bytes --]

Hi,

Drag and drop from Qt 5 applications does not work on Linux (X11). This
can be easily reproduced using the draggabletext example from Qt 5 and
trying to drop a text into Emacs. I have created a bug report for Qt 5,
you can find it at <https://bugreports.qt.io/browse/QTBUG-45812>. To
resume what I reported there:

Emacs receives an XdndDrop message, but the value received by
(x-get-selection-internal 'XdndSelection "text/uri-list") is nil. Qt 5
receives the get selection request in
QXcbDrag::handleSelectionRequest() (in qxcbdrag.cpp) and only returns
the selection if the time stamps match. However, when dropping into
Emacs, the time stamps differ and no matching selection is found.

Of course, Qt 5 should not be so picky about these time stamps and try
to find a matching selection also in the case where the time stamps
differ, e.g. using the IDs of XdndAware windows. I have created a
patch for Qt which fixes this and I hope that it will be handled by the
Qt maintainers. However, I think that also the behavior of Emacs could
be improved. It does not use the time stamp which can be found in the
XdndDrop message when requesting the selection. The XDND specification
<http://www.newplanetsoftware.com/xdnd/> states:

XdndDrop

Sent from source to target to complete the drop.

    data.l[0] contains the XID of the source window.
    data.l[1] is reserved for future use (flags).
    data.l[2] contains the time stamp for retrieving the data. (new in
    version 1)

When passing the value found in data.l[2] as the optional time stamp
argument to x-get-selection-internal, dropping from Qt 5 works with
Emacs. I have attached a patch fixing this.

~~~~
--- x-dnd.el.orig	2015-06-13 09:52:02.999811917 +0200
+++ x-dnd.el	2015-06-13 09:53:30.808247335 +0200
@@ -496,10 +496,12 @@
 	((equal "XdndDrop" message)
 	 (if (windowp window) (select-window window))
 	 (let* ((dnd-source (aref data 0))
+		(timestamp (aref data 2))
 		(value (and (x-dnd-current-type window)
 			    (x-get-selection-internal
 			     'XdndSelection
-			     (intern (x-dnd-current-type window)))))
+			     (intern (x-dnd-current-type window))
+			     timestamp)))
 		success action)
 
 	   (setq action (if value
~~~~

Regards,
Urs Fleisch




In GNU Emacs 24.4.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.9)
 of 2015-03-21 on kissel, modified by Debian
Windowing system distributor `The X.Org Foundation', version
11.0.11701000 System Description:	Ubuntu 15.04

Configured using:
 `configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.4/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.4/site-lisp:/usr/share/emacs/site-lisp
 --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.4/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.4/site-lisp:/usr/share/emacs/site-lisp
 --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars
 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat
 -Werror=format-security -Wall' CPPFLAGS=-D_FORTIFY_SOURCE=2
 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro''

Important settings:
  value of $LC_MONETARY: en_US.UTF-8
  value of $LC_NUMERIC: en_US.UTF-8
  value of $LC_TIME: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  show-paren-mode: t
  delete-selection-mode: t
  recentf-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
- d n <tab> . o r i g <return> <down> <return> C-x 
b i n i <tab> C-g <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <menu-bar> <file> <Open Recent> 
</home/urs/.emacs.d/init.el> <down-mouse-5> <mouse-5> 
<down-mouse-4> <mouse-4> <double-down-mouse-4> <double-mouse-4> 
<triple-down-mouse-4> <triple-mouse-4> <triple-down-mouse-4> 
<triple-mouse-4> <triple-down-mouse-4> <triple-mouse-4> 
<triple-down-mouse-4> <triple-mouse-4> <down-mouse-5> 
<mouse-5> <double-down-mouse-5> <double-mouse-5> <down-mouse-1> 
<mouse-1> C-a C-SPC <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> M-w C-x b <return> C-s - h a n d l e - x d n 
d C-s C-a C-y C-SPC <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <delete> 
<up> C-x C-s M-x e d i f f - b u f f <tab> <return> 
<return> C-g M-x <up> <return> x <tab> . <tab> o <tab> 
<tab> <tab> C-g C-x C-f x d <tab> <backspace> - d <tab> 
. o <tab> <return> M-x <up> <return> <return> <return> 
n n n q y <switch-frame> <down-mouse-1> <mouse-1> <help-echo> 
<help-echo> <down-mouse-1> <mouse-1> C-x 1 M-x r e 
p o r t - e m <tab> <return>

Recent messages:
Saving file /home/urs/xdnd/emacs/x-dnd.el...
Wrote /home/urs/xdnd/emacs/x-dnd.el
Quit [2 times]
Computing differences between x-dnd.el.orig and x-dnd.el ...
Buffer A: Processing difference region 0 of 2
Buffer B: Processing difference region 0 of 2
Processing difference regions ... done
Region 1 in buffer A is empty [2 times]
Refining difference region 2 ...
Quit this Ediff session? (y or n) y

Load-path shadows:
~/.emacs.d/vendor/python-mode/python-mode
hides /usr/share/emacs24/site-lisp/python-mode/python-mode
~/.emacs.d/vendor/pymacs-0.25/pymacs
hides /usr/share/emacs24/site-lisp/pymacs/pymacs /usr/share/emacs24/site-lisp/cmake-data/cmake-mode
hides /usr/share/emacs/site-lisp/cmake-mode /usr/share/emacs/24.4/site-lisp/debian-startup
hides /usr/share/emacs/site-lisp/debian-startup /usr/share/emacs24/site-lisp/dictionaries-common/flyspell
hides /usr/share/emacs/24.4/lisp/textmodes/flyspell /usr/share/emacs24/site-lisp/dictionaries-common/ispell
hides /usr/share/emacs/24.4/lisp/textmodes/ispell

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils ediff-merg ediff-wind ediff-diff ediff-mult
ediff-help ediff-init ediff-util ediff misearch multi-isearch dired-aux
dired browse-url saveplace paren grep compile comint ansi-color ring
cus-start cus-load pymacs advice help-fns delsel recentf tree-widget
wid-edit cl-loaddefs cl-lib easymenu server 50magit time-date tooltip
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
lisp-mode prog-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind gfilenotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 120917 9552)
 (symbols 48 22357 0)
 (miscs 40 78 250)
 (strings 32 21584 8579)
 (string-bytes 1 718116)
 (vectors 16 19152)
 (vector-slots 8 1185919 183954)
 (floats 8 80 323)
 (intervals 56 1352 0)
 (buffers 960 18)
 (heap 1024 39074 1259))

[-- Attachment #2: xdnd.patch --]
[-- Type: text/x-patch, Size: 536 bytes --]

--- x-dnd.el.orig	2015-06-13 09:52:02.999811917 +0200
+++ x-dnd.el	2015-06-13 09:53:30.808247335 +0200
@@ -496,10 +496,12 @@
 	((equal "XdndDrop" message)
 	 (if (windowp window) (select-window window))
 	 (let* ((dnd-source (aref data 0))
+		(timestamp (aref data 2))
 		(value (and (x-dnd-current-type window)
 			    (x-get-selection-internal
 			     'XdndSelection
-			     (intern (x-dnd-current-type window)))))
+			     (intern (x-dnd-current-type window))
+			     timestamp)))
 		success action)
 
 	   (setq action (if value

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#20804: 24.4; XdndDrop does not use time stamp
  2015-06-13  8:42 bug#20804: 24.4; XdndDrop does not use time stamp Urs Fleisch
@ 2019-08-01 21:40 ` Lars Ingebrigtsen
  2020-01-20  7:44 ` Paul Eggert
  1 sibling, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2019-08-01 21:40 UTC (permalink / raw)
  To: Urs Fleisch; +Cc: 20804

Urs Fleisch <urs.fleisch@gmail.com> writes:

[...]

> However, I think that also the behavior of Emacs could
> be improved. It does not use the time stamp which can be found in the
> XdndDrop message when requesting the selection. The XDND specification
> <http://www.newplanetsoftware.com/xdnd/> states:
>
> XdndDrop
>
> Sent from source to target to complete the drop.
>
>     data.l[0] contains the XID of the source window.
>     data.l[1] is reserved for future use (flags).
>     data.l[2] contains the time stamp for retrieving the data. (new in
>     version 1)
>
> When passing the value found in data.l[2] as the optional time stamp
> argument to x-get-selection-internal, dropping from Qt 5 works with
> Emacs. I have attached a patch fixing this.
>
> ~~~~
> --- x-dnd.el.orig	2015-06-13 09:52:02.999811917 +0200
> +++ x-dnd.el	2015-06-13 09:53:30.808247335 +0200
> @@ -496,10 +496,12 @@
>  	((equal "XdndDrop" message)
>  	 (if (windowp window) (select-window window))
>  	 (let* ((dnd-source (aref data 0))
> +		(timestamp (aref data 2))
>  		(value (and (x-dnd-current-type window)
>  			    (x-get-selection-internal
>  			     'XdndSelection
> -			     (intern (x-dnd-current-type window)))))
> +			     (intern (x-dnd-current-type window))
> +			     timestamp)))
>  		success action)

(I'm going through old bug reports that have unfortunately not gotten
any responses.)

I'm not really familiar with how drag and drop works, but I think this
sounds like it makes sense.  Does anybody else with more knowledge (than
me) about this area think so too?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#20804: 24.4; XdndDrop does not use time stamp
  2015-06-13  8:42 bug#20804: 24.4; XdndDrop does not use time stamp Urs Fleisch
  2019-08-01 21:40 ` Lars Ingebrigtsen
@ 2020-01-20  7:44 ` Paul Eggert
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Eggert @ 2020-01-20  7:44 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 20804-done, Urs Fleisch

> I'm not really familiar with how drag and drop works, but I think this
> sounds like it makes sense.

Looks OK to me too, not that I know much about DnD either. I installed the patch 
into Emacs master and am closing the bug report.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-20  7:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-13  8:42 bug#20804: 24.4; XdndDrop does not use time stamp Urs Fleisch
2019-08-01 21:40 ` Lars Ingebrigtsen
2020-01-20  7:44 ` Paul Eggert

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).