diff options
author | Po Lu <luangruo@yahoo.com> | 2022-04-30 18:05:44 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-04-30 18:05:44 +0800 |
commit | 5fd54723536efca5589f9b9ac64825e76f0d1360 (patch) | |
tree | c5d34f73f0ae6f24aced74081668f3b62902b1ec | |
parent | 7b7a124afa0a71f4847ddc5a3934b02ab5d46d2c (diff) | |
download | emacs-5fd54723536efca5589f9b9ac64825e76f0d1360.tar.gz emacs-5fd54723536efca5589f9b9ac64825e76f0d1360.tar.bz2 emacs-5fd54723536efca5589f9b9ac64825e76f0d1360.zip |
Avoid server roundtrip on wheel events from scroll bars on XI2
* src/xterm.c (handle_one_xevent): Translate coordinates for
scroll bars correctly when handling XI2 wheel events.
-rw-r--r-- | src/xterm.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/xterm.c b/src/xterm.c index 6d658cf2042..ea86b7f8033 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -16863,6 +16863,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, double delta, scroll_unit; int scroll_height; Lisp_Object window; + struct scroll_bar *bar; + + bar = NULL; /* See the comment on top of x_init_master_valuators for more details on how @@ -16880,9 +16883,8 @@ handle_one_xevent (struct x_display_info *dpyinfo, if (!f) { #if defined USE_MOTIF || !defined USE_TOOLKIT_SCROLL_BARS - struct scroll_bar *bar - = x_window_to_scroll_bar (xi_event->display, - xev->event, 2); + bar = x_window_to_scroll_bar (dpyinfo->display, + xev->event, 2); if (bar) f = WINDOW_XFRAME (XWINDOW (bar->window)); @@ -16899,11 +16901,26 @@ handle_one_xevent (struct x_display_info *dpyinfo, #endif if (FRAME_X_WINDOW (f) != xev->event) - XTranslateCoordinates (dpyinfo->display, - xev->event, FRAME_X_WINDOW (f), - lrint (xev->event_x), - lrint (xev->event_y), - &real_x, &real_y, &dummy); + { + if (!bar) + bar = x_window_to_scroll_bar (dpyinfo->display, xev->event, 2); + + /* If this is a scroll bar, compute the + actual position directly to avoid an + extra roundtrip. */ + + if (bar) + { + real_x = lrint (xev->event_x + bar->left); + real_y = lrint (xev->event_y + bar->top); + } + else + XTranslateCoordinates (dpyinfo->display, + xev->event, FRAME_X_WINDOW (f), + lrint (xev->event_x), + lrint (xev->event_y), + &real_x, &real_y, &dummy); + } else { real_x = lrint (xev->event_x); |