GTK3/4: use widget scale instead of screen scale

GTK+4 does not support the gdk_screen_get_monitor_scale_factor() API
(since gdk has become more backend independent.)

Use gtk_widget_get_scale_factor() API instead on the app top window.

TODO: This does not solve the multi-monitor problem, for that it would
be necessary to use the scale factor of the widget on which the action
is being peformed.
This commit is contained in:
Rafael Kitover
2017-12-11 02:54:58 -08:00
committed by paulcor
parent 21776b16f5
commit c2ef9ba275

View File

@@ -28,8 +28,8 @@
#include "wx/unix/utilsx11.h"
#ifdef __WXGTK3__
#include <gdk/gdk.h>
#include <gtk/gtk.h>
GtkWidget* wxGetTopLevelGTK();
#endif
// Normally we fall back on "plain X" implementation if XTest is not available,
@@ -256,15 +256,12 @@ bool wxUIActionSimulatorXTestImpl::DoX11MouseMove(long x, long y)
#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;
}
// 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 = gtk_widget_get_scale_factor(wxGetTopLevelGTK());
x *= scale;
y *= scale;
}
#endif // GTK+ 3.10+
#endif // __WXGTK3__