From 7f074fecf4516031699f443f8a88f925a73d1147 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sun, 16 Jan 2022 10:43:22 +0000 Subject: [PATCH] Make help event generation on Haiku behave closer to X * src/haikuterm.c (haiku_read_socket): Generate help events more like how X does it. --- src/haikuterm.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/haikuterm.c b/src/haikuterm.c index 7380420e531..05f9788f184 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -55,6 +55,8 @@ struct unhandled_event uint8_t buffer[200]; }; +static bool any_help_event_p = false; + char * get_keysym_name (int keysym) { @@ -2594,6 +2596,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) struct unhandled_event *unhandled_events = NULL; int button_or_motion_p; int need_flush = 0; + int do_help = 0; if (!buf) buf = xmalloc (200); @@ -2774,8 +2777,9 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) } haiku_new_focus_frame (x_display_list->focused_frame); - help_echo_string = Qnil; - gen_help_event (Qnil, frame, Qnil, Qnil, 0); + + if (any_help_event_p) + do_help = -1; } else { @@ -2820,9 +2824,9 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) remember_mouse_glyph (f, b->x, b->y, &FRAME_DISPLAY_INFO (f)->last_mouse_glyph); dpyinfo->last_mouse_glyph_frame = f; - gen_help_event (help_echo_string, frame, help_echo_window, - help_echo_object, help_echo_pos); } + else + help_echo_string = previous_help_echo_string; if (!NILP (Vmouse_autoselect_window)) { @@ -2842,6 +2846,10 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) last_mouse_window = window; } + + if (!NILP (help_echo_string) + || !NILP (previous_help_echo_string)) + do_help = 1; } break; } @@ -3293,6 +3301,28 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) xfree (old); } + if (do_help && !(hold_quit && hold_quit->kind != NO_EVENT)) + { + Lisp_Object help_frame = Qnil; + + if (x_display_list->last_mouse_frame) + XSETFRAME (help_frame, + x_display_list->last_mouse_frame); + + if (do_help > 0) + { + any_help_event_p = true; + gen_help_event (help_echo_string, help_frame, + help_echo_window, help_echo_object, + help_echo_pos); + } + else + { + help_echo_string = Qnil; + gen_help_event (Qnil, help_frame, Qnil, Qnil, 0); + } + } + if (need_flush) flush_dirty_back_buffers (); -- 2.39.2