Subject: bug#62392: frame-monitor-attributes fails to calculate mm-size for the monitor

From: Po Lu <[email-masked]>
Date: Thu, 23 Mar 2023 08:47:34 +0800

[email-masked] writes:

> Is the one causing the error. Where in particular? This section:
>
> (/ (nth 4 (assq 'geometry atts))
> (nth 2 (assq 'mm-size atts))
>
> What's the issue here? `(assq 'mm-size atts)` returns 0. For some reason, emacs can't seem to get my monitor size in milimeters. I have tried
> this on two different laptops, they both return proper values. This is happening on my desktop, where it fails.
>
> I am using Wayland (with Hyprland) and the PGTK version of emacs, which likely has something to do with this. This is what
> `frame-monitor-attributes` returns for me:
>
> ((name . "HDMI") (geometry 0 0 1920 1080) (workarea 0 0 1920 1080) (mm-size 0 0) (scale-factor . 1.0) (frames #<frame *scratch* - GNU Emacs at
> Rainbow 0x55799b79aa48> #<frame 0x55799d4561e0>) (source . "Gdk"))
>
> As you can see, the `mm-size` is 0, so emacs divides by zero. Amazingly, this is not what causes the error, the variable simply gets set to
> infinity. The error comes later, when it tries to multiply by infinity. Oh lord.
>
> This is what emacs outputs on my laptop for the same `frame-monitor-attributes`. Note that my laptop runs the exact same setup, it also runs
> Hyprland, it also runs emacs with PGTK, it uses the same config for everything since I have the same dotifles repo cloned in both systems:
>
> ((name . "0x0335") (geometry 0 0 1366 768) (workarea 0 0 1366 768) (mm-size 310 170) (scale-factor . 1.0) (frames #<frame *scratch* - GNU
> Emacs at T430 0x55c4c1cdad20> #<frame 0x55c4c356b7e0>) (source . "Gdk"))
>
> This time, the `mm-size` gets properly calculated.
>
> So something is funky with `frame-monitor-attributes`. Any direction on
> how I can further debug this would be appreciated.

On the contrary, something is funky with the EDID information from your
monitor, so the Wayland compositor is giving out faulty information.

What is the actual pixel resolution of the monitor connected to the
output named ``HDMI''? If it is indeed 72dpi (or something close), I
think tetris should just use `scale-factor' if available.

Thanks.