]> git.eshelyaron.com Git - emacs.git/commitdiff
Make interpolated scrolling work above non-selected windows
authorPo Lu <luangruo@yahoo.com>
Fri, 25 Feb 2022 06:15:51 +0000 (14:15 +0800)
committerPo Lu <luangruo@yahoo.com>
Fri, 25 Feb 2022 06:15:51 +0000 (14:15 +0800)
* lisp/pixel-scroll.el (pixel-scroll-precision-interpolate): New
parameter `old-window'.
(pixel-scroll-precision): Pass originally selected window to the
interpolation function.

lisp/pixel-scroll.el

index 463e106c7ac7ada3063f7ed6e08aee9cd4f11967..042c8a419e8075c17e3223b03b51580def61fa03 100644 (file)
@@ -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)