From: Po Lu Date: Fri, 25 Feb 2022 06:15:51 +0000 (+0800) Subject: Make interpolated scrolling work above non-selected windows X-Git-Tag: emacs-29.0.90~2112 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a2e80d2a419a2092d6a196c42280295c34388ae4;p=emacs.git Make interpolated scrolling work above non-selected windows * lisp/pixel-scroll.el (pixel-scroll-precision-interpolate): New parameter `old-window'. (pixel-scroll-precision): Pass originally selected window to the interpolation function. --- diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el index 463e106c7ac..042c8a419e8 100644 --- a/lisp/pixel-scroll.el +++ b/lisp/pixel-scroll.el @@ -592,10 +592,11 @@ the height of the current window." (when (< delta 0) (set-window-vscroll nil (- delta) t))))) -(defun pixel-scroll-precision-interpolate (delta) +(defun pixel-scroll-precision-interpolate (delta &optional old-window) "Interpolate a scroll of DELTA pixels. -This results in the window being scrolled by DELTA pixels with an -animation." +OLD-WINDOW is the window which will be selected when redisplay +takes place, or nil for the current window. This results in the +window being scrolled by DELTA pixels with an animation." (let ((percentage 0) (total-time pixel-scroll-precision-interpolation-total-time) (factor pixel-scroll-precision-interpolation-factor) @@ -613,7 +614,9 @@ animation." (while-no-input (unwind-protect (while (< percentage 1) - (redisplay t) + (with-selected-window (or old-window + (selected-window)) + (redisplay t)) (sleep-for between-scroll) (setq time-elapsed (+ time-elapsed (- (float-time) last-time)) @@ -664,7 +667,8 @@ Move the display up or down by the pixel deltas in EVENT to scroll the display according to the user's turning the mouse wheel." (interactive "e") - (let ((window (mwheel-event-window event))) + (let ((window (mwheel-event-window event)) + (current-window (selected-window))) (if (and (nth 4 event)) (let ((delta (round (cdr (nth 4 event))))) (unless (zerop delta) @@ -685,7 +689,7 @@ wheel." (let ((kin-state (pixel-scroll-kinetic-state))) (aset kin-state 0 (make-ring 30)) (aset kin-state 1 nil)) - (pixel-scroll-precision-interpolate delta)) + (pixel-scroll-precision-interpolate delta current-window)) (condition-case nil (progn (if (< delta 0)