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);