Merge remote-tracking branch 'origin/master' into feature/pgtk
This commit is contained in:
commit
41b1d223c6
4 changed files with 42 additions and 24 deletions
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue