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 788053 - Window position wrong in HiDPI mode
Window position wrong 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-09-22 16:30 UTC by Michail Crayson
Modified: 2017-10-08 19:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GDK W32: Correctly report window position in HiDPI mode (2.28 KB, patch)
2017-09-29 12:52 UTC, LRN
committed Details | Review

Description Michail Crayson 2017-09-22 16:30:04 UTC
This happens when in HiDPI mode.

Calling gtk_window_move() and then immediately calling gtk_window_get_position() gives an inconsistent result. This also means that you cannot use the result from gtk_window_get_position() to position a window with gtk_window_move().

Example code:

gtk_window_move( window, 100, 100 );
gtk_window_get_position( window, &x, &y );
printf( "moved to 100, 100: %d, %d\n", x, y );

Results in this when in HiDPI mode (2x scale):
moved to 100, 100: 174, 177

When in normal 100% scale:
moved to 100, 100: 100, 100
Comment 1 LRN 2017-09-22 17:41:25 UTC
I'll wait for fanc to comment on this, as he actually has a HiDPI hardware to debug this, and did a lot of HiDPI hacking on W32 backend in the past.

Meanwhile you can also tell us which version of GTK+ you're using (specifically, which revision of 3.22.x).
Comment 2 Michail Crayson 2017-09-22 19:51:54 UTC
Sure. This is with 3.22.19 from the MSYS2 repo. I'm running Windows 10 in a virtual machine with the display scale (in Windows) set to 200%.
Comment 3 Michail Crayson 2017-09-22 19:56:22 UTC
I've now tested it on a Surface Pro with scale 200% and got the same behaviour.
Comment 4 LRN 2017-09-29 12:52:56 UTC
Created attachment 360661 [details] [review]
GDK W32: Correctly report window position in HiDPI mode

Does this patch fix the problem for you?
Comment 5 Fan, Chun-wei 2017-09-30 02:28:53 UTC
Review of attachment 360661 [details] [review]:

Hi LRN,

Please go ahead to push this.  I was clearly at fault.

With blessings, thank you!

::: gdk/win32/gdkwindow-win32.c
@@ +2394,3 @@
+  rect->y = r.top + _gdk_offset_y * impl->window_scale;
+  rect->width = (r.right - r.left);
+  rect->height = (r.bottom - r.top);

Ugh, oops :|.  This was clearly my fault.
Comment 6 LRN 2017-10-08 19:50:55 UTC
Attachment 360661 [details] pushed as 8dfce0e - GDK W32: Correctly report window position in HiDPI mode