emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/auctex 67bd5ff 02/11: Use frame-monitor-attributes for


From: Tassilo Horn
Subject: [elpa] externals/auctex 67bd5ff 02/11: Use frame-monitor-attributes for computing DPI if avail (bug#45596)
Date: Fri, 8 Jan 2021 14:24:29 -0500 (EST)

branch: externals/auctex
commit 67bd5ffe4fe9d0e0af96f145e098ba1c632f680b
Author: Tassilo Horn <tsdh@gnu.org>
Commit: Tassilo Horn <tsdh@gnu.org>

    Use frame-monitor-attributes for computing DPI if avail (bug#45596)
    
    * preview.el.in (preview-get-dpi): New defun.
    (preview-get-geometry): Use it for computing the screen DPI (bug#45596)
---
 preview.el.in | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/preview.el.in b/preview.el.in
index 58c2741..eb40ae5 100644
--- a/preview.el.in
+++ b/preview.el.in
@@ -3603,6 +3603,25 @@ name(\\([^)]+\\))\\)\\|\
                                   snippet)) "Parser"))))))))
           (preview-call-hook 'close (car open-data) close-data))))))
 
+(defun preview-get-dpi ()
+  ;; TODO: Remove false-case when required emacs version is bumped to
+  ;; 24.4 or newer as this is the version where
+  ;; `frame-monitor-attributes' has been introduced.
+  (if (fboundp 'frame-monitor-attributes)
+      (let* ((monitor-attrs (frame-monitor-attributes))
+             (mm-dims (cdr (assoc 'mm-size monitor-attrs)))
+             (mm-width (nth 0 mm-dims))
+             (mm-height (nth 1 mm-dims))
+             (pixel-dims (cdddr (assoc 'geometry monitor-attrs)))
+             (pixel-width (nth 0 pixel-dims))
+             (pixel-height (nth 1 pixel-dims)))
+        (cons (/ (* 25.4 pixel-width) mm-width)
+              (/ (* 25.4 pixel-height) mm-height)))
+    (cons (/ (* 25.4 (display-pixel-width))
+             (display-mm-width))
+          (/ (* 25.4 (display-pixel-height))
+             (display-mm-height)))))
+
 (defun preview-get-geometry ()
   "Transfer display geometry parameters from current display.
 Returns list of scale, resolution and colors.  Calculation
@@ -3610,10 +3629,7 @@ is done in current buffer."
   (condition-case err
       (let* ((geometry
               (list (preview-hook-enquiry preview-scale-function)
-                    (cons (/ (* 25.4 (display-pixel-width))
-                             (display-mm-width))
-                          (/ (* 25.4 (display-pixel-height))
-                             (display-mm-height)))
+                    (preview-get-dpi)
                     (preview-get-colors)))
              (preview-min-spec
               (* (cdr (nth 1 geometry))



reply via email to

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