forked from AuroraMiddleware/gtk
Speed up gtk_widget_pick
Add early exits, and avoid as much work as possible.
This commit is contained in:
parent
82dc7b903c
commit
e8eb1df29f
@ -10476,6 +10476,25 @@ gtk_widget_contains (GtkWidget *widget,
|
||||
return GTK_WIDGET_GET_CLASS (widget)->contains (widget, x, y);
|
||||
}
|
||||
|
||||
/* do the checks for gtk_widget_pick that do not depend on position */
|
||||
static gboolean
|
||||
gtk_widget_can_be_picked (GtkWidget *widget,
|
||||
GtkPickFlags flags)
|
||||
{
|
||||
if (!_gtk_widget_is_drawable (widget))
|
||||
return FALSE;
|
||||
|
||||
if (!(flags & GTK_PICK_NON_TARGETABLE) &&
|
||||
!gtk_widget_get_can_target (widget))
|
||||
return FALSE;
|
||||
|
||||
if (!(flags & GTK_PICK_INSENSITIVE) &&
|
||||
!_gtk_widget_is_sensitive (widget))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_pick:
|
||||
* @widget: the widget to query
|
||||
@ -10507,38 +10526,19 @@ gtk_widget_pick (GtkWidget *widget,
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
GtkWidget *child;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
|
||||
if (!_gtk_widget_is_drawable (widget))
|
||||
return NULL;
|
||||
|
||||
if (!(flags & GTK_PICK_NON_TARGETABLE) &&
|
||||
!gtk_widget_get_can_target (widget))
|
||||
return NULL;
|
||||
|
||||
if (!(flags & GTK_PICK_INSENSITIVE) &&
|
||||
!_gtk_widget_is_sensitive (widget))
|
||||
return NULL;
|
||||
|
||||
switch (priv->overflow)
|
||||
{
|
||||
default:
|
||||
case GTK_OVERFLOW_VISIBLE:
|
||||
break;
|
||||
|
||||
case GTK_OVERFLOW_HIDDEN:
|
||||
{
|
||||
GtkCssBoxes boxes;
|
||||
|
||||
if (!gtk_widget_can_be_picked (widget, flags))
|
||||
return NULL;
|
||||
|
||||
if (priv->overflow == GTK_OVERFLOW_HIDDEN)
|
||||
{
|
||||
gtk_css_boxes_init (&boxes, widget);
|
||||
|
||||
if (!gsk_rounded_rect_contains_point (gtk_css_boxes_get_padding_box (&boxes),
|
||||
&GRAPHENE_POINT_INIT (x, y)))
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (GTK_IS_WINDOW (widget))
|
||||
{
|
||||
@ -10559,6 +10559,9 @@ gtk_widget_pick (GtkWidget *widget,
|
||||
GtkWidget *picked;
|
||||
graphene_point3d_t p0, p1, res;
|
||||
|
||||
if (!gtk_widget_can_be_picked (child, flags))
|
||||
continue;
|
||||
|
||||
if (GTK_IS_NATIVE (child))
|
||||
continue;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user