bug-auctex
[Top][All Lists]
Advanced

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

bug#45596: 12.2.4; Wrong DPI calculation for mixed-DPI multi-monitor set


From: Tassilo Horn
Subject: bug#45596: 12.2.4; Wrong DPI calculation for mixed-DPI multi-monitor setups
Date: Sun, 03 Jan 2021 10:55:03 +0100
User-agent: mu4e 1.5.7; emacs 28.0.50

Grzegorz Kowzan <grzegorz@kowzan.eu> writes:

Hi Grzegorz,

thanks a lot for your contribution!

> preview-latex calculates DPI in `preview-get-geometry` by calling
> `display-pixel-width`, `display-mm-width` and analogous height-related
> functions. According to documentation:
>
> For graphical terminals, note that on "multi-monitor" setups this
> refers to the pixel width for all physical monitors associated
> with DISPLAY.  To get information for each physical monitor, use
> display-monitor-attributes-list.
>
> This results in incorrent DPI values for multi-monitor setups with
> pure GTK fork of Emacs.  Please see this comment
> (https://github.com/masm11/emacs/issues/90#issuecomment-753307864) on
> GitHub for specifics. As a suggested fix, I'm attaching below a
> version of `preview-get-geometry` that returns DPI for the monitor
> holding the active frame.  This way of calculating DPI works correctly
> for current standard Emacs builds and for the pure GTK version of
> Emacs.

I get very different values with the old and new calculation on my
current single laptop screen setup

  ((131.09677419354838 . 134.47058823529412) ;; New
   (96.07565011820331 . 96.05042016806723))  ;; Old

so that by using your version, the previews are much larger than they
used to be, i.e., their font size appears to be much larger than my
normal editing font.  This is with a current Emacs 28 (master branch,
i.e., no pgtk) on a Wayland display.

Could you please look into where this huge difference comes from?  Here
is what `frame-monitor-attributes' and `display-mm-width' /
`display-mm-height' return here:

--8<---------------cut here---------------start------------->8---
(frame-monitor-attributes)
;=> ((name . "XWAYLAND0")
     (geometry 0 0 1600 900)
     (workarea 0 0 1600 900)
     (mm-size 310 170)
     (frames #<frame  *Minibuf-1* - GNU Emacs at thinkpad-t440p 0x5607eeb922f8> 
#<frame  0x5607eecefeb8> #<frame  0x5607f1829590>)
     (source . "Gdk"))

(display-mm-width)
;=> 423

(display-mm-height)
;=> 238
--8<---------------cut here---------------end--------------->8---

I guess the problem is that mm-size in the `frame-monitor-attributes'
return value differs from `display-mm-height' and `display-mm-width'.

Another problem is that

> (defun preview-get-dpi ()
>   (let* ((monitor-attrs (frame-monitor-attributes))
                           ^^^^^^^^^^^^^^^^^^^^^^^^

is available only since Emacs 24.4 and we just bumped support from 24.1
to 24.3.  So this would need to be fboundp-checked falling back to the
calculation we have right now with a comment mentioning that this is for
Emacs 24.3 compatibility and can be removed as soon as we bump
compatibility to Emacs 24.4 or newer.

Bye,
Tassilo





reply via email to

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