From 5414331d07a77d8e72aa44d4dd31f6af09bc161e Mon Sep 17 00:00:00 2001 From: Po Lu Date: Fri, 8 Apr 2022 08:13:49 +0800 Subject: [PATCH] Make device reporting work for tool bar clicks * src/dispextern.h: Update prototyupes. * src/xdisp.c (handle_tool_bar_click): Pass Qt to that function instead. (handle_tool_bar_click_with_device): New function. * src/xterm.c (handle_one_xevent): Pass device to tool bar click logic. --- src/dispextern.h | 2 ++ src/xdisp.c | 13 ++++++++++--- src/xterm.c | 5 +++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/dispextern.h b/src/dispextern.h index b7cfde70339..e9b19a7f135 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3460,6 +3460,8 @@ extern Lisp_Object handle_tab_bar_click (struct frame *, int, int, bool, int); extern void handle_tool_bar_click (struct frame *, int, int, bool, int); +extern void handle_tool_bar_click_with_device (struct frame *, int, int, bool, + int, Lisp_Object); extern void expose_frame (struct frame *, int, int, int, int); extern bool gui_intersect_rectangles (const Emacs_Rectangle *, diff --git a/src/xdisp.c b/src/xdisp.c index d7313081733..bdefd2b0423 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -15114,11 +15114,11 @@ get_tool_bar_item (struct frame *f, int x, int y, struct glyph **glyph, Handle mouse button event on the tool-bar of frame F, at frame-relative coordinates X/Y. DOWN_P is true for a button press, false for button release. MODIFIERS is event modifiers for button - release. */ + release. DEVICE is the device the click came from, or Qt. */ void -handle_tool_bar_click (struct frame *f, int x, int y, bool down_p, - int modifiers) +handle_tool_bar_click_with_device (struct frame *f, int x, int y, bool down_p, + int modifiers, Lisp_Object device) { Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); struct window *w = XWINDOW (f->tool_bar_window); @@ -15175,11 +15175,18 @@ handle_tool_bar_click (struct frame *f, int x, int y, bool down_p, event.frame_or_window = frame; event.arg = key; event.modifiers = modifiers; + event.device = device; kbd_buffer_store_event (&event); f->last_tool_bar_item = -1; } } +void +handle_tool_bar_click (struct frame *f, int x, int y, bool down_p, + int modifiers) +{ + handle_tool_bar_click_with_device (f, x, y, down_p, modifiers, Qt); +} /* Possibly highlight a tool-bar item on frame F when mouse moves to tool-bar window-relative coordinates X/Y. Called from diff --git a/src/xterm.c b/src/xterm.c index 8c6068e6541..9336b9420f6 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -17038,9 +17038,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, tool_bar_p = EQ (window, f->tool_bar_window); if (tool_bar_p && xev->detail < 4) - handle_tool_bar_click + handle_tool_bar_click_with_device (f, x, y, xev->evtype == XI_ButtonPress, - x_x_to_emacs_modifiers (dpyinfo, bv.state)); + x_x_to_emacs_modifiers (dpyinfo, bv.state), + source ? source->name : Qt); } #endif /* !USE_GTK */ -- 2.39.5