gtkwidget: Make gtk_widget_event() Accept pointing events in root coordinates

This function will, at the last minute, ensure the event contains the right
widget-relative coordinates for the widget the event is being emitted to.
This commit is contained in:
Carlos Garnacho
2017-03-31 18:25:04 +02:00
parent 02932bc406
commit ef4f0e5336

View File

@@ -6981,6 +6981,26 @@ event_window_is_still_viewable (GdkEvent *event)
}
}
static void
translate_coordinates (GdkEvent *event,
GtkWidget *widget)
{
GtkWidget *event_widget;
gdouble xd, yd;
gint x, y;
if (!gdk_event_get_coords (event, &xd, &yd))
return;
event_widget = gtk_get_event_widget (event);
/* FIXME: loses precision */
x = xd;
y = yd;
gtk_widget_translate_coordinates (event_widget, widget,
x, y, &x, &y);
gdk_event_set_coords (event, x, y);
}
static gint
gtk_widget_event_internal (GtkWidget *widget,
GdkEvent *event)
@@ -6996,6 +7016,7 @@ gtk_widget_event_internal (GtkWidget *widget,
return TRUE;
g_object_ref (widget);
translate_coordinates (event_copy, widget);
if (widget == gtk_get_event_widget (event))
return_val |= _gtk_widget_run_controllers (widget, event, GTK_PHASE_TARGET);