summaryrefslogtreecommitdiff
path: root/lisp/image-mode.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-03-23 14:17:58 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2022-03-23 14:19:22 +0100
commite5e5d85369cdae669af78feb22a924a2a493c48f (patch)
treea7a0cf7773e8d5af8d2b559a96248daaf5dc1d0c /lisp/image-mode.el
parent59260ec59847ac4ee686c6e342e910c1d796aad9 (diff)
downloademacs-e5e5d85369cdae669af78feb22a924a2a493c48f.tar.gz
emacs-e5e5d85369cdae669af78feb22a924a2a493c48f.tar.bz2
emacs-e5e5d85369cdae669af78feb22a924a2a493c48f.zip
Fix image-mode-fit-frame resizing
* lisp/image-mode.el (image-mode-fit-frame): Use pixel sizes instead of lines/columns to get more accurate resizing (bug#37630).
Diffstat (limited to 'lisp/image-mode.el')
-rw-r--r--lisp/image-mode.el32
1 files changed, 17 insertions, 15 deletions
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 38a5e7cdfdc..863d014cdc4 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -420,37 +420,39 @@ call."
(interactive (list nil t))
(let* ((buffer (current-buffer))
(display (image-get-display-property))
- (size (image-display-size display))
+ (size (image-display-size display t))
(saved (frame-parameter frame 'image-mode-saved-params))
(window-configuration (current-window-configuration frame))
- (width (frame-width frame))
- (height (frame-height frame)))
+ (frame-width (frame-pixel-width frame))
+ (frame-height (frame-pixel-height frame)))
(with-selected-frame (or frame (selected-frame))
(if (and toggle saved
- (= (caar saved) width)
- (= (cdar saved) height))
+ (= (caar saved) frame-width)
+ (= (cdar saved) frame-height))
(progn
- (set-frame-width frame (car (nth 1 saved)))
- (set-frame-height frame (cdr (nth 1 saved)))
+ (set-frame-width frame (car (nth 1 saved)) nil t)
+ (set-frame-height frame (cdr (nth 1 saved)) nil t)
(set-window-configuration (nth 2 saved))
(set-frame-parameter frame 'image-mode-saved-params nil))
(delete-other-windows)
(switch-to-buffer buffer t t)
- (let* ((edges (window-inside-edges))
- (inner-width (- (nth 2 edges) (nth 0 edges)))
+ (let* ((edges (window-inside-pixel-edges))
+ (inner-width (- (nth 2 edges) (nth 0 edges)))
(inner-height (- (nth 3 edges) (nth 1 edges))))
- (set-frame-width frame (+ (ceiling (car size))
- width (- inner-width)))
+ (set-frame-width frame (+ (ceiling (car size))
+ (- frame-width inner-width))
+ nil t)
(set-frame-height frame (+ (ceiling (cdr size))
- height (- inner-height)))
+ (- frame-height inner-height))
+ nil t)
;; The frame size after the above `set-frame-*' calls may
;; differ from what we specified, due to window manager
;; interference. We have to call `frame-width' and
;; `frame-height' to get the actual results.
(set-frame-parameter frame 'image-mode-saved-params
- (list (cons (frame-width)
- (frame-height))
- (cons width height)
+ (list (cons (frame-pixel-width frame)
+ (frame-pixel-height frame))
+ (cons frame-width frame-height)
window-configuration)))))))
;;; Image Mode setup