diff --git a/src/unix/uiactionx11.cpp b/src/unix/uiactionx11.cpp index 56af15ebef..4bf33c93b0 100644 --- a/src/unix/uiactionx11.cpp +++ b/src/unix/uiactionx11.cpp @@ -27,6 +27,11 @@ #include "wx/unix/utilsx11.h" +#ifdef __WXGTK3__ +#include +#include +#endif + // Normally we fall back on "plain X" implementation if XTest is not available, // but it's useless to do it when using GTK+ 3 as it's not going to work with // it anyhow because GTK+ 3 needs XInput2 events and not the "classic" ones we @@ -239,6 +244,27 @@ bool wxUIActionSimulatorXTestImpl::DoX11Button(int xbutton, bool isDown) bool wxUIActionSimulatorXTestImpl::DoX11MouseMove(long x, long y) { +#ifdef __WXGTK3__ + // We need to take into account the scaling factor as the input coordinates + // are in GTK logical "application pixels", while we need the physical + // "device pixels" for the X call below, so scale them if we have the + // required support at both compile- and run-time. +#if GTK_CHECK_VERSION(3,10,0) + if ( gtk_check_version(3, 10, 0) == NULL ) + { + if ( GdkScreen* const screen = gdk_screen_get_default() ) + { + // For multi-monitor support we would need to determine to which + // monitor the point (x, y) belongs, for now just use the scale + // factor of the main one. + gint const scale = gdk_screen_get_monitor_scale_factor(screen, 0); + x *= scale; + y *= scale; + } + } +#endif // GTK+ 3.10+ +#endif // __WXGTK3__ + return XTestFakeMotionEvent(m_display, -1, x, y, 0) != 0; }