From 2b8bb05383ea1589027786795c9efaba4c718cce Mon Sep 17 00:00:00 2001 From: Po Lu Date: Fri, 25 Feb 2022 11:36:07 +0000 Subject: [PATCH] Improve treatment of dropping mouse track state on Haiku * src/haikuterm.c (haiku_mouse_or_wdesc_frame): New function. (haiku_read_socket): Use it to find the appropriate frame when handling motion or button events. --- src/haikuterm.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/haikuterm.c b/src/haikuterm.c index 023349327a4..5e2259e49a8 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -393,6 +393,29 @@ haiku_frame_raise_lower (struct frame *f, bool raise_p) } } +static struct frame * +haiku_mouse_or_wdesc_frame (void *window) +{ + struct frame *lm_f = (gui_mouse_grabbed (x_display_list) + ? x_display_list->last_mouse_frame + : NULL); + + if (lm_f && !EQ (track_mouse, Qdropping)) + return lm_f; + else + { + struct frame *w_f = haiku_window_to_frame (window); + + /* Do not return a tooltip frame. */ + if (!w_f || FRAME_TOOLTIP_P (w_f)) + return EQ (track_mouse, Qdropping) ? lm_f : NULL; + else + /* When dropping it would be probably nice to raise w_f + here. */ + return w_f; + } +} + /* Unfortunately, NOACTIVATE is not implementable on Haiku. */ static void haiku_focus_frame (struct frame *frame, bool noactivate) @@ -2777,7 +2800,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) case MOUSE_MOTION: { struct haiku_mouse_motion_event *b = buf; - struct frame *f = haiku_window_to_frame (b->window); + struct frame *f = haiku_mouse_or_wdesc_frame (b->window); Mouse_HLInfo *hlinfo = &x_display_list->mouse_highlight; if (!f) @@ -2936,7 +2959,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) case BUTTON_DOWN: { struct haiku_button_event *b = buf; - struct frame *f = haiku_window_to_frame (b->window); + struct frame *f = haiku_mouse_or_wdesc_frame (b->window); Lisp_Object tab_bar_arg = Qnil; int tab_bar_p = 0, tool_bar_p = 0; bool up_okay_p = false; -- 2.39.5