emacs-diffs
[Top][All Lists]
Advanced

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

master 13762d24b8: Display drag-and-drop messages in echo area on non-gr


From: Po Lu
Subject: master 13762d24b8: Display drag-and-drop messages in echo area on non-graphics displays
Date: Thu, 17 Mar 2022 03:14:11 -0400 (EDT)

branch: master
commit 13762d24b88a370f349d308c48b28b94bcbbad18
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Display drag-and-drop messages in echo area on non-graphics displays
    
    * lisp/mouse.el (mouse-drag-and-drop-region-display-tooltip)
    (mouse-drag-and-drop-region-hide-tooltip): New functions.
    (mouse-drag-and-drop-region): Use them instead of calling
    `x-hide-tip' and `x-show-tip' directly.
---
 lisp/mouse.el | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/lisp/mouse.el b/lisp/mouse.el
index 3e7ae24697..93c89de91c 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -2991,6 +2991,21 @@ highlight the original region when
 (declare-function rectangle-intersect-p "rect" (pos1 size1 pos2 size2))
 (declare-function x-begin-drag "xfns.c")
 
+(defun mouse-drag-and-drop-region-display-tooltip (tooltip)
+  "Display TOOLTIP, a tooltip string, using `x-show-tip'.
+Call `tooltip-show-help-non-mode' instead on non-graphical displays."
+  (if (display-graphic-p)
+      (x-show-tip tooltip)
+    (tooltip-show-help-non-mode tooltip)))
+
+(defun mouse-drag-and-drop-region-hide-tooltip ()
+  "Hide any tooltip currently displayed.
+Call `tooltip-show-help-non-mode' to clear the echo area message
+instead on non-graphical displays."
+  (if (display-graphic-p)
+      (x-hide-tip)
+    (tooltip-show-help-non-mode nil)))
+
 (defun mouse-drag-and-drop-region (event)
   "Move text in the region to point where mouse is dragged to.
 The transportation of text is also referred as `drag and drop'.
@@ -3087,6 +3102,7 @@ is copied instead of being cut."
                                 (throw 'loop t)))))))
 
               (when (and mouse-drag-and-drop-region-cross-program
+                         (display-graphic-p)
                          (fboundp 'x-begin-drag)
                          (framep (posn-window (event-end event)))
                          (let ((location (posn-x-y (event-end event)))
@@ -3097,7 +3113,7 @@ is copied instead of being cut."
                                   (frame-pixel-width frame))
                                (> (cdr location)
                                   (frame-pixel-height frame)))))
-                (x-hide-tip)
+                (mouse-drag-and-drop-region-hide-tooltip)
                 (gui-set-selection 'XdndSelection value-selection)
                 (let ((drag-action-or-frame
                        (x-begin-drag '("UTF8_STRING" "text/plain"
@@ -3183,8 +3199,8 @@ is copied instead of being cut."
                   ;; 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))
+                  (mouse-drag-and-drop-region-display-tooltip text-tooltip)
+                (mouse-drag-and-drop-region-hide-tooltip))
 
               ;; Show cursor and highlight the original region.
               (when mouse-drag-and-drop-region-show-cursor



reply via email to

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