After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 778835 - Wrong screen size returned when in HiDPI mode
Wrong screen size returned when in HiDPI mode
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Win32
3.22.x
Other Windows
: Normal normal
: ---
Assigned To: gtk-win32 maintainers
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2017-02-17 14:03 UTC by Michail Crayson
Modified: 2017-02-19 10:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GDK W32: Apply HiDPI scale properly to monitors (5.89 KB, patch)
2017-02-17 16:04 UTC, LRN
committed Details | Review

Description Michail Crayson 2017-02-17 14:03:05 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.
Comment 1 LRN 2017-02-17 15:31:01 UTC
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.
Comment 2 LRN 2017-02-17 16:04:39 UTC
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.
Comment 3 LRN 2017-02-17 16:05:45 UTC
This might indeed be related to bug 778834. Also probably affected bug 778508.
Comment 4 Ignacio Casal Quinteiro (nacho) 2017-02-17 16:07:29 UTC
Review of attachment 346081 [details] [review]:

Makes sense and it makes the code even more readable
Comment 5 Andrew Chadwick 2017-02-17 23:43:35 UTC
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.
Comment 6 Andrew Chadwick 2017-02-18 22:55:18 UTC
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 7 LRN 2017-02-19 07:10:00 UTC
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
Comment 8 Michail Crayson 2017-02-19 10:25:22 UTC
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!