From 91919f4514dcfb9839a13ffedc8c43ba8011757a Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Wed, 25 Apr 2018 09:19:18 -0700 Subject: [PATCH] Fix saving/restoring TLW position on HiDPI X11 display with GTK+3 X11 frame extents need to be converted to GTK+ "logical" units --- src/gtk/toplevel.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index ae825d4039..97afe66757 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -470,7 +470,7 @@ bool wxGetFrameExtents(GdkWindow* window, int* left, int* right, int* top, int* Atom type; int format; gulong nitems, bytes_after; - guchar* data; + guchar* data = NULL; Status status = XGetWindowProperty( GDK_DISPLAY_XDISPLAY(display), GDK_WINDOW_XID(window), @@ -480,11 +480,17 @@ bool wxGetFrameExtents(GdkWindow* window, int* left, int* right, int* top, int* const bool success = status == Success && data && nitems == 4; if (success) { + // We need to convert the X11 physical extents to GTK+ "logical" units + int scale = 1; +#if GTK_CHECK_VERSION(3,10,0) + if (wx_is_at_least_gtk3(10)) + scale = gdk_window_get_scale_factor(window); +#endif long* p = (long*)data; - if (left) *left = int(p[0]); - if (right) *right = int(p[1]); - if (top) *top = int(p[2]); - if (bottom) *bottom = int(p[3]); + if (left) *left = int(p[0]) / scale; + if (right) *right = int(p[1]) / scale; + if (top) *top = int(p[2]) / scale; + if (bottom) *bottom = int(p[3]) / scale; } if (data) XFree(data);