From b305f5a3ab96f828bb8b41a702758314b924139c Mon Sep 17 00:00:00 2001 From: Po Lu Date: Fri, 4 Mar 2022 14:16:15 +0800 Subject: [PATCH] Correctly process legacy XI wheel events on top of scroll bars * src/xterm.c (handle_one_xevent): Handle XI button events generated by scroll wheels on top of scroll bars. --- src/xterm.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/xterm.c b/src/xterm.c index b9a4328c292..2c6289a9cb1 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -12236,6 +12236,48 @@ handle_one_xevent (struct x_display_info *dpyinfo, } #ifdef USE_GTK + if (!f) + { + int real_x = lrint (xev->event_x); + int real_y = lrint (xev->event_y); + Window child; + + f = x_any_window_to_frame (dpyinfo, xev->event); + + if (xev->detail > 3 && xev->detail < 9 && f) + { + if (xev->evtype == XI_ButtonRelease) + { + if (FRAME_X_WINDOW (f) != xev->event) + XTranslateCoordinates (dpyinfo->display, xev->event, + FRAME_X_WINDOW (f), real_x, + real_y, &real_x, &real_y, &child); + + if (xev->detail <= 5) + inev.ie.kind = WHEEL_EVENT; + else + inev.ie.kind = HORIZ_WHEEL_EVENT; + + inev.ie.timestamp = xev->time; + + XSETINT (inev.ie.x, real_x); + XSETINT (inev.ie.y, real_y); + XSETFRAME (inev.ie.frame_or_window, f); + + inev.ie.modifiers + |= x_x_to_emacs_modifiers (dpyinfo, + xev->mods.effective); + + inev.ie.modifiers |= xev->detail % 2 ? down_modifier : up_modifier; + } + + *finish = X_EVENT_DROP; + goto XI_OTHER; + } + else + f = NULL; + } + if (f && xg_event_is_for_scrollbar (f, event, false)) f = 0; #endif -- 2.39.5