diff options
author | Timm Bäder <mail@baedert.org> | 2019-02-14 07:11:34 +0100 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2019-02-16 15:45:06 +0100 |
commit | c9d9f8b750dc9672c8bc899b0ba3b6f87d918e1e (patch) | |
tree | 71b20981b38dcfb03092d5492da8061637bf024c /gtk/gtkflowbox.c | |
parent | ca2c05cdb371e4756444a4428f42825c73b2cced (diff) | |
download | gtk+-c9d9f8b750dc9672c8bc899b0ba3b6f87d918e1e.tar.gz |
flowbox: Implement get_child_at_pos properly
With transforms in the mix, checking if the coordinate is inside the
widget "allocation" makes even less sense. Just use gtk_widget_pick()
and walk up until we find a GtkFlowBoxChild.
Diffstat (limited to 'gtk/gtkflowbox.c')
-rw-r--r-- | gtk/gtkflowbox.c | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c index f95d8734e1..65c491fe4b 100644 --- a/gtk/gtkflowbox.c +++ b/gtk/gtkflowbox.c @@ -3918,7 +3918,7 @@ gtk_flow_box_get_child_at_index (GtkFlowBox *box, * @y: the y coordinate of the child * * Gets the child in the (@x, @y) position. Both @x and @y are - * assumed to be relative to the allocation of @box. + * assumed to be relative to the origin of @box. * * Returns: (transfer none) (nullable): the child widget, which will * always be a #GtkFlowBoxChild or %NULL in case no child widget @@ -3929,24 +3929,12 @@ gtk_flow_box_get_child_at_pos (GtkFlowBox *box, gint x, gint y) { - GtkWidget *child; - GSequenceIter *iter; - GtkAllocation allocation; - - for (iter = g_sequence_get_begin_iter (BOX_PRIV (box)->children); - !g_sequence_iter_is_end (iter); - iter = g_sequence_iter_next (iter)) - { - child = g_sequence_get (iter); - if (!child_is_visible (child)) - continue; + GtkWidget *child = gtk_widget_pick (GTK_WIDGET (box), x, y); - gtk_widget_get_allocation (child, &allocation); - if (gdk_rectangle_contains_point (&allocation, x, y)) - return GTK_FLOW_BOX_CHILD (child); - } + if (!child) + return NULL; - return NULL; + return (GtkFlowBoxChild *)gtk_widget_get_ancestor (child, GTK_TYPE_FLOW_BOX_CHILD); } /** |