GNOME Bugzilla – Bug 778835
Wrong screen size returned when in HiDPI mode
Last modified: 2017-02-19 10:25:22 UTC
On Linux running GTK 3.22.7 (Debian Stretch) the following two functions return the screen size in application pixels: gdk_screen_get_width() gdk_screen_get_height() On Windows running GTK 3.22.7 (from MSYS2) they return the screen size in device pixels - not taking the scale factor into account.
Right now my working theory is that commit 4add92a4, which added HiDPI scaling code for W32 GdkMonitor backend, did it too late. As a result, all monitors got their geometry in device pixels, not application pixels. The code intended for it to happen otherwise, but scale was always 1 at that point.
Created attachment 346081 [details] [review] GDK W32: Apply HiDPI scale properly to monitors Previously HiDPI scale was retrieved and applied too late in the initialization process to affect monitor size and monitor workarea size, but the code that initializes these sizes *did* try to use the scale, even though it was always getting scale=1. To fix this, move the too-late code into monitor enumeration routine. This also fixes a probable semantic bug where width and height were divided by scale, again. Now monitor and workarea should be in application pixels (i.e. divided by scale), as intended.
This might indeed be related to bug 778834. Also probably affected bug 778508.
Review of attachment 346081 [details] [review]: Makes sense and it makes the code even more readable
Temporary gtk3-git builds of gtk-3-22 (d825c34ca3) plus attachment 346081 [details] [review] for current MSYS2, as promised in bug 778508. They're good for two months according to filebin. https://filebin.net/8wf4l3dl4nbdblu9 To install (from a flash stick, for example...): $ pacman -U /e/mingw-w64-*-gtk3-git-3.22.8.14.gd825c34ca3_patch346081-1-any.pkg.tar.xz To revert to a stock MSYS2 GTK3 installation (to allow future upgrades to work): $ pacman -S mingw-w64-{x86_64,i686}-gtk3 Git packages are marked as conflicting with non-git ones, so you will be asked several times during installation whether you want to proceed. Enter "y" each time.
Review of attachment 346081 [details] [review]: Testing in MSYS2 seems good so far: - bug 778508 comment 15 - bug 778508 comment 17 Do we need any more testing/review before this can be merged?
Comment on attachment 346081 [details] [review] GDK W32: Apply HiDPI scale properly to monitors attachment 346081 [details] [review] pushed into gtk-3-22 branch as commit 1d0fad3d706ff81b841548ed2ad2ec0de513ab80
I have now tested the build from comment 5 and can confirm that it is now working as expected on my Windows 10 machine. Super-fast fix :) I'm impressed!