summaryrefslogtreecommitdiff
path: root/lisp/image-mode.el
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2019-10-05 11:59:55 +0300
committerEli Zaretskii <eliz@gnu.org>2019-10-05 11:59:55 +0300
commit9c66b09950cf2db50eb6d818656a268ef750bfe6 (patch)
tree82abc06a4666fc7f4d99ebf1c0407de6cd3012f3 /lisp/image-mode.el
parentbbfa9995ff3bdb8a00fe3082bc3249cc1e68e1ab (diff)
downloademacs-9c66b09950cf2db50eb6d818656a268ef750bfe6.tar.gz
Fix vertical scrolling in image-mode
* lisp/image-mode.el (image-set-window-vscroll): Interpret the argument VSCROLL value in pixel units. (image-mode-reapply-winprops): Interpret the 'vscroll' property value in pixel units. (image-next-line): Scroll the image with pixel resolution. (image-eob): Set the image vscroll in pixels. (Bug#37578)
Diffstat (limited to 'lisp/image-mode.el')
-rw-r--r--lisp/image-mode.el19
1 files changed, 11 insertions, 8 deletions
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index ed796565a38..a869907669c 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -121,7 +121,7 @@ otherwise it defaults to t, used for times when the buffer is not displayed."
(defun image-set-window-vscroll (vscroll)
(setf (image-mode-window-get 'vscroll) vscroll)
- (set-window-vscroll (selected-window) vscroll))
+ (set-window-vscroll (selected-window) vscroll t))
(defun image-set-window-hscroll (ncol)
(setf (image-mode-window-get 'hscroll) ncol)
@@ -139,7 +139,7 @@ otherwise it defaults to t, used for times when the buffer is not displayed."
(vscroll (image-mode-window-get 'vscroll winprops)))
(when (image-get-display-property) ;Only do it if we display an image!
(if hscroll (set-window-hscroll (selected-window) hscroll))
- (if vscroll (set-window-vscroll (selected-window) vscroll))))))
+ (if vscroll (set-window-vscroll (selected-window) vscroll t))))))
(defun image-mode-setup-winprops ()
;; Record current scroll settings.
@@ -215,16 +215,18 @@ Stop if the left edge of the image is reached."
"Scroll image in current window upward by N lines.
Stop if the bottom edge of the image is reached."
(interactive "p")
+ ;; Convert N to pixels.
+ (setq n (* n (frame-char-height)))
(cond ((= n 0) nil)
((< n 0)
- (image-set-window-vscroll (max 0 (+ (window-vscroll) n))))
+ (image-set-window-vscroll (max 0 (+ (window-vscroll nil t) n))))
(t
(let* ((image (image-get-display-property))
- (edges (window-inside-edges))
+ (edges (window-edges nil t t))
(win-height (- (nth 3 edges) (nth 1 edges)))
- (img-height (ceiling (cdr (image-display-size image)))))
+ (img-height (ceiling (cdr (image-display-size image t)))))
(image-set-window-vscroll (min (max 0 (- img-height win-height))
- (+ n (window-vscroll))))))))
+ (+ n (window-vscroll nil t))))))))
(defun image-previous-line (&optional n)
"Scroll image in current window downward by N lines.
@@ -351,10 +353,11 @@ stopping if the top or bottom edge of the image is reached."
(interactive)
(let* ((image (image-get-display-property))
(edges (window-inside-edges))
+ (pixel-edges (window-edges nil t t))
(win-width (- (nth 2 edges) (nth 0 edges)))
(img-width (ceiling (car (image-display-size image))))
- (win-height (- (nth 3 edges) (nth 1 edges)))
- (img-height (ceiling (cdr (image-display-size image)))))
+ (win-height (- (nth 3 pixel-edges) (nth 1 pixel-edges)))
+ (img-height (ceiling (cdr (image-display-size image t)))))
(image-set-window-hscroll (max 0 (- img-width win-width)))
(image-set-window-vscroll (max 0 (- img-height win-height)))))