diff options
author | Benjamin Otte <otte@redhat.com> | 2023-03-09 04:02:22 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2023-03-10 05:26:28 +0100 |
commit | 97e3c652518c66313c9e29dabed92e75b482fd1c (patch) | |
tree | 804aea465d6303db037f8ba62bf2c66b597e4432 /gtk/gtkgridview.c | |
parent | 334ca12d788bfbe53bfa16e1c74f7c78a2ad2032 (diff) | |
download | gtk+-97e3c652518c66313c9e29dabed92e75b482fd1c.tar.gz |
listview: Move bounds check into base class
This way, listview and gridview don't need to check if the rect is out
of bounds and nothing is selected, a quick rectangle_intersect() does
the job for them.
Diffstat (limited to 'gtk/gtkgridview.c')
-rw-r--r-- | gtk/gtkgridview.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/gtk/gtkgridview.c b/gtk/gtkgridview.c index 6abbfc55da..dcfd1edd68 100644 --- a/gtk/gtkgridview.c +++ b/gtk/gtkgridview.c @@ -378,22 +378,16 @@ gtk_grid_view_get_items_in_rect (GtkListBase *base, { GtkGridView *self = GTK_GRID_VIEW (base); guint first_row, last_row, first_column, last_column; - GdkRectangle bounds; GtkBitset *result; result = gtk_bitset_new_empty (); - /* limit rect to the region that actually overlaps items */ - gtk_list_item_manager_get_tile_bounds (self->item_manager, &bounds); - if (!gdk_rectangle_intersect (&bounds, rect, &bounds)) - return result; - - first_column = fmax (floor (bounds.x / self->column_width), 0); - last_column = fmin (floor ((bounds.x + bounds.width) / self->column_width), self->n_columns - 1); + first_column = fmax (floor (rect->x / self->column_width), 0); + last_column = fmin (floor ((rect->x + rect->width) / self->column_width), self->n_columns - 1); /* match y = 0 here because we care about the rows, not the cells */ - if (!gtk_grid_view_get_position_from_allocation (base, 0, bounds.y, &first_row, NULL)) + if (!gtk_grid_view_get_position_from_allocation (base, 0, rect->y, &first_row, NULL)) g_return_val_if_reached (result); - if (!gtk_grid_view_get_position_from_allocation (base, 0, bounds.y + bounds.height - 1, &last_row, NULL)) + if (!gtk_grid_view_get_position_from_allocation (base, 0, rect->y + rect->height - 1, &last_row, NULL)) g_return_val_if_reached (result); gtk_bitset_add_rectangle (result, |