[gtk/wip/matthiasc/css-values: 10/14] Speed up gtk_widget_pick
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/css-values: 10/14] Speed up gtk_widget_pick
- Date: Mon, 13 Jan 2020 15:16:33 +0000 (UTC)
commit 954098cf68899134c6ddcb4e784201f00eccd75b
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jan 12 19:36:53 2020 -0500
Speed up gtk_widget_pick
Add early exits, and avoid as much work as
possible.
gtk/gtkwidget.c | 47 +++++++++++++++++++++++++----------------------
1 file changed, 25 insertions(+), 22 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 76de31262a..6addb83171 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -10507,8 +10507,7 @@ 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);
+ GtkCssBoxes boxes;
if (!_gtk_widget_is_drawable (widget))
return NULL;
@@ -10521,30 +10520,26 @@ gtk_widget_pick (GtkWidget *widget,
!_gtk_widget_is_sensitive (widget))
return NULL;
- switch (priv->overflow)
- {
- default:
- case GTK_OVERFLOW_VISIBLE:
- break;
-
- case GTK_OVERFLOW_HIDDEN:
- {
- GtkCssBoxes boxes;
-
- gtk_css_boxes_init (&boxes, widget);
+ 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 (priv->overflow == GTK_OVERFLOW_HIDDEN)
+ {
+ if (!gsk_rounded_rect_contains_point (gtk_css_boxes_get_padding_box (&boxes),
+ &GRAPHENE_POINT_INIT (x, y)))
+ return NULL;
+ }
+ else
+ {
+ if (!gsk_rounded_rect_contains_point (gtk_css_boxes_get_border_box (&boxes),
+ &GRAPHENE_POINT_INIT (x, y)))
+ return NULL;
}
if (GTK_IS_WINDOW (widget))
{
GtkWidget *picked;
- picked = gtk_window_pick_popover (GTK_WINDOW (widget), x, y, flags);
+ picked = gtk_window_pick_popover ((GtkWindow *)widget, x, y, flags);
if (picked)
return picked;
}
@@ -10559,6 +10554,17 @@ gtk_widget_pick (GtkWidget *widget,
GtkWidget *picked;
graphene_point3d_t p0, p1, res;
+ if (!_gtk_widget_is_drawable (child))
+ continue;
+
+ if (!(flags & GTK_PICK_NON_TARGETABLE) &&
+ !gtk_widget_get_can_target (child))
+ continue;
+
+ if (!(flags & GTK_PICK_INSENSITIVE) &&
+ !_gtk_widget_is_sensitive (child))
+ continue;
+
if (GTK_IS_NATIVE (child))
continue;
@@ -10588,9 +10594,6 @@ gtk_widget_pick (GtkWidget *widget,
return picked;
}
- if (!gtk_widget_contains (widget, x, y))
- return NULL;
-
return widget;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]