diff options
| author | Po Lu | 2021-12-08 14:18:09 +0800 |
|---|---|---|
| committer | Po Lu | 2021-12-08 14:18:09 +0800 |
| commit | 41b1d223c6ab7bca1b626a4c07a4f2dda2855feb (patch) | |
| tree | c353ea66d42402e91da18fb78a55c4e455c4cba0 | |
| parent | bdeb189cf202f9661f783aebd4852b401858958b (diff) | |
| parent | bf79dad3f20345ddf095325ce22c0f2a3408d3ba (diff) | |
| download | emacs-41b1d223c6ab7bca1b626a4c07a4f2dda2855feb.tar.gz emacs-41b1d223c6ab7bca1b626a4c07a4f2dda2855feb.zip | |
Merge remote-tracking branch 'origin/master' into feature/pgtk
| -rw-r--r-- | lisp/pixel-scroll.el | 48 | ||||
| -rw-r--r-- | src/xterm.c | 9 | ||||
| -rw-r--r-- | src/xwidget.c | 7 | ||||
| -rw-r--r-- | src/xwidget.h | 2 |
4 files changed, 42 insertions, 24 deletions
diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el index 2e09f9af2d4..6191c0530c4 100644 --- a/lisp/pixel-scroll.el +++ b/lisp/pixel-scroll.el | |||
| @@ -141,6 +141,18 @@ Nil means to not interpolate such scrolls." | |||
| 141 | number) | 141 | number) |
| 142 | :version "29.1") | 142 | :version "29.1") |
| 143 | 143 | ||
| 144 | (defcustom pixel-scroll-precision-interpolation-total-time 0.01 | ||
| 145 | "The total time in seconds to spend interpolating a large scroll." | ||
| 146 | :group 'mouse | ||
| 147 | :type 'float | ||
| 148 | :version 29.1) | ||
| 149 | |||
| 150 | (defcustom pixel-scroll-precision-interpolation-factor 2.0 | ||
| 151 | "A factor to apply to the distance of an interpolated scroll." | ||
| 152 | :group 'mouse | ||
| 153 | :type 'float | ||
| 154 | :version 29.1) | ||
| 155 | |||
| 144 | (defun pixel-scroll-in-rush-p () | 156 | (defun pixel-scroll-in-rush-p () |
| 145 | "Return non-nil if next scroll should be non-smooth. | 157 | "Return non-nil if next scroll should be non-smooth. |
| 146 | When scrolling request is delivered soon after the previous one, | 158 | When scrolling request is delivered soon after the previous one, |
| @@ -529,23 +541,23 @@ the height of the current window." | |||
| 529 | "Interpolate a scroll of DELTA pixels. | 541 | "Interpolate a scroll of DELTA pixels. |
| 530 | This results in the window being scrolled by DELTA pixels with an | 542 | This results in the window being scrolled by DELTA pixels with an |
| 531 | animation." | 543 | animation." |
| 532 | (while-no-input | 544 | (let ((percentage 0) |
| 533 | (let ((percentage 0) | 545 | (total-time pixel-scroll-precision-interpolation-total-time) |
| 534 | (total-time 0.01) | 546 | (factor pixel-scroll-precision-interpolation-factor) |
| 535 | (time-elapsed 0.0) | 547 | (time-elapsed 0.0) |
| 536 | (between-scroll 0.001)) | 548 | (between-scroll 0.001)) |
| 537 | (while (< percentage 1) | 549 | (while (< percentage 1) |
| 538 | (sit-for between-scroll) | 550 | (sit-for between-scroll) |
| 539 | (setq time-elapsed (+ time-elapsed between-scroll) | 551 | (setq time-elapsed (+ time-elapsed between-scroll) |
| 540 | percentage (/ time-elapsed total-time)) | 552 | percentage (/ time-elapsed total-time)) |
| 541 | (if (< delta 0) | 553 | (if (< delta 0) |
| 542 | (pixel-scroll-precision-scroll-down | 554 | (pixel-scroll-precision-scroll-down |
| 543 | (ceiling (abs (* delta | 555 | (ceiling (abs (* (* delta factor) |
| 544 | (/ between-scroll total-time))))) | 556 | (/ between-scroll total-time))))) |
| 545 | (pixel-scroll-precision-scroll-up | 557 | (pixel-scroll-precision-scroll-up |
| 546 | (ceiling (* delta | 558 | (ceiling (* (* delta factor) |
| 547 | (/ between-scroll total-time))))) | 559 | (/ between-scroll total-time))))) |
| 548 | (redisplay t))))) | 560 | (redisplay t)))) |
| 549 | 561 | ||
| 550 | (defun pixel-scroll-precision-scroll-up (delta) | 562 | (defun pixel-scroll-precision-scroll-up (delta) |
| 551 | "Scroll the current window up by DELTA pixels." | 563 | "Scroll the current window up by DELTA pixels." |
| @@ -691,6 +703,8 @@ precisely, according to the turning of the mouse wheel." | |||
| 691 | :group 'mouse | 703 | :group 'mouse |
| 692 | :keymap pixel-scroll-precision-mode-map | 704 | :keymap pixel-scroll-precision-mode-map |
| 693 | (setq mwheel-coalesce-scroll-events | 705 | (setq mwheel-coalesce-scroll-events |
| 706 | (not pixel-scroll-precision-mode) | ||
| 707 | make-cursor-line-fully-visible | ||
| 694 | (not pixel-scroll-precision-mode))) | 708 | (not pixel-scroll-precision-mode))) |
| 695 | 709 | ||
| 696 | (provide 'pixel-scroll) | 710 | (provide 'pixel-scroll) |
diff --git a/src/xterm.c b/src/xterm.c index 3f7b9560345..ae0daa79f31 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -9851,6 +9851,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 9851 | XIValuatorState *states; | 9851 | XIValuatorState *states; |
| 9852 | double *values; | 9852 | double *values; |
| 9853 | bool found_valuator = false; | 9853 | bool found_valuator = false; |
| 9854 | bool any_stop_p = false; | ||
| 9854 | 9855 | ||
| 9855 | /* A fake XMotionEvent for x_note_mouse_movement. */ | 9856 | /* A fake XMotionEvent for x_note_mouse_movement. */ |
| 9856 | XMotionEvent ev; | 9857 | XMotionEvent ev; |
| @@ -10003,9 +10004,13 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 10003 | if (val->horizontal) | 10004 | if (val->horizontal) |
| 10004 | xv_total_x += delta; | 10005 | xv_total_x += delta; |
| 10005 | else | 10006 | else |
| 10006 | xv_total_y += -delta; | 10007 | xv_total_y += delta; |
| 10007 | 10008 | ||
| 10008 | found_valuator = true; | 10009 | found_valuator = true; |
| 10010 | |||
| 10011 | if (delta == 0.0) | ||
| 10012 | any_stop_p = true; | ||
| 10013 | |||
| 10009 | continue; | 10014 | continue; |
| 10010 | } | 10015 | } |
| 10011 | #endif | 10016 | #endif |
| @@ -10092,7 +10097,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 10092 | if (found_valuator) | 10097 | if (found_valuator) |
| 10093 | xwidget_scroll (xv, xev->event_x, xev->event_y, | 10098 | xwidget_scroll (xv, xev->event_x, xev->event_y, |
| 10094 | xv_total_x, xv_total_y, xev->mods.effective, | 10099 | xv_total_x, xv_total_y, xev->mods.effective, |
| 10095 | xev->time); | 10100 | xev->time, any_stop_p); |
| 10096 | else | 10101 | else |
| 10097 | xwidget_motion_notify (xv, xev->event_x, xev->event_y, | 10102 | xwidget_motion_notify (xv, xev->event_x, xev->event_y, |
| 10098 | xev->mods.effective, xev->time); | 10103 | xev->mods.effective, xev->time); |
diff --git a/src/xwidget.c b/src/xwidget.c index 749a3220a38..bd64f483377 100644 --- a/src/xwidget.c +++ b/src/xwidget.c | |||
| @@ -1066,7 +1066,8 @@ xwidget_motion_notify (struct xwidget_view *view, | |||
| 1066 | 1066 | ||
| 1067 | void | 1067 | void |
| 1068 | xwidget_scroll (struct xwidget_view *view, double x, double y, | 1068 | xwidget_scroll (struct xwidget_view *view, double x, double y, |
| 1069 | double dx, double dy, uint state, Time time) | 1069 | double dx, double dy, uint state, Time time, |
| 1070 | bool stop_p) | ||
| 1070 | { | 1071 | { |
| 1071 | GdkEvent *xg_event; | 1072 | GdkEvent *xg_event; |
| 1072 | GtkWidget *target; | 1073 | GtkWidget *target; |
| @@ -1101,9 +1102,7 @@ xwidget_scroll (struct xwidget_view *view, double x, double y, | |||
| 1101 | xg_event->scroll.delta_x = dx; | 1102 | xg_event->scroll.delta_x = dx; |
| 1102 | xg_event->scroll.delta_y = dy; | 1103 | xg_event->scroll.delta_y = dy; |
| 1103 | xg_event->scroll.device = find_suitable_pointer (view->frame); | 1104 | xg_event->scroll.device = find_suitable_pointer (view->frame); |
| 1104 | 1105 | xg_event->scroll.is_stop = stop_p; | |
| 1105 | if (!(fabs (dx) > 0) || !(fabs (dy) > 0)) | ||
| 1106 | xg_event->scroll.is_stop = TRUE; | ||
| 1107 | 1106 | ||
| 1108 | g_object_ref (xg_event->any.window); | 1107 | g_object_ref (xg_event->any.window); |
| 1109 | 1108 | ||
diff --git a/src/xwidget.h b/src/xwidget.h index f2d497c0920..a03006fde9a 100644 --- a/src/xwidget.h +++ b/src/xwidget.h | |||
| @@ -199,7 +199,7 @@ extern void xwidget_motion_or_crossing (struct xwidget_view *, | |||
| 199 | extern void xwidget_motion_notify (struct xwidget_view *, double, | 199 | extern void xwidget_motion_notify (struct xwidget_view *, double, |
| 200 | double, uint, Time); | 200 | double, uint, Time); |
| 201 | extern void xwidget_scroll (struct xwidget_view *, double, double, | 201 | extern void xwidget_scroll (struct xwidget_view *, double, double, |
| 202 | double, double, uint, Time); | 202 | double, double, uint, Time, bool); |
| 203 | #endif | 203 | #endif |
| 204 | #endif | 204 | #endif |
| 205 | #else | 205 | #else |