summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2011-07-10 10:24:40 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2011-07-10 10:24:40 +0100
commit5d10a7141ca6557049aff1d4a513953f06fe0d54 (patch)
tree87daf8eb6d8080273b4e6891f886c85e02031854
parentf6cdeb985812e13174c85cf04bc4a782e2d1939d (diff)
downloadclutter-5d10a7141ca6557049aff1d4a513953f06fe0d54.tar.gz
text: Make sure that the selection box is big enough
Do not use integers to store the result of the PANGO_UNITS scaling to avoid rounding issues with the default C rules. We should use cielf() instead.
-rw-r--r--clutter/clutter-text.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c
index ea783ad91..4f8f97e57 100644
--- a/clutter/clutter-text.c
+++ b/clutter/clutter-text.c
@@ -1487,8 +1487,8 @@ clutter_text_foreach_selection_rectangle (ClutterText *self,
for (i = 0; i < n_ranges; i++)
{
- gint range_x;
- gint range_width;
+ gfloat range_x;
+ gfloat range_width;
range_x = ranges[i * 2] / PANGO_SCALE;
@@ -1497,11 +1497,11 @@ clutter_text_foreach_selection_rectangle (ClutterText *self,
range_x += priv->text_x;
- range_width = (ranges[i * 2 + 1] - ranges[i * 2])
- / PANGO_SCALE;
+ range_width = ((gfloat) ranges[i * 2 + 1] - (gfloat) ranges[i * 2])
+ / PANGO_SCALE;
box.x1 = range_x;
- box.x2 = range_x + range_width;
+ box.x2 = ceilf (range_x + range_width + .5f);
func (self, &box, user_data);
}
@@ -1513,9 +1513,9 @@ clutter_text_foreach_selection_rectangle (ClutterText *self,
}
static void
-clutter_text_add_selection_rectangle_to_path (ClutterText *text,
- const ClutterActorBox *box,
- gpointer user_data)
+add_selection_rectangle_to_path (ClutterText *text,
+ const ClutterActorBox *box,
+ gpointer user_data)
{
cogl_path_rectangle (user_data, box->x1, box->y1, box->x2, box->y2);
}
@@ -1578,10 +1578,9 @@ selection_paint (ClutterText *self)
color->blue,
paint_opacity * color->alpha / 255);
- clutter_text_foreach_selection_rectangle
- (self,
- clutter_text_add_selection_rectangle_to_path,
- selection_path);
+ clutter_text_foreach_selection_rectangle (self,
+ add_selection_rectangle_to_path,
+ selection_path);
cogl_path_fill (selection_path);
@@ -2051,9 +2050,9 @@ clutter_text_paint (ClutterActor *self)
}
static void
-clutter_text_add_selection_to_paint_volume_cb (ClutterText *text,
- const ClutterActorBox *box,
- gpointer user_data)
+add_selection_to_paint_volume (ClutterText *text,
+ const ClutterActorBox *box,
+ gpointer user_data)
{
ClutterPaintVolume *total_volume = user_data;
ClutterPaintVolume rect_volume;
@@ -2093,8 +2092,9 @@ clutter_text_get_paint_volume_for_cursor (ClutterText *text,
}
else
{
- clutter_text_foreach_selection_rectangle
- (text, clutter_text_add_selection_to_paint_volume_cb, volume);
+ clutter_text_foreach_selection_rectangle (text,
+ add_selection_to_paint_volume,
+ volume);
}
}