[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/pgtk 41b1d22: Merge remote-tracking branch 'origin/master' into
From: |
Po Lu |
Subject: |
feature/pgtk 41b1d22: Merge remote-tracking branch 'origin/master' into feature/pgtk |
Date: |
Wed, 8 Dec 2021 01:18:23 -0500 (EST) |
branch: feature/pgtk
commit 41b1d223c6ab7bca1b626a4c07a4f2dda2855feb
Merge: bdeb189 bf79dad
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Merge remote-tracking branch 'origin/master' into feature/pgtk
---
lisp/pixel-scroll.el | 48 +++++++++++++++++++++++++++++++-----------------
src/xterm.c | 9 +++++++--
src/xwidget.c | 7 +++----
src/xwidget.h | 2 +-
4 files changed, 42 insertions(+), 24 deletions(-)
diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el
index 2e09f9a..6191c05 100644
--- a/lisp/pixel-scroll.el
+++ b/lisp/pixel-scroll.el
@@ -141,6 +141,18 @@ Nil means to not interpolate such scrolls."
number)
:version "29.1")
+(defcustom pixel-scroll-precision-interpolation-total-time 0.01
+ "The total time in seconds to spend interpolating a large scroll."
+ :group 'mouse
+ :type 'float
+ :version 29.1)
+
+(defcustom pixel-scroll-precision-interpolation-factor 2.0
+ "A factor to apply to the distance of an interpolated scroll."
+ :group 'mouse
+ :type 'float
+ :version 29.1)
+
(defun pixel-scroll-in-rush-p ()
"Return non-nil if next scroll should be non-smooth.
When scrolling request is delivered soon after the previous one,
@@ -529,23 +541,23 @@ the height of the current window."
"Interpolate a scroll of DELTA pixels.
This results in the window being scrolled by DELTA pixels with an
animation."
- (while-no-input
- (let ((percentage 0)
- (total-time 0.01)
- (time-elapsed 0.0)
- (between-scroll 0.001))
- (while (< percentage 1)
- (sit-for between-scroll)
- (setq time-elapsed (+ time-elapsed between-scroll)
- percentage (/ time-elapsed total-time))
- (if (< delta 0)
- (pixel-scroll-precision-scroll-down
- (ceiling (abs (* delta
- (/ between-scroll total-time)))))
- (pixel-scroll-precision-scroll-up
- (ceiling (* delta
- (/ between-scroll total-time)))))
- (redisplay t)))))
+ (let ((percentage 0)
+ (total-time pixel-scroll-precision-interpolation-total-time)
+ (factor pixel-scroll-precision-interpolation-factor)
+ (time-elapsed 0.0)
+ (between-scroll 0.001))
+ (while (< percentage 1)
+ (sit-for between-scroll)
+ (setq time-elapsed (+ time-elapsed between-scroll)
+ percentage (/ time-elapsed total-time))
+ (if (< delta 0)
+ (pixel-scroll-precision-scroll-down
+ (ceiling (abs (* (* delta factor)
+ (/ between-scroll total-time)))))
+ (pixel-scroll-precision-scroll-up
+ (ceiling (* (* delta factor)
+ (/ between-scroll total-time)))))
+ (redisplay t))))
(defun pixel-scroll-precision-scroll-up (delta)
"Scroll the current window up by DELTA pixels."
@@ -691,6 +703,8 @@ precisely, according to the turning of the mouse wheel."
:group 'mouse
:keymap pixel-scroll-precision-mode-map
(setq mwheel-coalesce-scroll-events
+ (not pixel-scroll-precision-mode)
+ make-cursor-line-fully-visible
(not pixel-scroll-precision-mode)))
(provide 'pixel-scroll)
diff --git a/src/xterm.c b/src/xterm.c
index 3f7b956..ae0daa7 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -9851,6 +9851,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
XIValuatorState *states;
double *values;
bool found_valuator = false;
+ bool any_stop_p = false;
/* A fake XMotionEvent for x_note_mouse_movement. */
XMotionEvent ev;
@@ -10003,9 +10004,13 @@ handle_one_xevent (struct x_display_info *dpyinfo,
if (val->horizontal)
xv_total_x += delta;
else
- xv_total_y += -delta;
+ xv_total_y += delta;
found_valuator = true;
+
+ if (delta == 0.0)
+ any_stop_p = true;
+
continue;
}
#endif
@@ -10092,7 +10097,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
if (found_valuator)
xwidget_scroll (xv, xev->event_x, xev->event_y,
xv_total_x, xv_total_y, xev->mods.effective,
- xev->time);
+ xev->time, any_stop_p);
else
xwidget_motion_notify (xv, xev->event_x, xev->event_y,
xev->mods.effective, xev->time);
diff --git a/src/xwidget.c b/src/xwidget.c
index 749a322..bd64f48 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -1066,7 +1066,8 @@ xwidget_motion_notify (struct xwidget_view *view,
void
xwidget_scroll (struct xwidget_view *view, double x, double y,
- double dx, double dy, uint state, Time time)
+ double dx, double dy, uint state, Time time,
+ bool stop_p)
{
GdkEvent *xg_event;
GtkWidget *target;
@@ -1101,9 +1102,7 @@ xwidget_scroll (struct xwidget_view *view, double x,
double y,
xg_event->scroll.delta_x = dx;
xg_event->scroll.delta_y = dy;
xg_event->scroll.device = find_suitable_pointer (view->frame);
-
- if (!(fabs (dx) > 0) || !(fabs (dy) > 0))
- xg_event->scroll.is_stop = TRUE;
+ xg_event->scroll.is_stop = stop_p;
g_object_ref (xg_event->any.window);
diff --git a/src/xwidget.h b/src/xwidget.h
index f2d497c..a03006f 100644
--- a/src/xwidget.h
+++ b/src/xwidget.h
@@ -199,7 +199,7 @@ extern void xwidget_motion_or_crossing (struct xwidget_view
*,
extern void xwidget_motion_notify (struct xwidget_view *, double,
double, uint, Time);
extern void xwidget_scroll (struct xwidget_view *, double, double,
- double, double, uint, Time);
+ double, double, uint, Time, bool);
#endif
#endif
#else