[gtk/pick-insensitive: 1/4] widget: Change definition of gtk_widget_contains



commit ca07a41f1cc734b77f6bb4d804b5bfc7000eccac
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Apr 7 12:35:15 2019 +0000

    widget: Change definition of gtk_widget_contains
    
    Make this function just about location, leave out
    reactiveness.
    
    Drop the vfunc. We can decide this purely with the
    information we have, no need to call out to application code.
    
    Take the rounded rectangle into account for determining
    the answer.

 gtk/gtkwidget.c | 30 +++++-------------------------
 gtk/gtkwidget.h |  4 ----
 2 files changed, 5 insertions(+), 29 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index ed0a21f5a7..95cad7c640 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -815,20 +815,6 @@ gtk_widget_real_snapshot (GtkWidget   *widget,
     gtk_widget_snapshot_child (widget, child, snapshot);
 }
 
-static gboolean
-gtk_widget_real_contains (GtkWidget *widget,
-                          gdouble    x,
-                          gdouble    y)
-{
-  GtkCssBoxes boxes;
-
-  gtk_css_boxes_init (&boxes, widget);
-
-  /* XXX: This misses rounded rects */
-  return graphene_rect_contains_point (gtk_css_boxes_get_border_rect (&boxes),
-                                       &(graphene_point_t){x, y});
-}
-
 static GtkWidget *
 gtk_widget_real_pick (GtkWidget *widget,
                       gdouble    x,
@@ -982,7 +968,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   klass->priv->accessible_role = ATK_ROLE_INVALID;
   klass->get_accessible = gtk_widget_real_get_accessible;
 
-  klass->contains = gtk_widget_real_contains;
   klass->pick = gtk_widget_real_pick;
 
   widget_props[PROP_NAME] =
@@ -11042,11 +11027,6 @@ gtk_widget_get_allocation (GtkWidget     *widget,
  * The coordinates for (@x, @y) must be in widget coordinates, so
  * (0, 0) is assumed to be the top left of @widget's content area.
  *
- * Pass-through widgets and insensitive widgets do never respond to
- * input and will therefor always return %FALSE here. See
- * gtk_widget_set_can_pick() and gtk_widget_set_sensitive() for
- * details about those functions.
- *
  * Returns: %TRUE if @widget contains (@x, @y).
  **/
 gboolean
@@ -11054,14 +11034,14 @@ gtk_widget_contains (GtkWidget  *widget,
                      gdouble     x,
                      gdouble     y)
 {
+  GtkCssBoxes boxes;
+
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  if (!gtk_widget_get_can_pick (widget) ||
-      !_gtk_widget_is_sensitive (widget) ||
-      !_gtk_widget_is_drawable (widget))
-    return FALSE;
+  gtk_css_boxes_init (&boxes, widget);
 
-  return GTK_WIDGET_GET_CLASS (widget)->contains (widget, x, y);
+  return gsk_rounded_rect_contains_point (gtk_css_boxes_get_border_box (&boxes),
+                                          &GRAPHENE_POINT_INIT (x, y));
 }
 
 /**
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 8ff503a400..4cc1161121 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -222,7 +222,6 @@ struct _GtkWidget
  * @style_updated: Signal emitted when the GtkStyleContext of a widget
  *   is changed.
  * @snapshot: Vfunc for gtk_widget_snapshot().
- * @contains: Vfunc for gtk_widget_contains().
  * @pick: Vfunc for gtk_widget_pick().
  */
 struct _GtkWidgetClass
@@ -336,9 +335,6 @@ struct _GtkWidgetClass
   void         (* snapshot)                    (GtkWidget            *widget,
                                                 GtkSnapshot          *snapshot);
 
-  gboolean     (* contains)                    (GtkWidget *widget,
-                                                gdouble    x,
-                                                gdouble    y);
   GtkWidget *  (* pick)                        (GtkWidget *widget,
                                                 gdouble    x,
                                                 gdouble    y);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]