diff options
| author | Po Lu | 2021-12-05 09:44:06 +0800 |
|---|---|---|
| committer | Po Lu | 2021-12-05 09:46:42 +0800 |
| commit | 643eee8b1bf0bcacf6030f58bcaf161e5a3d5ab6 (patch) | |
| tree | 7f1f965edbd5eb949a49b0e1fed2c12bd0495d62 | |
| parent | c585112ac5f60f32d26ccf59100176ff194098ab (diff) | |
| download | emacs-643eee8b1bf0bcacf6030f58bcaf161e5a3d5ab6.tar.gz emacs-643eee8b1bf0bcacf6030f58bcaf161e5a3d5ab6.zip | |
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.
| -rw-r--r-- | lisp/pixel-scroll.el | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el index ce2aee6c452..5d6836ca688 100644 --- a/lisp/pixel-scroll.el +++ b/lisp/pixel-scroll.el | |||
| @@ -411,23 +411,23 @@ the height of the current window." | |||
| 411 | (object (posn-object desired-pos)) | 411 | (object (posn-object desired-pos)) |
| 412 | (desired-start (posn-point desired-pos)) | 412 | (desired-start (posn-point desired-pos)) |
| 413 | (desired-vscroll (cdr (posn-object-x-y desired-pos))) | 413 | (desired-vscroll (cdr (posn-object-x-y desired-pos))) |
| 414 | (edges (window-edges nil t)) | ||
| 415 | (usable-height (- (nth 3 edges) | ||
| 416 | (nth 1 edges))) | ||
| 414 | (next-pos (save-excursion | 417 | (next-pos (save-excursion |
| 415 | (goto-char desired-start) | 418 | (goto-char desired-start) |
| 416 | (when (zerop (vertical-motion (1+ scroll-margin))) | 419 | (when (zerop (vertical-motion (1+ scroll-margin))) |
| 417 | (signal 'end-of-buffer nil)) | 420 | (signal 'end-of-buffer nil)) |
| 418 | (point)))) | 421 | (point))) |
| 419 | (if (and (< (point) next-pos) | 422 | (end-pos (posn-at-x-y 0 (+ usable-height |
| 420 | (let ((pos-visibility (pos-visible-in-window-p next-pos nil t))) | 423 | (window-tab-line-height) |
| 421 | (and pos-visibility | 424 | (window-header-line-height))))) |
| 422 | (or (eq (length pos-visibility) 2) | 425 | (if (or (overlayp object) |
| 423 | (when-let* ((posn (posn-at-point next-pos)) | 426 | (stringp object) |
| 424 | (edges (window-edges nil t)) | 427 | (and (consp object) |
| 425 | (usable-height (- (nth 3 edges) | 428 | (stringp (car object))) |
| 426 | (nth 1 edges)))) | 429 | (and (consp (posn-object end-pos)) |
| 427 | (> (cdr (posn-object-width-height posn)) | 430 | (> (cdr (posn-object-x-y end-pos)) 0))) |
| 428 | usable-height)))))) | ||
| 429 | (goto-char next-pos)) | ||
| 430 | (if (or (consp object) (stringp object)) | ||
| 431 | ;; We are either on an overlay or a string, so set vscroll | 431 | ;; We are either on an overlay or a string, so set vscroll |
| 432 | ;; directly. | 432 | ;; directly. |
| 433 | (set-window-vscroll nil (+ (window-vscroll nil t) | 433 | (set-window-vscroll nil (+ (window-vscroll nil t) |
| @@ -441,7 +441,15 @@ the height of the current window." | |||
| 441 | (beginning-of-visual-line) | 441 | (beginning-of-visual-line) |
| 442 | (point))) | 442 | (point))) |
| 443 | t)) | 443 | t)) |
| 444 | (set-window-vscroll nil desired-vscroll t)))) | 444 | (set-window-vscroll nil desired-vscroll t)) |
| 445 | (if (and (or (< (point) next-pos)) | ||
| 446 | (let ((pos-visibility (pos-visible-in-window-p next-pos nil t))) | ||
| 447 | (and pos-visibility | ||
| 448 | (or (eq (length pos-visibility) 2) | ||
| 449 | (when-let* ((posn (posn-at-point next-pos))) | ||
| 450 | (> (cdr (posn-object-width-height posn)) | ||
| 451 | usable-height)))))) | ||
| 452 | (goto-char next-pos)))) | ||
| 445 | 453 | ||
| 446 | (defun pixel-scroll-precision-scroll-down (delta) | 454 | (defun pixel-scroll-precision-scroll-down (delta) |
| 447 | "Scroll the current window down by DELTA pixels." | 455 | "Scroll the current window down by DELTA pixels." |