Re: Monitor attributes on Windows 11/WSL2
Eli Zaretskii <[email protected]> Sat, 01 Aug 2026 15:26:47 +0300
| Newsgroups | gmane.emacs.devel |
|---|---|
| Message-ID | <[email protected]> |
> Date: Sat, 1 Aug 2026 14:11:14 +0200 > Cc: [email protected], [email protected] > From: martin rudalics <[email protected]> > > > The code which uses mm-size in our code base seems to assume without > > checking that the value is non-zero. So I wonder how this particular > > platform violates the assumption that held since time immemoriam. > > Which code is responsible for asking X to provider these values, and > > why does it not work in this case? I tried to answer this question > > myself, but was surprised to see the relevant variables set only under > > one particular combination of toolkit and use of XRandr. I'm probably > > missing something. > > XRandr should not be involved here. The relevant code is > > #if GTK_CHECK_VERSION (3, 22, 0) > width_mm = gdk_monitor_get_width_mm (monitor); > height_mm = gdk_monitor_get_height_mm (monitor); > #else > width_mm = gdk_screen_get_monitor_width_mm (gscreen, i); > height_mm = gdk_screen_get_monitor_height_mm (gscreen, i); > if (width_mm < 0) > width_mm = rec.width * mm_width_per_pixel + 0.5; > if (height_mm < 0) > height_mm = rec.height * mm_height_per_pixel + 0.5; > #endif > > around line 6991 of xfns.c since the source reported by the OP is Gdk > (source . "Gdk"). But maybe xrandr can do better (unless the user is on > Wayland). > > > We don't officially support WSL, so we could just say that. But it > > would be nice to have a better understanding of what APIs fail us in > > this case. Can you perhaps point to the relevant code, so Arash could > > then try working with that user to find out what goes wrong? > > Either gdk_monitor_get_width_mm or gdk_screen_get_monitor_width_mm above > seem to return 0. Thanks. Arash, can that user walk through this code and tell what happens there?