From 14afc3345aa2d679211a74dcfaa3bcf0bb9c20eb Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 10 Sep 2007 00:43:58 +0000 Subject: [PATCH] Add a bounding box test that will avoid getting the individual cell boxes 2007-09-09 Matthias Clasen * gtk/gtkiconview.c (gtk_icon_view_item_hit_test): Add a bounding box test that will avoid getting the individual cell boxes if they haven't been calculated yet. (#404541) svn path=/trunk/; revision=18775 --- ChangeLog | 6 ++++++ gtk/gtkiconview.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index c28011c4e..2fdfdac2d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-09-09 Matthias Clasen + + * gtk/gtkiconview.c (gtk_icon_view_item_hit_test): Add a + bounding box test that will avoid getting the individual cell + boxes if they haven't been calculated yet. (#404541) + 2007-09-09 Matthias Clasen * gtk/gtkaction.c: diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 7d9fcf455..f5e14e506 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -2284,6 +2284,10 @@ gtk_icon_view_item_hit_test (GtkIconView *icon_view, GList *l; GdkRectangle box; + if (MIN (x + width, item->x + item->width) - MAX (x, item->x) <= 0 || + MIN (y + height, item->y + item->height) - MAX (y, item->y) <= 0) + return FALSE; + for (l = icon_view->priv->cell_list; l; l = l->next) { GtkIconViewCellInfo *info = (GtkIconViewCellInfo *)l->data; @@ -2705,6 +2709,8 @@ gtk_icon_view_get_cell_area (GtkIconView *icon_view, GtkIconViewCellInfo *info, GdkRectangle *cell_area) { + g_return_if_fail (info->position < item->n_cells); + if (icon_view->priv->orientation == GTK_ORIENTATION_HORIZONTAL) { cell_area->x = item->box[info->position].x - item->before[info->position]; @@ -2729,6 +2735,8 @@ gtk_icon_view_get_cell_box (GtkIconView *icon_view, GtkIconViewCellInfo *info, GdkRectangle *box) { + g_return_if_fail (info->position < item->n_cells); + *box = item->box[info->position]; }