diff options
| author | Jared Finder | 2020-10-03 14:46:30 -0700 |
|---|---|---|
| committer | Eli Zaretskii | 2020-10-24 13:14:27 +0300 |
| commit | 0695c9e8599b5036a80361571e7cb0ea9fdead99 (patch) | |
| tree | f6ab30dcdde06d309367f4ae5fbe8688da62dde5 /src | |
| parent | 9d230684ff16e105db168ebaafdbea2de2e7d6ca (diff) | |
| download | emacs-0695c9e8599b5036a80361571e7cb0ea9fdead99.tar.gz emacs-0695c9e8599b5036a80361571e7cb0ea9fdead99.zip | |
Make TTY menus work with xterm-mouse-mode
* src/term.c (mouse_get_xy): Call 'mouse_position' passing it the
value of 'tty-menu-calls-mouse-position-function' as the
argument.
(syms_of_term) <tty-menu-calls-mouse-position-function>: New
DEFVAR_BOOL.
* src/frame.c (mouse_position): New function, with most of the
code from Fmouse_position, but call 'mouse-position-function' only
if called with non-zero argument.
(Fmouse_position): Call 'mouse_position' to do the job.
* lisp/xt-mouse.el (xterm-mouse-translate-1): Respect
'track-mouse'.
(xterm-mouse-mode): Set 'tty-menu-calls-mouse-position-function'
when setting 'mouse-position-function'.
(xterm-mouse-tracking-enable-sequence): Use SET_ANY_EVENT_MOUSE
(0x1003) so that mouse movement can be reported even if no buttons
are pressed. Doc fix.
* lisp/menu-bar.el (menu-bar-define-mouse-key): New function.
(tty-menu-navigation-map): Call it.
* doc/lispref/frames.texi (Mouse Position): Document
'tty-menu-calls-mouse-position-function'.
* etc/NEWS: Announce 'tty-menu-calls-mouse-position-function'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/frame.c | 8 | ||||
| -rw-r--r-- | src/frame.h | 1 | ||||
| -rw-r--r-- | src/term.c | 26 |
3 files changed, 24 insertions, 11 deletions
diff --git a/src/frame.c b/src/frame.c index 0b707c2af87..5d967a59ce3 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -2434,6 +2434,12 @@ passing the normal return value to that function as an argument, | |||
| 2434 | and returns whatever that function returns. */) | 2434 | and returns whatever that function returns. */) |
| 2435 | (void) | 2435 | (void) |
| 2436 | { | 2436 | { |
| 2437 | return mouse_position (true); | ||
| 2438 | } | ||
| 2439 | |||
| 2440 | Lisp_Object | ||
| 2441 | mouse_position (bool call_mouse_position_function) | ||
| 2442 | { | ||
| 2437 | struct frame *f; | 2443 | struct frame *f; |
| 2438 | Lisp_Object lispy_dummy; | 2444 | Lisp_Object lispy_dummy; |
| 2439 | Lisp_Object x, y, retval; | 2445 | Lisp_Object x, y, retval; |
| @@ -2462,7 +2468,7 @@ and returns whatever that function returns. */) | |||
| 2462 | } | 2468 | } |
| 2463 | XSETFRAME (lispy_dummy, f); | 2469 | XSETFRAME (lispy_dummy, f); |
| 2464 | retval = Fcons (lispy_dummy, Fcons (x, y)); | 2470 | retval = Fcons (lispy_dummy, Fcons (x, y)); |
| 2465 | if (!NILP (Vmouse_position_function)) | 2471 | if (call_mouse_position_function && !NILP (Vmouse_position_function)) |
| 2466 | retval = call1 (Vmouse_position_function, retval); | 2472 | retval = call1 (Vmouse_position_function, retval); |
| 2467 | return retval; | 2473 | return retval; |
| 2468 | } | 2474 | } |
diff --git a/src/frame.h b/src/frame.h index 476bac67faf..16ecfd311c3 100644 --- a/src/frame.h +++ b/src/frame.h | |||
| @@ -1361,6 +1361,7 @@ extern bool frame_inhibit_resize (struct frame *, bool, Lisp_Object); | |||
| 1361 | extern void adjust_frame_size (struct frame *, int, int, int, bool, Lisp_Object); | 1361 | extern void adjust_frame_size (struct frame *, int, int, int, bool, Lisp_Object); |
| 1362 | extern void frame_size_history_add (struct frame *f, Lisp_Object fun_symbol, | 1362 | extern void frame_size_history_add (struct frame *f, Lisp_Object fun_symbol, |
| 1363 | int width, int height, Lisp_Object rest); | 1363 | int width, int height, Lisp_Object rest); |
| 1364 | extern Lisp_Object mouse_position (bool); | ||
| 1364 | 1365 | ||
| 1365 | extern Lisp_Object Vframe_list; | 1366 | extern Lisp_Object Vframe_list; |
| 1366 | 1367 | ||
diff --git a/src/term.c b/src/term.c index 53a1016183b..ff1aabfed23 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -2804,16 +2804,15 @@ tty_menu_calc_size (tty_menu *menu, int *width, int *height) | |||
| 2804 | static void | 2804 | static void |
| 2805 | mouse_get_xy (int *x, int *y) | 2805 | mouse_get_xy (int *x, int *y) |
| 2806 | { | 2806 | { |
| 2807 | struct frame *sf = SELECTED_FRAME (); | 2807 | Lisp_Object lmx = Qnil, lmy = Qnil; |
| 2808 | Lisp_Object lmx = Qnil, lmy = Qnil, lisp_dummy; | 2808 | Lisp_Object mouse = mouse_position (tty_menu_calls_mouse_position_function); |
| 2809 | enum scroll_bar_part part_dummy; | 2809 | |
| 2810 | Time time_dummy; | 2810 | if (EQ (selected_frame, XCAR (mouse))) |
| 2811 | 2811 | { | |
| 2812 | if (FRAME_TERMINAL (sf)->mouse_position_hook) | 2812 | lmx = XCAR (XCDR (mouse)); |
| 2813 | (*FRAME_TERMINAL (sf)->mouse_position_hook) (&sf, -1, | 2813 | lmy = XCDR (XCDR (mouse)); |
| 2814 | &lisp_dummy, &part_dummy, | 2814 | } |
| 2815 | &lmx, &lmy, | 2815 | |
| 2816 | &time_dummy); | ||
| 2817 | if (!NILP (lmx)) | 2816 | if (!NILP (lmx)) |
| 2818 | { | 2817 | { |
| 2819 | *x = XFIXNUM (lmx); | 2818 | *x = XFIXNUM (lmx); |
| @@ -4554,6 +4553,13 @@ What means \"very visible\" is up to your terminal. It may make the cursor | |||
| 4554 | bigger, or it may make it blink, or it may do nothing at all. */); | 4553 | bigger, or it may make it blink, or it may do nothing at all. */); |
| 4555 | visible_cursor = 1; | 4554 | visible_cursor = 1; |
| 4556 | 4555 | ||
| 4556 | DEFVAR_BOOL ("tty-menu-calls-mouse-position-function", | ||
| 4557 | tty_menu_calls_mouse_position_function, | ||
| 4558 | doc: /* Non-nil means TTY menu code will call `mouse-position-function'. | ||
| 4559 | This should be set if the function in `mouse-position-function' does not | ||
| 4560 | trigger redisplay. */); | ||
| 4561 | tty_menu_calls_mouse_position_function = 0; | ||
| 4562 | |||
| 4557 | defsubr (&Stty_display_color_p); | 4563 | defsubr (&Stty_display_color_p); |
| 4558 | defsubr (&Stty_display_color_cells); | 4564 | defsubr (&Stty_display_color_cells); |
| 4559 | defsubr (&Stty_no_underline); | 4565 | defsubr (&Stty_no_underline); |