[gnome-shell] StContainer: Account for floating-point imprecision when sorting actors
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] StContainer: Account for floating-point imprecision when sorting actors
- Date: Tue, 15 Mar 2011 19:44:57 +0000 (UTC)
commit c0d0c792e120a879264360ed59e539fe2a31bad1
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Mon Mar 7 15:31:55 2011 -0500
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 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/st/st-container.c b/src/st/st-container.c
index 24430d0..403da55 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]