GNOME Bugzilla – Bug 788053
Window position wrong in HiDPI mode
Last modified: 2017-10-08 19:51:00 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().
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
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).
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%.
I've now tested it on a Surface Pro with scale 200% and got the same behaviour.
Created attachment 360661 [details] [review]
GDK W32: Correctly report window position in HiDPI mode
Does this patch fix the problem for you?
Review of attachment 360661 [details] [review]:
Please go ahead to push this. I was clearly at fault.
With blessings, thank you!
@@ +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.
Attachment 360661 [details] pushed as 8dfce0e - GDK W32: Correctly report window position in HiDPI mode