summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2017-05-10 12:11:58 +0200
committerCarlos Garnacho <carlosg@gnome.org>2017-05-25 16:25:59 +0200
commit2ad2ecad4492d09151ed68afce4ab88e8a6ce83a (patch)
tree163203a9e681ccb6cb9a194f740c3fe0ecebcf04
parentdd836fff353fa0d3be4d92c94aeca262b9c2c1e2 (diff)
downloadgtk+-2ad2ecad4492d09151ed68afce4ab88e8a6ce83a.tar.gz
flowbox: Fix child item selection
-rw-r--r--gtk/gtkflowbox.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c
index 02440b27ac..bc7d610036 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -4136,7 +4136,8 @@ gtk_flow_box_get_child_at_index (GtkFlowBox *box,
* @x: the x coordinate of the child
* @y: the y coordinate of the child
*
- * Gets the child in the (@x, @y) position.
+ * Gets the child in the (@x, @y) position. Both @x and @y are
+ * assumed to be relative to the allocation of @box.
*
* Returns: (transfer none) (nullable): the child widget, which will
* always be a #GtkFlowBoxChild or %NULL in case no child widget
@@ -4152,6 +4153,9 @@ gtk_flow_box_get_child_at_pos (GtkFlowBox *box,
GtkWidget *child;
GSequenceIter *iter;
GtkAllocation allocation;
+ GtkAllocation box_allocation;
+
+ gtk_widget_get_allocation (GTK_WIDGET (box), &box_allocation);
for (iter = g_sequence_get_begin_iter (BOX_PRIV (box)->children);
!g_sequence_iter_is_end (iter);
@@ -4160,7 +4164,10 @@ gtk_flow_box_get_child_at_pos (GtkFlowBox *box,
child = g_sequence_get (iter);
if (!child_is_visible (child))
continue;
+
gtk_widget_get_allocation (child, &allocation);
+ allocation.x -= box_allocation.x;
+ allocation.y -= box_allocation.y;
if (x >= allocation.x && x < (allocation.x + allocation.width) &&
y >= allocation.y && y < (allocation.y + allocation.height))
return GTK_FLOW_BOX_CHILD (child);