From 42ede97016e82c86460b2a20cadeb4e8e6ebea7a Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 29 Dec 2021 13:13:15 +0800 Subject: [PATCH] Use XI2 to handle xwidget button events * src/xterm.c (handle_one_xevent): Handle xwidget views when handling XI_ButtonPress or XI_ButtonRelease events. * src/xwidget.c (x_draw_xwidget_glyph_string): Add appropriate values to the XI2 event mask. --- src/xterm.c | 22 ++++++++++++++++++++++ src/xwidget.c | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/xterm.c b/src/xterm.c index 3fdf214c3da..3200e44a872 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -10325,6 +10325,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, bool tab_bar_p = false; bool tool_bar_p = false; struct xi_device_t *device; +#ifdef HAVE_XWIDGETS + struct xwidget_view *xvw; +#endif #ifdef XIPointerEmulated /* Ignore emulated scroll events when XI2 native @@ -10340,6 +10343,25 @@ handle_one_xevent (struct x_display_info *dpyinfo, } #endif +#ifdef HAVE_XWIDGETS + xvw = xwidget_view_from_window (xev->event); + if (xvw) + { + xwidget_button (xvw, xev->evtype == XI_ButtonPress, + lrint (xev->event_x), lrint (xev->event_y), + xev->detail, xev->mods.effective, xev->time); + + if (!EQ (selected_window, xvw->w) && (xev->detail < 4)) + { + inev.ie.kind = SELECT_WINDOW_EVENT; + inev.ie.frame_or_window = xvw->w; + } + + *finish = X_EVENT_DROP; + goto XI_OTHER; + } +#endif + device = xi_device_from_id (dpyinfo, xev->deviceid); if (!device || !device->master_p) diff --git a/src/xwidget.c b/src/xwidget.c index 57451535485..22c42382bbf 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -2106,6 +2106,8 @@ x_draw_xwidget_glyph_string (struct glyph_string *s) mask.deviceid = XIAllMasterDevices; XISetMask (m, XI_Motion); + XISetMask (m, XI_ButtonPress); + XISetMask (m, XI_ButtonRelease); XISelectEvents (xv->dpy, xv->wdesc, &mask, 1); } #endif -- 2.39.2