emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 643eee8: Make pixel scrolling through images less jumpy


From: Po Lu
Subject: master 643eee8: Make pixel scrolling through images less jumpy
Date: Sat, 4 Dec 2021 20:46:53 -0500 (EST)

branch: master
commit 643eee8b1bf0bcacf6030f58bcaf161e5a3d5ab6
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Make pixel scrolling through images less jumpy
    
    * lisp/pixel-scroll.el
    (pixel-scroll-precision-scroll-down-page): Improve detection of
    situations where vscroll must directly be set.
---
 lisp/pixel-scroll.el | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el
index ce2aee6..5d6836c 100644
--- a/lisp/pixel-scroll.el
+++ b/lisp/pixel-scroll.el
@@ -411,23 +411,23 @@ the height of the current window."
          (object (posn-object desired-pos))
         (desired-start (posn-point desired-pos))
         (desired-vscroll (cdr (posn-object-x-y desired-pos)))
+         (edges (window-edges nil t))
+         (usable-height (- (nth 3 edges)
+                           (nth 1 edges)))
          (next-pos (save-excursion
                      (goto-char desired-start)
                      (when (zerop (vertical-motion (1+ scroll-margin)))
                        (signal 'end-of-buffer nil))
-                     (point))))
-    (if (and (< (point) next-pos)
-             (let ((pos-visibility (pos-visible-in-window-p next-pos nil t)))
-               (and pos-visibility
-                    (or (eq (length pos-visibility) 2)
-                        (when-let* ((posn (posn-at-point next-pos))
-                                    (edges (window-edges nil t))
-                                    (usable-height (- (nth 3 edges)
-                                                      (nth 1 edges))))
-                          (> (cdr (posn-object-width-height posn))
-                             usable-height))))))
-        (goto-char next-pos))
-    (if (or (consp object) (stringp object))
+                     (point)))
+         (end-pos (posn-at-x-y 0 (+ usable-height
+                                    (window-tab-line-height)
+                                   (window-header-line-height)))))
+    (if (or (overlayp object)
+            (stringp object)
+            (and (consp object)
+                 (stringp (car object)))
+            (and (consp (posn-object end-pos))
+                 (> (cdr (posn-object-x-y end-pos)) 0)))
         ;; We are either on an overlay or a string, so set vscroll
         ;; directly.
         (set-window-vscroll nil (+ (window-vscroll nil t)
@@ -441,7 +441,15 @@ the height of the current window."
                                   (beginning-of-visual-line)
                                   (point)))
                           t))
-      (set-window-vscroll nil desired-vscroll t))))
+      (set-window-vscroll nil desired-vscroll t))
+    (if (and (or (< (point) next-pos))
+             (let ((pos-visibility (pos-visible-in-window-p next-pos nil t)))
+               (and pos-visibility
+                    (or (eq (length pos-visibility) 2)
+                        (when-let* ((posn (posn-at-point next-pos)))
+                          (> (cdr (posn-object-width-height posn))
+                             usable-height))))))
+        (goto-char next-pos))))
 
 (defun pixel-scroll-precision-scroll-down (delta)
   "Scroll the current window down by DELTA pixels."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]