emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 47dcf72dec: Fix tooltip text properties showing up in dragged tex


From: Po Lu
Subject: master 47dcf72dec: Fix tooltip text properties showing up in dragged text
Date: Wed, 16 Mar 2022 03:20:22 -0400 (EDT)

branch: master
commit 47dcf72dec63b4b4b9cc3b8444bbbfcb85e31d3e
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix tooltip text properties showing up in dragged text
    
    * lisp/mouse.el (mouse-drag-and-drop-region): Directly call
    x-show-tip and x-hide-tip instead of going through tooltip-show.
---
 lisp/mouse.el | 36 ++++++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/lisp/mouse.el b/lisp/mouse.el
index b650bea1bd..4eead39925 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -3097,12 +3097,28 @@ is copied instead of being cut."
                                   (frame-pixel-width frame))
                                (> (cdr location)
                                   (frame-pixel-height frame)))))
-                (tooltip-hide)
+                (x-hide-tip)
                 (gui-set-selection 'XdndSelection value-selection)
-                (when (framep
-                       (x-begin-drag '("UTF8_STRING" "STRING") 'XdndActionCopy
-                                     (posn-window (event-end event)) t))
-                  (throw 'drag-again nil))
+                (let ((drag-action-or-frame
+                       (x-begin-drag '("UTF8_STRING" "STRING")
+                                     (if 
mouse-drag-and-drop-region-cut-when-buffers-differ
+                                         'XdndActionMove
+                                       'XdndActionCopy)
+                                     (posn-window (event-end event)) t)))
+                  (when (framep drag-action-or-frame)
+                    (throw 'drag-again nil))
+
+                  (when (eq drag-action-or-frame 'XdndActionMove)
+                    ;; Remove the dragged text from source buffer like
+                    ;; operation `cut'.
+                    (dolist (overlay mouse-drag-and-drop-overlays)
+                      (delete-region (overlay-start overlay)
+                                     (overlay-end overlay))))
+
+                  (when (eq drag-action-or-frame 'XdndActionCopy)
+                    ;; Set back the dragged text as region on source buffer
+                    ;; like operation `copy'.
+                    (activate-mark)))
                 (throw 'cross-program-drag nil))
 
               (setq window-to-paste (posn-window (event-end event)))
@@ -3161,8 +3177,12 @@ is copied instead of being cut."
 
               ;; Show a tooltip.
               (if mouse-drag-and-drop-region-show-tooltip
-                  (tooltip-show text-tooltip)
-                (tooltip-hide))
+                  ;; Don't use tooltip-show since it has side effects
+                  ;; which change the text properties, and
+                  ;; `text-tooltip' can potentially be the text which
+                  ;; will be pasted.
+                  (x-show-tip text-tooltip)
+                (x-hide-tip))
 
               ;; Show cursor and highlight the original region.
               (when mouse-drag-and-drop-region-show-cursor
@@ -3183,7 +3203,7 @@ is copied instead of being cut."
                   (mouse-set-point event)))))))
 
       ;; Hide a tooltip.
-      (when mouse-drag-and-drop-region-show-tooltip (tooltip-hide))
+      (when mouse-drag-and-drop-region-show-tooltip (x-hide-tip))
 
       ;; Check if modifier was pressed on drop.
       (setq no-modifier-on-drop



reply via email to

[Prev in Thread] Current Thread [Next in Thread]