From d90be279958c093c4d3023ef553ea20508cf4c28 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sat, 11 Dec 2021 18:30:01 +0800 Subject: [PATCH] Use window height to determine wheel event pixel deltas on XInput 2 * src/xterm.c (handle_one_xevent): Use window height instead of frame height to determine the height of a scroll unit. --- src/xterm.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/xterm.c b/src/xterm.c index 41aa2b268c1..f2129458e16 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -9990,6 +9990,8 @@ handle_one_xevent (struct x_display_info *dpyinfo, { struct xi_scroll_valuator_t *val; double delta, scroll_unit; + int scroll_height; + Lisp_Object window; /* See the comment on top of @@ -10056,7 +10058,19 @@ handle_one_xevent (struct x_display_info *dpyinfo, xev->mods.effective); } - scroll_unit = pow (FRAME_PIXEL_HEIGHT (f), 2.0 / 3.0); + window = window_from_coordinates (f, xev->event_x, + xev->event_y, NULL, + false, false); + + if (WINDOWP (window)) + scroll_height = XWINDOW (window)->pixel_height; + else + /* EVENT_X and EVENT_Y can be outside the + frame if F holds the input grab, so fall + back to the height of the frame instead. */ + scroll_height = FRAME_PIXEL_HEIGHT (f); + + scroll_unit = pow (scroll_height, 2.0 / 3.0); if (NUMBERP (Vx_scroll_event_delta_factor)) scroll_unit *= XFLOATINT (Vx_scroll_event_delta_factor); -- 2.39.5