unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* mouse-face and help echo support for xterm mouse
@ 2020-11-01  5:46 Jared Finder via Emacs development discussions.
  2020-11-01 13:39 ` Stefan Monnier
  0 siblings, 1 reply; 24+ messages in thread
From: Jared Finder via Emacs development discussions. @ 2020-11-01  5:46 UTC (permalink / raw)
  To: emacs-devel

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

Attached is a patch that makes the xterm-mouse properly support 
mouse-face and help echo text.  It simply adds a new function to call 
from Lisp that does what the existing event handlers 
(handle_one_term_event for GPM, w32_read_socket for Windows, etc.) when 
they notice mouse movement.

I think with this the xterm-mouse is now at parity with other terminal 
mouse support.  Yay!

   -- MJF

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Face-changing-text-properties-and-help-echo-now-work.patch --]
[-- Type: text/x-diff; name=0001-Face-changing-text-properties-and-help-echo-now-work.patch, Size: 3296 bytes --]

From b7eb78397bc96c0e1bc2d280bd6660bbaa779790 Mon Sep 17 00:00:00 2001
From: Jared Finder <jared@finder.org>
Date: Sat, 31 Oct 2020 21:25:47 -0800
Subject: [PATCH] Face-changing text properties and help-echo now work with
 xterm-mouse.

* src/term.c (handle-lisp-mouse-motion): New function like
handle_one_term_event but only for mouse motion and with no GPM code.
* lisp/xt-mouse.el (xterm-mouse--handle-mouse-motion): New function that
calls 'handle-lisp-mouse-motion'.
(xterm-mouse-translate-1): Call 'xterm-mouse--handle-mouse-motion'.
---
 lisp/xt-mouse.el |  9 +++++++++
 src/term.c       | 28 ++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index f9c08f9a17..37550276f8 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -77,6 +77,7 @@ xterm-mouse-translate-1
               (copy-sequence event))
 	vec)
        (is-move
+        (xterm-mouse--handle-mouse-motion)
         (if track-mouse vec
           ;; Mouse movement events are currently supposed to be
           ;; suppressed.  Return no event.
@@ -106,8 +107,16 @@ xterm-mouse-translate-1
 	      (if (null track-mouse)
 		  (vector drag)
 		(push drag unread-command-events)
+                (xterm-mouse--handle-mouse-motion)
 		(vector (list 'mouse-movement ev-data))))))))))))
 
+(defun xterm-mouse--handle-mouse-motion ()
+  "Handle mouse motion that was just generated for XTerm mouse."
+  (let ((frame (selected-frame)))
+    (handle-lisp-mouse-motion frame
+                              (terminal-parameter frame 'xterm-mouse-x)
+                              (terminal-parameter frame 'xterm-mouse-y))))
+
 ;; These two variables have been converted to terminal parameters.
 ;;
 ;;(defvar xterm-mouse-x 0
diff --git a/src/term.c b/src/term.c
index ff1aabfed2..710b00e32f 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2617,6 +2617,33 @@ handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event,
   return count;
 }
 
+DEFUN ("handle-lisp-mouse-motion", Fhandle_lisp_mouse_motion,
+       Shandle_lisp_mouse_motion, 3, 3, 0,
+       doc: /* Handle mouse motion detected by Lisp code.
+
+This function should be called when Lisp code detects the mouse has
+moved, even if `track-mouse' is nil.  This handles updates that do not
+not rely on input events such as updating display for mouse-face
+proprties or updating the help echo text.  */)
+  (Lisp_Object frame, Lisp_Object mouse_x, Lisp_Object mouse_y)
+{
+  if (NILP (frame))
+    frame = selected_frame;
+
+  previous_help_echo_string = help_echo_string;
+  help_echo_string = Qnil;
+
+  note_mouse_highlight(XFRAME(frame), XFIXNUM (mouse_x), XFIXNUM (mouse_y));
+
+  if (!NILP (help_echo_string)
+      || !NILP (previous_help_echo_string))
+    {
+      gen_help_event (help_echo_string, frame, help_echo_window,
+                      help_echo_object, help_echo_pos);
+    }
+  return Qnil;
+}
+
 DEFUN ("gpm-mouse-start", Fgpm_mouse_start, Sgpm_mouse_start,
        0, 0, 0,
        doc: /* Open a connection to Gpm.
@@ -4568,6 +4595,7 @@ syms_of_term (void)
   defsubr (&Stty_top_frame);
   defsubr (&Ssuspend_tty);
   defsubr (&Sresume_tty);
+  defsubr (&Shandle_lisp_mouse_motion);
 #ifdef HAVE_GPM
   defsubr (&Sgpm_mouse_start);
   defsubr (&Sgpm_mouse_stop);
-- 
2.20.1


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

end of thread, other threads:[~2020-11-14 12:38 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-01  5:46 mouse-face and help echo support for xterm mouse Jared Finder via Emacs development discussions.
2020-11-01 13:39 ` Stefan Monnier
2020-11-01 15:56   ` Jared Finder via Emacs development discussions.
2020-11-04  6:54     ` Jared Finder via Emacs development discussions.
2020-11-04 14:13       ` Stefan Monnier
2020-11-04 15:46         ` Eli Zaretskii
2020-11-04 15:56           ` Stefan Monnier
2020-11-04 17:54             ` Jared Finder via Emacs development discussions.
2020-11-04 18:47               ` Stefan Monnier
2020-11-04 18:51                 ` Eli Zaretskii
2020-11-04 19:05                   ` Stefan Monnier
2020-11-04 19:10                     ` Jared Finder via Emacs development discussions.
2020-11-04 15:19       ` Eli Zaretskii
2020-11-05  8:15   ` Jared Finder via Emacs development discussions.
2020-11-05 14:45     ` Stefan Monnier
2020-11-05 19:58       ` Jared Finder via Emacs development discussions.
2020-11-05 20:18         ` Stefan Monnier
2020-11-06  5:23           ` Jared Finder via Emacs development discussions.
2020-11-06  6:00             ` Eli Zaretskii
2020-11-06  6:46               ` Jared Finder via Emacs development discussions.
2020-11-06  7:39                 ` Eli Zaretskii
2020-11-07  1:22                   ` Jared Finder via Emacs development discussions.
2020-11-14 12:38                     ` Eli Zaretskii
2020-11-14 12:35                 ` Eli Zaretskii

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).