gdk_monitor_get_*_mm returning 1 (possibly limited to NVidia and/or UltraWide displays)
Steps to reproduce
- Download the attached file, saving it as
dpi-check.c
. - In the target directory, compile by running:
gcc -Wno-deprecated-declarations -O0 -ggdb3 $(pkg-config --cflags gtk+-3.0) -o dpi-check dpi-check.c $(pkg-config --libs gtk+-3.0) -lm
- Run the program with
./dpi-check
.
Current behavior
gdk_monitor_get_width_mm
and gdk_monitor_get_height_mm
methods return a value of 1
, preventing the calculation of the monitor's DPI
Expected outcome
The actual value (if it can be determined) -- in my case 1626mm x 457mm -- else 0, the documented default.
Version information
mvastola@vastdesk:~/tmp$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
mvastola@vastdesk:~/tmp$ uname -a
Linux vastdesk.vasto.la 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
mvastola@vastdesk:~/tmp$ modinfo -Fversion nvidia
440.100
mvastola@vastdesk:~/tmp$ dpkg -l libgtk-3-0
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-================-================-============-====================================
ii libgtk-3-0:amd64 3.24.20-0ubuntu1 amd64 GTK graphical user interface library
## Additional information
```sh[dpi-check.c](/uploads/f23f4956c95f4a4691d840e1e4942eb0/dpi-check.c)
mvastola@vastdesk:~/tmp$ ./dpi-check
Gtk+ version: 3.24.20
Window Manager: X11
Screen:
1626 x 457 [mm x mm]
5120 x 1440 [px]
dp (pixels): 5318.646444
di (by mm): 66.496110
dpi (dp/di): 79.984325
Monitor: DP-4 [0]
1 x 1 [mm x mm]
5120 x 1440 [px]
dp (pixels): 5318.646444
di (by mm): 0.055678
dpi (dp/di): 95525.614575
See also evince#1403 (closed)