Commit f24dff79 authored by Gene Z. Ragan's avatar Gene Z. Ragan Committed by Gene Ragan
Browse files

reviewed by: John Harper <jsh@eazel.com>

2001-02-26  Gene Z. Ragan  <gzr@eazel.com>

	reviewed by: John Harper <jsh@eazel.com>

	Fixed bug 3898, selection in icon view extremely slow

	I increased the performance of drag selection of icons in a few ways.
	First, I avoid unneeded, repeated transforms of coordinates from
	world coordinates to canvas coordinates.  I also cached three freqeuently
	calculated dimensions; the icons bounds in canvas coordinates, the icons
	text bounds and canvas coordinates and the bounding rect of all emblems
	in canvas coordinates.  Instead of repeatedly calculating these values,
	have functions refer to the cached values.  In hit_test, I then do a
	quick intersection check of the drag rect with the cached values before
	proceeding to the more expensive intersection detection routines.

	* libnautilus-extensions/nautilus-icon-canvas-item.c:
	* libnautilus-extensions/nautilus-icon-canvas-item.h:
	(nautilus_icon_canvas_item_set_image), (compute_text_rectangle),
	(nautilus_icon_canvas_item_draw),
	(nautilus_icon_canvas_item_render),
	(nautilus_icon_canvas_item_bounds), (get_icon_canvas_rectangle),
	Set up the various places that we need to update our cached items.

	(nautilus_icon_canvas_item_update_bounds):
	Update our cached values.

	(hit_test), (hit_test_stretch_handle):
	Perform quick interesection checks before doing more expensive checks.

	(nautilus_icon_canvas_item_hit_test_rectangle):
	Change function to use canvas coordinates. The caller is responsible
	to do the conversion form world to canvas. This provides a large
	optimization if this routine is caled in a loop.

	* libnautilus-extensions/nautilus-icon-container.c:
	* libnautilus-extensions/nautilus-icon-container.h:
	(rubberband_select):
	Do transform of drag rect from world coordiantes to canvas canvas
	coordinates onlty once. There is no need to do this for every canvas
	item that is visted during list traversal.

	* libnautilus-extensions/nautilus-icon-dnd.c:
	(nautilus_icon_container_item_at):
	Call nautilus_icon_canvas_item_hit_test_rectangle() using coordinate
	converted to canvas coordinates.
parent 57a9d240
2001-02-26 Gene Z. Ragan <gzr@eazel.com>
reviewed by: John Harper <jsh@eazel.com>
Fixed bug 3898, selection in icon view extremely slow
I increased the performance of drag selection of icons in a few ways.
First, I avoid unneeded, repeated transforms of coordinates from
world coordinates to canvas coordinates. I also cached three freqeuently
calculated dimensions; the icons bounds in canvas coordinates, the icons
text bounds and canvas coordinates and the bounding rect of all emblems
in canvas coordinates. Instead of repeatedly calculating these values,
have functions refer to the cached values. In hit_test, I then do a
quick intersection check of the drag rect with the cached values before
proceeding to the more expensive intersection detection routines.
* libnautilus-extensions/nautilus-icon-canvas-item.c:
* libnautilus-extensions/nautilus-icon-canvas-item.h:
(nautilus_icon_canvas_item_set_image), (compute_text_rectangle),
(nautilus_icon_canvas_item_draw),
(nautilus_icon_canvas_item_render),
(nautilus_icon_canvas_item_bounds), (get_icon_canvas_rectangle),
Set up the various places that we need to update our cached items.
(nautilus_icon_canvas_item_update_bounds):
Update our cached values.
(hit_test), (hit_test_stretch_handle):
Perform quick interesection checks before doing more expensive checks.
(nautilus_icon_canvas_item_hit_test_rectangle):
Change function to use canvas coordinates. The caller is responsible
to do the conversion form world to canvas. This provides a large
optimization if this routine is caled in a loop.
* libnautilus-extensions/nautilus-icon-container.c:
* libnautilus-extensions/nautilus-icon-container.h:
(rubberband_select):
Do transform of drag rect from world coordiantes to canvas canvas
coordinates onlty once. There is no need to do this for every canvas
item that is visted during list traversal.
* libnautilus-extensions/nautilus-icon-dnd.c:
(nautilus_icon_container_item_at):
Call nautilus_icon_canvas_item_hit_test_rectangle() using coordinate
converted to canvas coordinates.
Mon Feb 26 03:00:03 2001 George Lebl <jirka@5z.com>
Gene Z. Ragan <gzr@eazel.com> was subjected to this patch and
......
......@@ -97,6 +97,11 @@ struct NautilusIconCanvasItemDetails {
/* Font stuff whilst in smooth mode */
guint smooth_font_size;
NautilusScalableFont *smooth_font;
/* Cached rectangle in canvas coordinates */
ArtIRect canvas_rect;
ArtIRect text_rect;
ArtIRect emblem_rect;
};
/* Object argument IDs. */
......@@ -520,8 +525,8 @@ nautilus_icon_canvas_item_set_image (NautilusIconCanvasItem *item,
}
details->pixbuf = image;
gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (item));
gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (item));
}
void
......@@ -599,11 +604,25 @@ recompute_bounding_box (NautilusIconCanvasItem *icon_item)
item->y2 = bottom_right.y;
}
static void
compute_text_rectangle (NautilusIconCanvasItem *item,
const ArtIRect *icon_rect,
ArtIRect *text_rect)
{
/* Compute text rectangle. */
text_rect->x0 = (icon_rect->x0 + icon_rect->x1) / 2 - item->details->text_width / 2;
text_rect->y0 = icon_rect->y1 + LABEL_OFFSET;
text_rect->x1 = text_rect->x0 + item->details->text_width;
text_rect->y1 = text_rect->y0 + item->details->text_height;
}
void
nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item)
{
ArtIRect before, after;
ArtIRect before, after, emblem_rect;
EmblemLayout emblem_layout;
GdkPixbuf *emblem_pixbuf;
/* Compute new bounds. */
nautilus_gnome_canvas_item_get_current_canvas_bounds
(GNOME_CANVAS_ITEM (item), &before);
......@@ -615,6 +634,20 @@ nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item)
if (nautilus_art_irect_equal (&before, &after)) {
return;
}
/* Update canvas and text rect cache */
get_icon_canvas_rectangle (item, &item->details->canvas_rect);
compute_text_rectangle (item, &item->details->canvas_rect, &item->details->text_rect);
/* Update emblem rect cache */
item->details->emblem_rect.x0 = 0;
item->details->emblem_rect.x1 = 0;
item->details->emblem_rect.y0 = 0;
item->details->emblem_rect.y1 = 0;
emblem_layout_reset (&emblem_layout, item, &item->details->canvas_rect);
while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect)) {
art_irect_union (&item->details->emblem_rect, &item->details->emblem_rect, &emblem_rect);
}
/* Send out the bounds_changed signal and queue a redraw. */
nautilus_gnome_canvas_request_redraw_rectangle
......@@ -1284,7 +1317,7 @@ nautilus_icon_canvas_item_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
}
/* Compute icon rectangle in drawable coordinates. */
get_icon_canvas_rectangle (icon_item, &icon_rect);
icon_rect = icon_item->details->canvas_rect;
icon_rect.x0 -= x;
icon_rect.y0 -= y;
icon_rect.x1 -= x;
......@@ -1649,8 +1682,8 @@ nautilus_icon_canvas_item_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf)
/* map the pixbuf for selection or other effects */
temp_pixbuf = map_pixbuf (icon_item);
get_icon_canvas_rectangle (icon_item, &icon_rect);
icon_rect = icon_item->details->canvas_rect;
if (buf->is_bg) {
gnome_canvas_buf_ensure_buf (buf);
buf->is_bg = FALSE;
......@@ -1741,18 +1774,6 @@ nautilus_icon_canvas_item_event (GnomeCanvasItem *item, GdkEvent *event)
}
}
static void
compute_text_rectangle (NautilusIconCanvasItem *item,
const ArtIRect *icon_rect,
ArtIRect *text_rect)
{
/* Compute text rectangle. */
text_rect->x0 = (icon_rect->x0 + icon_rect->x1) / 2 - item->details->text_width / 2;
text_rect->y0 = icon_rect->y1 + LABEL_OFFSET;
text_rect->x1 = text_rect->x0 + item->details->text_width;
text_rect->y1 = text_rect->y0 + item->details->text_height;
}
static gboolean
hit_test_pixbuf (GdkPixbuf *pixbuf, const ArtIRect *pixbuf_location, const ArtIRect *probe_rect)
{
......@@ -1803,11 +1824,18 @@ static gboolean
hit_test (NautilusIconCanvasItem *icon_item, const ArtIRect *canvas_rect)
{
NautilusIconCanvasItemDetails *details;
ArtIRect icon_rect, text_rect, emblem_rect;
ArtIRect emblem_rect;
EmblemLayout emblem_layout;
GdkPixbuf *emblem_pixbuf;
details = icon_item->details;
/* Quick check to see if the rect hits the icon, text or emblems at all. */
if (!nautilus_art_irect_hits_irect (&icon_item->details->canvas_rect, canvas_rect)
&& (!nautilus_art_irect_hits_irect (&details->text_rect, canvas_rect))
&& (!nautilus_art_irect_hits_irect (&details->emblem_rect, canvas_rect))) {
return FALSE;
}
/* Check for hits in the stretch handles. */
if (hit_test_stretch_handle (icon_item, canvas_rect)) {
......@@ -1815,32 +1843,30 @@ hit_test (NautilusIconCanvasItem *icon_item, const ArtIRect *canvas_rect)
}
/* Check for hit in the icon. If we're highlighted for dropping, anywhere in the rect is OK */
get_icon_canvas_rectangle (icon_item, &icon_rect);
if (icon_item->details->is_highlighted_for_drop) {
if (nautilus_art_irect_hits_irect (&icon_rect, canvas_rect)) {
if (nautilus_art_irect_hits_irect (&icon_item->details->canvas_rect, canvas_rect)) {
return TRUE;
}
} else {
if (hit_test_pixbuf (details->pixbuf, &icon_rect, canvas_rect)) {
if (hit_test_pixbuf (details->pixbuf, &icon_item->details->canvas_rect, canvas_rect)) {
return TRUE;
}
}
/* Check for hit in the text. */
compute_text_rectangle (icon_item, &icon_rect, &text_rect);
if (nautilus_art_irect_hits_irect (&text_rect, canvas_rect)
if (nautilus_art_irect_hits_irect (&details->text_rect, canvas_rect)
&& !icon_item->details->is_renaming) {
return TRUE;
}
/* Check for hit in the emblem pixbufs. */
emblem_layout_reset (&emblem_layout, icon_item, &icon_rect);
emblem_layout_reset (&emblem_layout, icon_item, &icon_item->details->canvas_rect);
while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect)) {
if (hit_test_pixbuf (emblem_pixbuf, &emblem_rect, canvas_rect)) {
return TRUE;
}
}
}
return FALSE;
}
......@@ -1877,7 +1903,7 @@ nautilus_icon_canvas_item_bounds (GnomeCanvasItem *item,
double pixels_per_unit;
EmblemLayout emblem_layout;
GdkPixbuf *emblem_pixbuf;
g_assert (x1 != NULL);
g_assert (y1 != NULL);
g_assert (x2 != NULL);
......@@ -1947,7 +1973,7 @@ nautilus_icon_canvas_item_get_icon_rectangle (NautilusIconCanvasItem *item,
}
/* Get the rectangle of the icon only, in canvas coordinates. */
void
static void
get_icon_canvas_rectangle (NautilusIconCanvasItem *item,
ArtIRect *rect)
{
......@@ -1957,7 +1983,7 @@ get_icon_canvas_rectangle (NautilusIconCanvasItem *item,
g_return_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item));
g_return_if_fail (rect != NULL);
gnome_canvas_item_i2c_affine (GNOME_CANVAS_ITEM (item), i2c);
art_point.x = 0;
......@@ -2019,7 +2045,7 @@ hit_test_stretch_handle (NautilusIconCanvasItem *item,
}
/* Quick check to see if the rect hits the icon at all. */
get_icon_canvas_rectangle (item, &icon_rect);
icon_rect = item->details->canvas_rect;
if (!nautilus_art_irect_hits_irect (probe_canvas_rect, &icon_rect)) {
return FALSE;
}
......@@ -2058,18 +2084,18 @@ nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanvasItem *item
return hit_test_stretch_handle (item, &canvas_rect);
}
/* nautilus_icon_canvas_item_hit_test_rectangle
*
* Check and see if there is an intersection between the item and the
* canvas rect.
*/
gboolean
nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanvasItem *item,
const ArtDRect *world_rect)
nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanvasItem *item, const ArtIRect *canvas_rect)
{
ArtIRect canvas_rect;
g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), FALSE);
g_return_val_if_fail (world_rect != NULL, FALSE);
g_return_val_if_fail (canvas_rect != NULL, FALSE);
nautilus_gnome_canvas_world_to_canvas_rectangle
(GNOME_CANVAS_ITEM (item)->canvas, world_rect, &canvas_rect);
return hit_test (item, &canvas_rect);
return hit_test (item, canvas_rect);
}
const char *
......
......@@ -83,7 +83,7 @@ void nautilus_icon_canvas_item_set_renaming (NautilusIconCanv
/* geometry and hit testing */
gboolean nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanvasItem *item,
const ArtDRect *world_rectangle);
const ArtIRect *canvas_rect);
gboolean nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanvasItem *item,
const ArtPoint *world_point);
void nautilus_icon_canvas_item_invalidate_label_size (NautilusIconCanvasItem *item);
......
......@@ -1359,24 +1359,33 @@ nautilus_icon_container_move_icon (NautilusIconContainer *container,
}
/* Implementation of rubberband selection. */
static void
rubberband_select (NautilusIconContainer *container,
const ArtDRect *previous_rect,
const ArtDRect *current_rect)
{
GList *p;
gboolean selection_changed, is_in;
gboolean selection_changed, is_in, canvas_rect_calculated;
NautilusIcon *icon;
ArtIRect canvas_rect;
selection_changed = FALSE;
canvas_rect_calculated = FALSE;
for (p = container->details->icons; p != NULL; p = p->next) {
icon = p->data;
is_in = nautilus_icon_canvas_item_hit_test_rectangle
(icon->item, current_rect);
if (!canvas_rect_calculated) {
/* Only do this calculation once, since all the canvas items
* we are interating are in the same coordinate space
*/
nautilus_gnome_canvas_world_to_canvas_rectangle
(GNOME_CANVAS_ITEM (icon->item)->canvas, current_rect, &canvas_rect);
canvas_rect_calculated = TRUE;
}
is_in = nautilus_icon_canvas_item_hit_test_rectangle (icon->item, &canvas_rect);
g_assert (icon->was_selected_before_rubberband == FALSE
|| icon->was_selected_before_rubberband == TRUE);
selection_changed |= icon_set_selected
......
......@@ -88,7 +88,7 @@ typedef struct {
int copy_action,
int x,
int y);
void (* create_nautilus_links) (NautilusIconContainer *container,
void (* create_nautilus_links) (NautilusIconContainer *container,
GList *item_uris,
int x,
int y);
......
......@@ -499,6 +499,7 @@ nautilus_icon_container_item_at (NautilusIconContainer *container,
GList *p;
int size;
ArtDRect point;
ArtIRect canvas_point;
/* build the hit-test rectangle. Base the size on the scale factor to ensure that it is
* non-empty even at the smallest scale factor
......@@ -513,12 +514,14 @@ nautilus_icon_container_item_at (NautilusIconContainer *container,
for (p = container->details->icons; p != NULL; p = p->next) {
NautilusIcon *icon;
icon = p->data;
if (nautilus_icon_canvas_item_hit_test_rectangle
(icon->item, &point)) {
nautilus_gnome_canvas_world_to_canvas_rectangle (GNOME_CANVAS_ITEM (icon->item)->canvas, &point, &canvas_point);
if (nautilus_icon_canvas_item_hit_test_rectangle (icon->item, &canvas_point)) {
return icon;
}
}
return NULL;
}
......
......@@ -97,6 +97,11 @@ struct NautilusIconCanvasItemDetails {
/* Font stuff whilst in smooth mode */
guint smooth_font_size;
NautilusScalableFont *smooth_font;
/* Cached rectangle in canvas coordinates */
ArtIRect canvas_rect;
ArtIRect text_rect;
ArtIRect emblem_rect;
};
/* Object argument IDs. */
......@@ -520,8 +525,8 @@ nautilus_icon_canvas_item_set_image (NautilusIconCanvasItem *item,
}
details->pixbuf = image;
gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (item));
gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (item));
}
void
......@@ -599,11 +604,25 @@ recompute_bounding_box (NautilusIconCanvasItem *icon_item)
item->y2 = bottom_right.y;
}
static void
compute_text_rectangle (NautilusIconCanvasItem *item,
const ArtIRect *icon_rect,
ArtIRect *text_rect)
{
/* Compute text rectangle. */
text_rect->x0 = (icon_rect->x0 + icon_rect->x1) / 2 - item->details->text_width / 2;
text_rect->y0 = icon_rect->y1 + LABEL_OFFSET;
text_rect->x1 = text_rect->x0 + item->details->text_width;
text_rect->y1 = text_rect->y0 + item->details->text_height;
}
void
nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item)
{
ArtIRect before, after;
ArtIRect before, after, emblem_rect;
EmblemLayout emblem_layout;
GdkPixbuf *emblem_pixbuf;
/* Compute new bounds. */
nautilus_gnome_canvas_item_get_current_canvas_bounds
(GNOME_CANVAS_ITEM (item), &before);
......@@ -615,6 +634,20 @@ nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item)
if (nautilus_art_irect_equal (&before, &after)) {
return;
}
/* Update canvas and text rect cache */
get_icon_canvas_rectangle (item, &item->details->canvas_rect);
compute_text_rectangle (item, &item->details->canvas_rect, &item->details->text_rect);
/* Update emblem rect cache */
item->details->emblem_rect.x0 = 0;
item->details->emblem_rect.x1 = 0;
item->details->emblem_rect.y0 = 0;
item->details->emblem_rect.y1 = 0;
emblem_layout_reset (&emblem_layout, item, &item->details->canvas_rect);
while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect)) {
art_irect_union (&item->details->emblem_rect, &item->details->emblem_rect, &emblem_rect);
}
/* Send out the bounds_changed signal and queue a redraw. */
nautilus_gnome_canvas_request_redraw_rectangle
......@@ -1284,7 +1317,7 @@ nautilus_icon_canvas_item_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
}
/* Compute icon rectangle in drawable coordinates. */
get_icon_canvas_rectangle (icon_item, &icon_rect);
icon_rect = icon_item->details->canvas_rect;
icon_rect.x0 -= x;
icon_rect.y0 -= y;
icon_rect.x1 -= x;
......@@ -1649,8 +1682,8 @@ nautilus_icon_canvas_item_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf)
/* map the pixbuf for selection or other effects */
temp_pixbuf = map_pixbuf (icon_item);
get_icon_canvas_rectangle (icon_item, &icon_rect);
icon_rect = icon_item->details->canvas_rect;
if (buf->is_bg) {
gnome_canvas_buf_ensure_buf (buf);
buf->is_bg = FALSE;
......@@ -1741,18 +1774,6 @@ nautilus_icon_canvas_item_event (GnomeCanvasItem *item, GdkEvent *event)
}
}
static void
compute_text_rectangle (NautilusIconCanvasItem *item,
const ArtIRect *icon_rect,
ArtIRect *text_rect)
{
/* Compute text rectangle. */
text_rect->x0 = (icon_rect->x0 + icon_rect->x1) / 2 - item->details->text_width / 2;
text_rect->y0 = icon_rect->y1 + LABEL_OFFSET;
text_rect->x1 = text_rect->x0 + item->details->text_width;
text_rect->y1 = text_rect->y0 + item->details->text_height;
}
static gboolean
hit_test_pixbuf (GdkPixbuf *pixbuf, const ArtIRect *pixbuf_location, const ArtIRect *probe_rect)
{
......@@ -1803,11 +1824,18 @@ static gboolean
hit_test (NautilusIconCanvasItem *icon_item, const ArtIRect *canvas_rect)
{
NautilusIconCanvasItemDetails *details;
ArtIRect icon_rect, text_rect, emblem_rect;
ArtIRect emblem_rect;
EmblemLayout emblem_layout;
GdkPixbuf *emblem_pixbuf;
details = icon_item->details;
/* Quick check to see if the rect hits the icon, text or emblems at all. */
if (!nautilus_art_irect_hits_irect (&icon_item->details->canvas_rect, canvas_rect)
&& (!nautilus_art_irect_hits_irect (&details->text_rect, canvas_rect))
&& (!nautilus_art_irect_hits_irect (&details->emblem_rect, canvas_rect))) {
return FALSE;
}
/* Check for hits in the stretch handles. */
if (hit_test_stretch_handle (icon_item, canvas_rect)) {
......@@ -1815,32 +1843,30 @@ hit_test (NautilusIconCanvasItem *icon_item, const ArtIRect *canvas_rect)
}
/* Check for hit in the icon. If we're highlighted for dropping, anywhere in the rect is OK */
get_icon_canvas_rectangle (icon_item, &icon_rect);
if (icon_item->details->is_highlighted_for_drop) {
if (nautilus_art_irect_hits_irect (&icon_rect, canvas_rect)) {
if (nautilus_art_irect_hits_irect (&icon_item->details->canvas_rect, canvas_rect)) {
return TRUE;
}
} else {
if (hit_test_pixbuf (details->pixbuf, &icon_rect, canvas_rect)) {
if (hit_test_pixbuf (details->pixbuf, &icon_item->details->canvas_rect, canvas_rect)) {
return TRUE;
}
}
/* Check for hit in the text. */
compute_text_rectangle (icon_item, &icon_rect, &text_rect);
if (nautilus_art_irect_hits_irect (&text_rect, canvas_rect)
if (nautilus_art_irect_hits_irect (&details->text_rect, canvas_rect)
&& !icon_item->details->is_renaming) {
return TRUE;
}
/* Check for hit in the emblem pixbufs. */
emblem_layout_reset (&emblem_layout, icon_item, &icon_rect);
emblem_layout_reset (&emblem_layout, icon_item, &icon_item->details->canvas_rect);
while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect)) {
if (hit_test_pixbuf (emblem_pixbuf, &emblem_rect, canvas_rect)) {
return TRUE;
}
}
}
return FALSE;
}
......@@ -1877,7 +1903,7 @@ nautilus_icon_canvas_item_bounds (GnomeCanvasItem *item,
double pixels_per_unit;
EmblemLayout emblem_layout;
GdkPixbuf *emblem_pixbuf;
g_assert (x1 != NULL);
g_assert (y1 != NULL);
g_assert (x2 != NULL);
......@@ -1947,7 +1973,7 @@ nautilus_icon_canvas_item_get_icon_rectangle (NautilusIconCanvasItem *item,
}
/* Get the rectangle of the icon only, in canvas coordinates. */
void
static void
get_icon_canvas_rectangle (NautilusIconCanvasItem *item,
ArtIRect *rect)
{
......@@ -1957,7 +1983,7 @@ get_icon_canvas_rectangle (NautilusIconCanvasItem *item,
g_return_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item));
g_return_if_fail (rect != NULL);
gnome_canvas_item_i2c_affine (GNOME_CANVAS_ITEM (item), i2c);
art_point.x = 0;
......@@ -2019,7 +2045,7 @@ hit_test_stretch_handle (NautilusIconCanvasItem *item,
}
/* Quick check to see if the rect hits the icon at all. */
get_icon_canvas_rectangle (item, &icon_rect);
icon_rect = item->details->canvas_rect;
if (!nautilus_art_irect_hits_irect (probe_canvas_rect, &icon_rect)) {
return FALSE;
}
......@@ -2058,18 +2084,18 @@ nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanvasItem *item
return hit_test_stretch_handle (item, &canvas_rect);
}
/* nautilus_icon_canvas_item_hit_test_rectangle
*
* Check and see if there is an intersection between the item and the
* canvas rect.
*/
gboolean
nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanvasItem *item,
const ArtDRect *world_rect)
nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanvasItem *item, const ArtIRect *canvas_rect)
{
ArtIRect canvas_rect;
g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), FALSE);
g_return_val_if_fail (world_rect != NULL, FALSE);
g_return_val_if_fail (canvas_rect != NULL, FALSE);
nautilus_gnome_canvas_world_to_canvas_rectangle
(GNOME_CANVAS_ITEM (item)->canvas, world_rect, &canvas_rect);
return hit_test (item, &canvas_rect);
return hit_test (item, canvas_rect);
}
const char *
......
......@@ -83,7 +83,7 @@ void nautilus_icon_canvas_item_set_renaming (NautilusIconCanv
/* geometry and hit testing */
gboolean nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanvasItem *item,
const ArtDRect *world_rectangle);
const ArtIRect *canvas_rect);
gboolean nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanvasItem *item,
const ArtPoint *world_point);
void nautilus_icon_canvas_item_invalidate_label_size (NautilusIconCanvasItem *item);
......
......@@ -1359,24 +1359,33 @@ nautilus_icon_container_move_icon (NautilusIconContainer *container,