diff options
author | Po Lu <luangruo@yahoo.com> | 2022-04-04 13:10:01 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-04-04 13:10:01 +0800 |
commit | aea799838b7ffd11f187c2511ecca250c8b99411 (patch) | |
tree | b0bff026f01c9e04480bd732016c2e510e5e3315 /lisp/mouse.el | |
parent | 9ff2f0be32be621a0a1953cac2d552afebafe226 (diff) | |
download | emacs-aea799838b7ffd11f187c2511ecca250c8b99411.tar.gz |
Improve behavior of dragging text to windows on top of frames
* doc/lispref/frames.texi (Drag and Drop): Document new meaning
of `return-frame' in `x-begin-drag'.
* lisp/mouse.el (mouse-drag-and-drop-region): Use `now' when
calling `x-begin-drag'.
* src/xfns.c (Fx_begin_drag): Update doc string.
* src/xterm.c (x_dnd_begin_drag_and_drop): Accept return_frame
as a Lisp_Object and handle Qnow correctly.
(XTmouse_position): Ignore tooltip frames when processing
`drag-source'.
(syms_of_xterm): New defsym `now'.
* src/xterm.h: Update prototypes.
Diffstat (limited to 'lisp/mouse.el')
-rw-r--r-- | lisp/mouse.el | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el index f42492bb5d3..26a17365da2 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -3061,7 +3061,8 @@ is copied instead of being cut." value-selection ; This remains nil when event was "click". text-tooltip states - window-exempt) + window-exempt + drag-again-mouse-position) ;; STATES stores for each window on this frame its start and point ;; positions so we can restore them on all windows but for the one @@ -3171,7 +3172,14 @@ is copied instead of being cut." (frame-pixel-width frame)) (> (cdr location) (frame-pixel-height frame))))) - (not (posn-window (event-end event))))) + (and (or (not drag-again-mouse-position) + (let ((mouse-position (mouse-absolute-pixel-position))) + (or (< 5 (abs (- (car drag-again-mouse-position) + (car mouse-position)))) + (< 5 (abs (- (cdr drag-again-mouse-position) + (cdr mouse-position))))))) + (not (posn-window (event-end event)))))) + (setq drag-again-mouse-position nil) (mouse-drag-and-drop-region-hide-tooltip) (gui-set-selection 'XdndSelection value-selection) (let ((drag-action-or-frame @@ -3182,9 +3190,18 @@ is copied instead of being cut." (if mouse-drag-and-drop-region-cut-when-buffers-differ 'XdndActionMove 'XdndActionCopy) - (posn-window (event-end event)) t) + (posn-window (event-end event)) 'now) (quit nil)))) (when (framep drag-action-or-frame) + ;; With some window managers `x-begin-drag' + ;; returns a frame sooner than `mouse-position' + ;; will return one, due to over-wide frame windows + ;; being drawn by the window manager. To avoid + ;; that, we just require the mouse move a few + ;; pixels before beginning another cross-program + ;; drag. + (setq drag-again-mouse-position + (mouse-absolute-pixel-position)) (throw 'drag-again nil)) (let ((min-char (point))) |