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

From: Tassilo Horn <[email-masked]>
Date: Mon, 04 Jan 2021 21:27:11 +0100

Grzegorz Kowzan <[email-masked]> writes:

Hi Grzegorz,

>> I guess the problem is that mm-size in the `frame-monitor-attributes'
>> return value differs from `display-mm-height' and `display-mm-width'.
>
> 1) Yes, `display-pixel/mm-width/height` functions are defined in terms
> of Xlib calls, whereas `frame-monitor-attributes` calls Gdk functions
> (if Emacs was compiled with Gtk support) and only as a fallback it
> calls Xlib. This is why we have this inconsistency. The standard DPI
> for Xorg server is 96 regardless of the actual value, so for a given
> resolution and assumed DPI Xorg gives fake mm width and
> height. Essentially, the current calculation of DPI in auctex looks
> pointless to me...

Ok, I see.

> With pure Gtk port we get actual physical pixel width/height and
> actual mm width/height, so I guess when auctex detects pgtk port, it
> can either ignore these values and hardcode DPI of 96 or make use of
> the actual DPI. I suppose there is something to be said for not
> changing auctex's behaviour and hardcoding the value, but I would
> prefer to use the actual DPI at least as an option (see below).

That's what I did.  Essentially I've applied your patch with an
additional fboundp check for `frame-monitor-attributes'.  If it's
available (24.4), then your variant is used, if not, the previous
variant basically always saying 96 DPI is used.

So let's see if we get any complaints with the next ELPA release.

I'll close this report now.  Thanks again for the contribution!

Bye,
Tassilo