diff options
author | Jared Finder <jared@finder.org> | 2020-10-31 21:25:47 -0800 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2020-11-14 14:31:55 +0200 |
commit | 91d5edd9d10db30418cb32f5734d496d76ef56f3 (patch) | |
tree | 3f21bae82386a7b9f976d483ef3b68cf387a9f0f /src/dispnew.c | |
parent | 31f94e4b1c3dc201646ec436d3e2c477f784ed21 (diff) | |
download | emacs-91d5edd9d10db30418cb32f5734d496d76ef56f3.tar.gz emacs-91d5edd9d10db30418cb32f5734d496d76ef56f3.tar.bz2 emacs-91d5edd9d10db30418cb32f5734d496d76ef56f3.zip |
Face-changing text properties and help-echo now work with xterm-mouse.
* src/dispnew.c (update_mouse_position): New function for mouse
movement logic in 'handle_one_term_event' that can be shared across
different mouse backends.
(display--update-for-mouse-movement): New lisp function, call it.
* lisp/xt-mouse.el (xterm-mouse--handle-mouse-movement): New function
that calls 'display--update-for-mouse-movement'.
(xterm-mouse-translate-1): Call it.
* src/term.c (handle_one_term_event): Inline logic from
'term_mouse_movement' and call 'update_mouse_position'.
(term_mouse_movement): Delete.
Diffstat (limited to 'src/dispnew.c')
-rw-r--r-- | src/dispnew.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/dispnew.c b/src/dispnew.c index 48a36f2006c..479fccb45e0 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -3323,6 +3323,53 @@ update_frame_with_menu (struct frame *f, int row, int col) display_completed = !paused_p; } +/* Update the mouse position for a frame F. This handles both + updating the display for mouse-face propreties and updating the + help echo text. + + Returns the number of events generated. */ +int +update_mouse_position (struct frame *f, int x, int y) +{ + previous_help_echo_string = help_echo_string; + help_echo_string = Qnil; + + note_mouse_highlight (f, x, y); + + /* If the contents of the global variable help_echo_string + has changed, generate a HELP_EVENT. */ + if (!NILP (help_echo_string) + || !NILP (previous_help_echo_string)) + { + Lisp_Object frame; + XSETFRAME (frame, f); + + gen_help_event (help_echo_string, frame, help_echo_window, + help_echo_object, help_echo_pos); + return 1; + } + + return 0; +} + +DEFUN ("display--update-for-mouse-movement", Fdisplay__update_for_mouse_movement, + Sdisplay__update_for_mouse_movement, 2, 2, 0, + doc: /* Handle mouse movement 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 +rely on input events such as updating display for mouse-face +properties or updating the help echo text. */) + (Lisp_Object mouse_x, Lisp_Object mouse_y) +{ + CHECK_FIXNUM (mouse_x); + CHECK_FIXNUM (mouse_y); + + update_mouse_position (SELECTED_FRAME (), XFIXNUM (mouse_x), + XFIXNUM (mouse_y)); + return Qnil; +} + /************************************************************************ Window-based updates @@ -6494,6 +6541,7 @@ syms_of_display (void) { defsubr (&Sredraw_frame); defsubr (&Sredraw_display); + defsubr (&Sdisplay__update_for_mouse_movement); defsubr (&Sframe_or_buffer_changed_p); defsubr (&Sopen_termscript); defsubr (&Sding); |