emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 44a77d3: Reset window scroll when displaying an ima


From: Mark Oteiza
Subject: [Emacs-diffs] master 44a77d3: Reset window scroll when displaying an image
Date: Wed, 14 Dec 2016 17:31:02 +0000 (UTC)

branch: master
commit 44a77d34c63fb4188edca6e1a875c9a1ec01f3f7
Author: Mark Oteiza <address@hidden>
Commit: Mark Oteiza <address@hidden>

    Reset window scroll when displaying an image
    
    When viewing a large image full size and scrolling, for instance, to
    the lower right corner, then selecting a much smaller image in the
    thumbnail buffer, the window stays scrolled so the new image is out of
    the window.  One must scroll back to the "origin" to view the new
    displayed image, or just kill the image-dired-display-image buffer and
    try again.  This fixes the issue.
    * lisp/image-dired.el (image-dired-display-window-width):
    (image-dired-display-window-height): Operate on a window as argument.
    (image-dired-display-image): Bind (image-dired-display-window) and use
    it. Set window vscroll and hscroll to zero when refreshing the
    buffer's contents.
---
 lisp/image-dired.el |   19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index cff4ef8..1c99db3 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -1674,14 +1674,14 @@ Ask user how many thumbnails should be displayed per 
row."
              (equal (window-buffer window) buf))))
       (error "No thumbnail image at point"))))
 
-(defun image-dired-display-window-width ()
-  "Return width, in pixels, of image-dired's image display window."
-  (- (image-dired-window-width-pixels (image-dired-display-window))
+(defun image-dired-display-window-width (window)
+  "Return width, in pixels, of WINDOW."
+  (- (image-dired-window-width-pixels window)
      image-dired-display-window-width-correction))
 
-(defun image-dired-display-window-height ()
-  "Return height, in pixels, of image-dired's image display window."
-  (- (image-dired-window-height-pixels (image-dired-display-window))
+(defun image-dired-display-window-height (window)
+  "Return height, in pixels, of WINDOW."
+  (- (image-dired-window-height-pixels window)
      image-dired-display-window-height-correction))
 
 (defun image-dired-display-image (file &optional original-size)
@@ -1697,13 +1697,14 @@ original size."
   (image-dired--check-executable-exists
    'image-dired-cmd-create-temp-image-program)
   (let ((new-file (expand-file-name image-dired-temp-image-file))
+        (window (image-dired-display-window))
         width height command ret
         (image-type 'jpeg))
     (setq file (expand-file-name file))
     (if (not original-size)
         (progn
-          (setq width (image-dired-display-window-width))
-          (setq height (image-dired-display-window-height))
+          (setq width (image-dired-display-window-width window))
+          (setq height (image-dired-display-window-height window))
           (setq command
                 (format-spec
                  image-dired-cmd-create-temp-image-options
@@ -1725,6 +1726,8 @@ original size."
         (clear-image-cache)
         (image-dired-insert-image image-dired-temp-image-file image-type 0 0)
         (goto-char (point-min))
+        (set-window-vscroll window 0)
+        (set-window-hscroll window 0)
         (image-dired-update-property 'original-file-name file)))))
 
 (defun image-dired-display-thumbnail-original-image (&optional arg)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]