From c0d0c792e120a879264360ed59e539fe2a31bad1 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Mon, 7 Mar 2011 15:31:55 -0500 Subject: [PATCH] StContainer: Account for floating-point imprecision when sorting actors When we compare the boxes for two actors, they may appear to overlap by a small amount because of floating-point imprecision. Allow for up to 0.1 pixel overlap when determining what children are in the focus direction from the currently focused actor. https://bugzilla.gnome.org/show_bug.cgi?id=644134 --- src/st/st-container.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/st/st-container.c b/src/st/st-container.c index 24430d040..403da5573 100644 --- a/src/st/st-container.c +++ b/src/st/st-container.c @@ -445,33 +445,35 @@ filter_by_position (GList *children, clutter_actor_get_allocation_box (child, &cbox); /* Filter out children if they are in the wrong direction from - * @rbox, or if they don't overlap it. + * @rbox, or if they don't overlap it. To account for floating- + * point imprecision, an actor is "down" (etc.) from an another + * actor even if it overlaps it by up to 0.1 pixels. */ switch (direction) { case GTK_DIR_UP: - if (cbox.y2 > rbox->y1) + if (cbox.y2 > rbox->y1 + 0.1) continue; if (cbox.x1 >= rbox->x2 || cbox.x2 <= rbox->x1) continue; break; case GTK_DIR_DOWN: - if (cbox.y1 < rbox->y2) + if (cbox.y1 < rbox->y2 - 0.1) continue; if (cbox.x1 >= rbox->x2 || cbox.x2 <= rbox->x1) continue; break; case GTK_DIR_LEFT: - if (cbox.x2 > rbox->x1) + if (cbox.x2 > rbox->x1 + 0.1) continue; if (cbox.y1 >= rbox->y2 || cbox.y2 <= rbox->y1) continue; break; case GTK_DIR_RIGHT: - if (cbox.x1 < rbox->x2) + if (cbox.x1 < rbox->x2 - 0.1) continue; if (cbox.y1 >= rbox->y2 || cbox.y2 <= rbox->y1) continue;