diff options
| author | Jared Finder | 2020-10-31 21:25:47 -0800 |
|---|---|---|
| committer | Eli Zaretskii | 2020-11-14 14:31:55 +0200 |
| commit | 91d5edd9d10db30418cb32f5734d496d76ef56f3 (patch) | |
| tree | 3f21bae82386a7b9f976d483ef3b68cf387a9f0f /src | |
| parent | 31f94e4b1c3dc201646ec436d3e2c477f784ed21 (diff) | |
| download | emacs-91d5edd9d10db30418cb32f5734d496d76ef56f3.tar.gz 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')
| -rw-r--r-- | src/dispextern.h | 1 | ||||
| -rw-r--r-- | src/dispnew.c | 48 | ||||
| -rw-r--r-- | src/term.c | 52 |
3 files changed, 63 insertions, 38 deletions
diff --git a/src/dispextern.h b/src/dispextern.h index 848d3bcd20e..da51772b37a 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -3606,6 +3606,7 @@ extern Lisp_Object marginal_area_string (struct window *, enum window_part, | |||
| 3606 | extern void redraw_frame (struct frame *); | 3606 | extern void redraw_frame (struct frame *); |
| 3607 | extern bool update_frame (struct frame *, bool, bool); | 3607 | extern bool update_frame (struct frame *, bool, bool); |
| 3608 | extern void update_frame_with_menu (struct frame *, int, int); | 3608 | extern void update_frame_with_menu (struct frame *, int, int); |
| 3609 | extern int update_mouse_position (struct frame *, int, int); | ||
| 3609 | extern void bitch_at_user (void); | 3610 | extern void bitch_at_user (void); |
| 3610 | extern void adjust_frame_glyphs (struct frame *); | 3611 | extern void adjust_frame_glyphs (struct frame *); |
| 3611 | void free_glyphs (struct frame *); | 3612 | void free_glyphs (struct frame *); |
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) | |||
| 3323 | display_completed = !paused_p; | 3323 | display_completed = !paused_p; |
| 3324 | } | 3324 | } |
| 3325 | 3325 | ||
| 3326 | /* Update the mouse position for a frame F. This handles both | ||
| 3327 | updating the display for mouse-face propreties and updating the | ||
| 3328 | help echo text. | ||
| 3329 | |||
| 3330 | Returns the number of events generated. */ | ||
| 3331 | int | ||
| 3332 | update_mouse_position (struct frame *f, int x, int y) | ||
| 3333 | { | ||
| 3334 | previous_help_echo_string = help_echo_string; | ||
| 3335 | help_echo_string = Qnil; | ||
| 3336 | |||
| 3337 | note_mouse_highlight (f, x, y); | ||
| 3338 | |||
| 3339 | /* If the contents of the global variable help_echo_string | ||
| 3340 | has changed, generate a HELP_EVENT. */ | ||
| 3341 | if (!NILP (help_echo_string) | ||
| 3342 | || !NILP (previous_help_echo_string)) | ||
| 3343 | { | ||
| 3344 | Lisp_Object frame; | ||
| 3345 | XSETFRAME (frame, f); | ||
| 3346 | |||
| 3347 | gen_help_event (help_echo_string, frame, help_echo_window, | ||
| 3348 | help_echo_object, help_echo_pos); | ||
| 3349 | return 1; | ||
| 3350 | } | ||
| 3351 | |||
| 3352 | return 0; | ||
| 3353 | } | ||
| 3354 | |||
| 3355 | DEFUN ("display--update-for-mouse-movement", Fdisplay__update_for_mouse_movement, | ||
| 3356 | Sdisplay__update_for_mouse_movement, 2, 2, 0, | ||
| 3357 | doc: /* Handle mouse movement detected by Lisp code. | ||
| 3358 | |||
| 3359 | This function should be called when Lisp code detects the mouse has | ||
| 3360 | moved, even if `track-mouse' is nil. This handles updates that do not | ||
| 3361 | rely on input events such as updating display for mouse-face | ||
| 3362 | properties or updating the help echo text. */) | ||
| 3363 | (Lisp_Object mouse_x, Lisp_Object mouse_y) | ||
| 3364 | { | ||
| 3365 | CHECK_FIXNUM (mouse_x); | ||
| 3366 | CHECK_FIXNUM (mouse_y); | ||
| 3367 | |||
| 3368 | update_mouse_position (SELECTED_FRAME (), XFIXNUM (mouse_x), | ||
| 3369 | XFIXNUM (mouse_y)); | ||
| 3370 | return Qnil; | ||
| 3371 | } | ||
| 3372 | |||
| 3326 | 3373 | ||
| 3327 | /************************************************************************ | 3374 | /************************************************************************ |
| 3328 | Window-based updates | 3375 | Window-based updates |
| @@ -6494,6 +6541,7 @@ syms_of_display (void) | |||
| 6494 | { | 6541 | { |
| 6495 | defsubr (&Sredraw_frame); | 6542 | defsubr (&Sredraw_frame); |
| 6496 | defsubr (&Sredraw_display); | 6543 | defsubr (&Sredraw_display); |
| 6544 | defsubr (&Sdisplay__update_for_mouse_movement); | ||
| 6497 | defsubr (&Sframe_or_buffer_changed_p); | 6545 | defsubr (&Sframe_or_buffer_changed_p); |
| 6498 | defsubr (&Sopen_termscript); | 6546 | defsubr (&Sopen_termscript); |
| 6499 | defsubr (&Sding); | 6547 | defsubr (&Sding); |
diff --git a/src/term.c b/src/term.c index 3a13da165e5..a0738594bfc 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -2430,22 +2430,6 @@ tty_draw_row_with_mouse_face (struct window *w, struct glyph_row *row, | |||
| 2430 | cursor_to (f, save_y, save_x); | 2430 | cursor_to (f, save_y, save_x); |
| 2431 | } | 2431 | } |
| 2432 | 2432 | ||
| 2433 | static bool | ||
| 2434 | term_mouse_movement (struct frame *frame, Gpm_Event *event) | ||
| 2435 | { | ||
| 2436 | /* Has the mouse moved off the glyph it was on at the last sighting? */ | ||
| 2437 | if (event->x != last_mouse_x || event->y != last_mouse_y) | ||
| 2438 | { | ||
| 2439 | frame->mouse_moved = 1; | ||
| 2440 | note_mouse_highlight (frame, event->x, event->y); | ||
| 2441 | /* Remember which glyph we're now on. */ | ||
| 2442 | last_mouse_x = event->x; | ||
| 2443 | last_mouse_y = event->y; | ||
| 2444 | return 1; | ||
| 2445 | } | ||
| 2446 | return 0; | ||
| 2447 | } | ||
| 2448 | |||
| 2449 | /* Return the current time, as a Time value. Wrap around on overflow. */ | 2433 | /* Return the current time, as a Time value. Wrap around on overflow. */ |
| 2450 | static Time | 2434 | static Time |
| 2451 | current_Time (void) | 2435 | current_Time (void) |
| @@ -2562,30 +2546,22 @@ handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event) | |||
| 2562 | 2546 | ||
| 2563 | if (event->type & (GPM_MOVE | GPM_DRAG)) | 2547 | if (event->type & (GPM_MOVE | GPM_DRAG)) |
| 2564 | { | 2548 | { |
| 2565 | previous_help_echo_string = help_echo_string; | ||
| 2566 | help_echo_string = Qnil; | ||
| 2567 | |||
| 2568 | Gpm_DrawPointer (event->x, event->y, fileno (tty->output)); | 2549 | Gpm_DrawPointer (event->x, event->y, fileno (tty->output)); |
| 2569 | 2550 | ||
| 2570 | if (!term_mouse_movement (f, event)) | 2551 | /* Has the mouse moved off the glyph it was on at the last |
| 2571 | help_echo_string = previous_help_echo_string; | 2552 | sighting? */ |
| 2572 | 2553 | if (event->x != last_mouse_x || event->y != last_mouse_y) | |
| 2573 | /* If the contents of the global variable help_echo_string | 2554 | { |
| 2574 | has changed, generate a HELP_EVENT. */ | 2555 | /* FIXME: These three lines can not be moved into |
| 2575 | if (!NILP (help_echo_string) | 2556 | update_mouse_position unless xterm-mouse gets updated to |
| 2576 | || !NILP (previous_help_echo_string)) | 2557 | generate mouse events via C code. See |
| 2577 | { | 2558 | https://lists.gnu.org/archive/html/emacs-devel/2020-11/msg00163.html */ |
| 2578 | Lisp_Object frame; | 2559 | last_mouse_x = event->x; |
| 2579 | 2560 | last_mouse_y = event->y; | |
| 2580 | if (f) | 2561 | f->mouse_moved = 1; |
| 2581 | XSETFRAME (frame, f); | 2562 | |
| 2582 | else | 2563 | count += update_mouse_position (f, event->x, event->y); |
| 2583 | frame = Qnil; | 2564 | } |
| 2584 | |||
| 2585 | gen_help_event (help_echo_string, frame, help_echo_window, | ||
| 2586 | help_echo_object, help_echo_pos); | ||
| 2587 | count++; | ||
| 2588 | } | ||
| 2589 | } | 2565 | } |
| 2590 | else | 2566 | else |
| 2591 | { | 2567 | { |