summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2016-02-01 09:40:46 +0100
committerCarlos Soriano <csoriano@gnome.org>2016-02-01 10:03:27 +0100
commit9cce755ec90f8d75f711b8454aa7cb096a988ce8 (patch)
treeecf67ccce17225ec63768226eafec668a3b05f27
parent2b01cffe13a8315acfef0e6289dcdc81156ac051 (diff)
downloadnautilus-9cce755ec90f8d75f711b8454aa7cb096a988ce8.tar.gz
canvas-container: fix desktop snapping
To snap an icon to the closest grid cell, we were trying to round the x position with an offset of 0.5. However, cells are not normalized, so that 0.5 is actually doing little to round the position. This is making the icons to snap to the right closest cell once the user drags more the icon left to the current cell. The actual size of the cell is SNAP_SIZE_*, so to fix this use half of the SNAP_SIZE to "round" the number. https://bugzilla.gnome.org/show_bug.cgi?id=750446
-rw-r--r--libnautilus-private/nautilus-canvas-container.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libnautilus-private/nautilus-canvas-container.c b/libnautilus-private/nautilus-canvas-container.c
index 84e652361..e3d0bd79a 100644
--- a/libnautilus-private/nautilus-canvas-container.c
+++ b/libnautilus-private/nautilus-canvas-container.c
@@ -109,8 +109,8 @@
#define SNAP_HORIZONTAL(func,x) ((func ((double)((x) - DESKTOP_PAD_HORIZONTAL) / SNAP_SIZE_X) * SNAP_SIZE_X) + DESKTOP_PAD_HORIZONTAL)
#define SNAP_VERTICAL(func, y) ((func ((double)((y) - DESKTOP_PAD_VERTICAL) / SNAP_SIZE_Y) * SNAP_SIZE_Y) + DESKTOP_PAD_VERTICAL)
-#define SNAP_NEAREST_HORIZONTAL(x) SNAP_HORIZONTAL (floor, x + .5)
-#define SNAP_NEAREST_VERTICAL(y) SNAP_VERTICAL (floor, y + .5)
+#define SNAP_NEAREST_HORIZONTAL(x) SNAP_HORIZONTAL (floor, x + SNAP_SIZE_X / 2)
+#define SNAP_NEAREST_VERTICAL(y) SNAP_VERTICAL (floor, y + SNAP_SIZE_Y / 2)
#define SNAP_CEIL_HORIZONTAL(x) SNAP_HORIZONTAL (ceil, x)
#define SNAP_CEIL_VERTICAL(y) SNAP_VERTICAL (ceil, y)