viewport: Implement clipping for picking

This is necessary because picking is no longer automatically constrained
to a widget's box. So all clipping widgets need to constrain their
clipping, too.

This patch does that for GtkViewport only.
This commit is contained in:
Benjamin Otte 2017-11-05 07:17:36 +01:00
parent b3f69c130e
commit 73077c4e90

View File

@ -198,6 +198,25 @@ viewport_set_adjustment_values (GtkViewport *viewport,
viewport_size);
}
static GtkWidget *
gtk_viewport_pick (GtkWidget *widget,
double x,
double y)
{
if (x >= 0 && x <= gtk_widget_get_width (widget) &&
y >= 0 && y <= gtk_widget_get_height(widget))
{
return GTK_WIDGET_CLASS (gtk_viewport_parent_class)->pick (widget, x, y);
}
else
{
if (gtk_widget_contains (widget, x, y))
return widget;
else
return NULL;
}
}
static void
gtk_viewport_measure (GtkWidget *widget,
GtkOrientation orientation,
@ -236,6 +255,7 @@ gtk_viewport_class_init (GtkViewportClass *class)
widget_class->snapshot = gtk_viewport_snapshot;
widget_class->size_allocate = gtk_viewport_size_allocate;
widget_class->measure = gtk_viewport_measure;
widget_class->pick = gtk_viewport_pick;
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_VIEWPORT);