GNU bug report logs -
#32672
27.0.50; image resize on window resizing
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Sun, 9 Sep 2018 16:11:02 UTC
Severity: wishlist
Tags: fixed
Fixed in version 27.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #150 received at control <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tags 32672 fixed
close 32672 27.0.50
quit
>> Using new hooks I noticed only one problem that when the same image buffer is
>> displayed in several windows then using `other-window' to switch between them,
>> the selection-change hook is not always called.
>
> [...]
>
>> + (add-hook 'window-size-change-functions (debounce #'image-window-change 1) nil t)
>> + (add-hook 'window-state-change-functions (debounce #'image-window-change 1) nil t)
>> + (add-hook 'window-selection-change-functions (debounce #'image-window-change 1) nil t)
>> +
>
> I think this sounds like a nice addition for image-mode... but were the
> remaining edge cases ever resolved? I see that the patch hasn't been
> applied.
This is installed now with the following patch and closed.
[image--window-change.patch (text/x-diff, inline)]
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index db6864649d..09d7828047 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -599,6 +599,10 @@ image-mode--setup-mode
(add-hook 'change-major-mode-hook #'image-toggle-display-text nil t)
(add-hook 'after-revert-hook #'image-after-revert-hook nil t)
+ (add-hook 'window-size-change-functions #'image--window-change nil t)
+ (add-hook 'window-state-change-functions #'image--window-change nil t)
+ (add-hook 'window-selection-change-functions #'image--window-change nil t)
+
(run-mode-hooks 'image-mode-hook)
(let ((image (image-get-display-property))
(msg1 (substitute-command-keys
@@ -856,6 +860,27 @@ image-after-revert-hook
(get-buffer-window-list (current-buffer) 'nomini 'visible))
(image-toggle-display-image)))
+(defvar image--window-change-function
+ (debounce 1.0
+ (lambda (window)
+ (when (window-live-p window)
+ (with-current-buffer (window-buffer)
+ (when (derived-mode-p 'image-mode)
+ (let ((spec (image-get-display-property)))
+ (when (eq (car-safe spec) 'image)
+ (let* ((image-width (plist-get (cdr spec) :max-width))
+ (image-height (plist-get (cdr spec) :max-height))
+ (edges (window-inside-pixel-edges window))
+ (window-width (- (nth 2 edges) (nth 0 edges)))
+ (window-height (- (nth 3 edges) (nth 1 edges))))
+ (when (and image-width image-height
+ (or (not (= image-width window-width))
+ (not (= image-height window-height))))
+ (image-toggle-display-image)))))))))))
+
+(defun image--window-change (window)
+ (funcall image--window-change-function window))
+
;;; Animated images
This bug report was last modified 5 years and 170 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.