aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2019-10-05 11:59:55 +0300
committerEli Zaretskii2019-10-05 11:59:55 +0300
commit9c66b09950cf2db50eb6d818656a268ef750bfe6 (patch)
tree82abc06a4666fc7f4d99ebf1c0407de6cd3012f3
parentbbfa9995ff3bdb8a00fe3082bc3249cc1e68e1ab (diff)
downloademacs-9c66b09950cf2db50eb6d818656a268ef750bfe6.tar.gz
emacs-9c66b09950cf2db50eb6d818656a268ef750bfe6.zip
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)
-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."
121 121
122(defun image-set-window-vscroll (vscroll) 122(defun image-set-window-vscroll (vscroll)
123 (setf (image-mode-window-get 'vscroll) vscroll) 123 (setf (image-mode-window-get 'vscroll) vscroll)
124 (set-window-vscroll (selected-window) vscroll)) 124 (set-window-vscroll (selected-window) vscroll t))
125 125
126(defun image-set-window-hscroll (ncol) 126(defun image-set-window-hscroll (ncol)
127 (setf (image-mode-window-get 'hscroll) ncol) 127 (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."
139 (vscroll (image-mode-window-get 'vscroll winprops))) 139 (vscroll (image-mode-window-get 'vscroll winprops)))
140 (when (image-get-display-property) ;Only do it if we display an image! 140 (when (image-get-display-property) ;Only do it if we display an image!
141 (if hscroll (set-window-hscroll (selected-window) hscroll)) 141 (if hscroll (set-window-hscroll (selected-window) hscroll))
142 (if vscroll (set-window-vscroll (selected-window) vscroll)))))) 142 (if vscroll (set-window-vscroll (selected-window) vscroll t))))))
143 143
144(defun image-mode-setup-winprops () 144(defun image-mode-setup-winprops ()
145 ;; Record current scroll settings. 145 ;; Record current scroll settings.
@@ -215,16 +215,18 @@ Stop if the left edge of the image is reached."
215 "Scroll image in current window upward by N lines. 215 "Scroll image in current window upward by N lines.
216Stop if the bottom edge of the image is reached." 216Stop if the bottom edge of the image is reached."
217 (interactive "p") 217 (interactive "p")
218 ;; Convert N to pixels.
219 (setq n (* n (frame-char-height)))
218 (cond ((= n 0) nil) 220 (cond ((= n 0) nil)
219 ((< n 0) 221 ((< n 0)
220 (image-set-window-vscroll (max 0 (+ (window-vscroll) n)))) 222 (image-set-window-vscroll (max 0 (+ (window-vscroll nil t) n))))
221 (t 223 (t
222 (let* ((image (image-get-display-property)) 224 (let* ((image (image-get-display-property))
223 (edges (window-inside-edges)) 225 (edges (window-edges nil t t))
224 (win-height (- (nth 3 edges) (nth 1 edges))) 226 (win-height (- (nth 3 edges) (nth 1 edges)))
225 (img-height (ceiling (cdr (image-display-size image))))) 227 (img-height (ceiling (cdr (image-display-size image t)))))
226 (image-set-window-vscroll (min (max 0 (- img-height win-height)) 228 (image-set-window-vscroll (min (max 0 (- img-height win-height))
227 (+ n (window-vscroll)))))))) 229 (+ n (window-vscroll nil t))))))))
228 230
229(defun image-previous-line (&optional n) 231(defun image-previous-line (&optional n)
230 "Scroll image in current window downward by N lines. 232 "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."
351 (interactive) 353 (interactive)
352 (let* ((image (image-get-display-property)) 354 (let* ((image (image-get-display-property))
353 (edges (window-inside-edges)) 355 (edges (window-inside-edges))
356 (pixel-edges (window-edges nil t t))
354 (win-width (- (nth 2 edges) (nth 0 edges))) 357 (win-width (- (nth 2 edges) (nth 0 edges)))
355 (img-width (ceiling (car (image-display-size image)))) 358 (img-width (ceiling (car (image-display-size image))))
356 (win-height (- (nth 3 edges) (nth 1 edges))) 359 (win-height (- (nth 3 pixel-edges) (nth 1 pixel-edges)))
357 (img-height (ceiling (cdr (image-display-size image))))) 360 (img-height (ceiling (cdr (image-display-size image t)))))
358 (image-set-window-hscroll (max 0 (- img-width win-width))) 361 (image-set-window-hscroll (max 0 (- img-width win-width)))
359 (image-set-window-vscroll (max 0 (- img-height win-height))))) 362 (image-set-window-vscroll (max 0 (- img-height win-height)))))
360 363