summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2015-09-08 09:42:14 +0200
committerCarlos Soriano <csoriano@gnome.org>2015-09-08 11:13:16 +0200
commit7d96b11f195594c62d347c94e373f8d455c027f6 (patch)
treef61ebe73ba5fd6cdf33b9d74ea5a05a70d7311b9
parentaec064eec7b6d755c936e1b2ffcb19a657476b62 (diff)
downloadnautilus-7d96b11f195594c62d347c94e373f8d455c027f6.tar.gz
canvas-container: fix bounding box on different pixels per unit
We were returning the bounding box without taking care of the pixels per unit, so the clients of it were using the wrong bounding box calculation. For instance the rename popover was wrong calculated for the canvas view if the pixel per unit was different than 1. The bounding boxes are usually not calculated with pixels per unit adjustment, but is very convenient to have it here, so add a comment explaining it. https://bugzilla.gnome.org/show_bug.cgi?id=754620
-rw-r--r--libnautilus-private/nautilus-canvas-container.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/libnautilus-private/nautilus-canvas-container.c b/libnautilus-private/nautilus-canvas-container.c
index d40b77abb..042dd5886 100644
--- a/libnautilus-private/nautilus-canvas-container.c
+++ b/libnautilus-private/nautilus-canvas-container.c
@@ -6380,7 +6380,8 @@ nautilus_canvas_container_get_icon_locations (NautilusCanvasContainer *container
return result;
}
-/* Returns an array of GdkRectangles of the icons. */
+/* Returns an array of GdkRectangles of the icons. The bounding box is adjusted
+ * with the pixels_per_unit already, so they are the final positions on the canvas */
static GArray *
nautilus_canvas_container_get_icons_bounding_box (NautilusCanvasContainer *container,
GList *icons)
@@ -6396,11 +6397,11 @@ nautilus_canvas_container_get_icons_bounding_box (NautilusCanvasContainer *conta
for (index = 0, node = icons; node != NULL; index++, node = node->next) {
icon_get_bounding_box ((NautilusCanvasIcon *)node->data,
&x1, &y1, &x2, &y2,
- BOUNDS_USAGE_FOR_ENTIRE_ITEM);
- g_array_index (result, GdkRectangle, index).x = x1;
- g_array_index (result, GdkRectangle, index).width = x2 - x1;
- g_array_index (result, GdkRectangle, index).y = y1;
- g_array_index (result, GdkRectangle, index).height = y2 - y1;
+ BOUNDS_USAGE_FOR_DISPLAY);
+ g_array_index (result, GdkRectangle, index).x = x1 * EEL_CANVAS (container)->pixels_per_unit;
+ g_array_index (result, GdkRectangle, index).width = (x2 - x1) * EEL_CANVAS (container)->pixels_per_unit;
+ g_array_index (result, GdkRectangle, index).y = y1 * EEL_CANVAS (container)->pixels_per_unit;
+ g_array_index (result, GdkRectangle, index).height = (y2 - y1) * EEL_CANVAS (container)->pixels_per_unit;
}
return result;