summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Canvas.cpp10
-rw-r--r--src/canvas-base.c24
2 files changed, 19 insertions, 15 deletions
diff --git a/src/Canvas.cpp b/src/Canvas.cpp
index 5d4eb55..cbe8263 100644
--- a/src/Canvas.cpp
+++ b/src/Canvas.cpp
@@ -797,16 +797,8 @@ GanvCanvasImpl::layout_iteration()
// Update position
const Vector dpos = vec_mult(node->impl->vel, dur);
- if (fabs(dpos.x) > 1.0 || fabs(dpos.y) > 1.0) {
- GanvItem* item = GANV_ITEM(node);
+ if (fabs(dpos.x) >= 1.0 || fabs(dpos.y) >= 1.0) {
ganv_item_move(GANV_ITEM(node), dpos.x, dpos.y);
- static const float min_coord = 4.0;
- if (item->x < min_coord) {
- item->x = min_coord;
- }
- if (item->y < min_coord) {
- item->y = min_coord;
- }
}
}
diff --git a/src/canvas-base.c b/src/canvas-base.c
index a56da8e..b437581 100644
--- a/src/canvas-base.c
+++ b/src/canvas-base.c
@@ -427,11 +427,25 @@ ganv_item_move(GanvItem* item, double dx, double dy)
g_return_if_fail(item != NULL);
g_return_if_fail(GANV_IS_ITEM(item));
+ const double old_x = item->x;
+ const double old_y = item->y;
+
item->x += dx;
item->y += dy;
- ganv_item_request_update(item);
- item->canvas->need_repick = TRUE;
+ static const double MIN_COORD = 4.0;
+ if (item->x < MIN_COORD) {
+ item->x = MIN_COORD;
+ }
+ if (item->y < MIN_COORD) {
+ item->y = MIN_COORD;
+ }
+
+ if (lrint(old_x) != lrint(item->x) ||
+ lrint(old_y) != lrint(item->y)) {
+ ganv_item_request_update(item);
+ item->canvas->need_repick = TRUE;
+ }
}
/**
@@ -750,13 +764,11 @@ ganv_item_get_bounds(GanvItem* item, double* x1, double* y1, double* x2, double*
void
ganv_item_request_update(GanvItem* item)
{
- /* FIXME: For some reason, if this short-circuit is enabled, the canvas
- stops updating items entirely when connected modules are removed. */
- /*
+ /* Note: At some point, if this short-circuit was enabled, the canvas stopped
+ updating items entirely when connected modules are removed. */
if (item->object.flags & GANV_ITEM_NEED_UPDATE) {
return;
}
- */
if (!item->canvas) {
/* Item is being / has been destroyed, ignore */