[clutter-text] Fix x-position of cursor when moving up or down
authorNeil Roberts <neil@linux.intel.com>
Wed, 14 Jan 2009 11:12:02 +0000 (11:12 +0000)
committerNeil Roberts <neil@linux.intel.com>
Wed, 14 Jan 2009 11:12:02 +0000 (11:12 +0000)
commitffc15e0962a0b24afce1ff08eab13537fe23eadc
treebe388979f6be444c4b1ecb1bee3e3d544142237a
parentb57c7e12d43e7891ef3125dc03e396c5a24281aa
[clutter-text] Fix x-position of cursor when moving up or down

ClutterText already has code to try to preserve the x position when
moving up or down. A target x-position is stored and the cursor is
positioned at the nearest point to that in the appropriate line when
up or down is pressed. However the target position was never cleared
so it would always target the x-position of the cursor from the first
time you pressed up or down.

To fix this the patch clears the target position in set_position and
then sets it after the call in real_move_up/down. That way pressing
up or down sets the target position and any other movement will clear
it.

To get an index for the pixel position in the line
pango_layout_line_x_to_index is used. However when x is greater than
the length of the line then the index before the last grapheme is
returned which was causing it to jump to the penultimate
character. The patch makes it add on the trailing value so that it
will jump to the last character.
clutter/clutter-text.c