edje entry: return correct selection

Summary:
In entry, when selection_get function is called, selection is not
always returned the current selection.

Scenario:
- In select mode, entry has selection (e.g, by double click).
- When selection handler is moved, set the cursor the current coordinate
  with edje_object_part_text_cursor_pos_set() API.
- Edje emits "selection,changed" signal.
- Elementary gets current selection and stores it.
- Elementary does not get selection as visual selection (e.g, text is
   highlighted with "entry test", but the selection returned
   from edje is "entry").
- If we copy and then paste to the entry, the pasted text is not same as
   selected text.

Reason:
- In _edje_entry_cursor_coord_set function, if entry has selection, we only
  emit "selection,changed" signal without freeing en->selection.
- When _edje_entry_selection_get is called, we check the en->selection,
  since it is existed, we just return it which is not updated one.

This patch clears en->selection, so that it is updated at _selection_get,
and the updated selection is returned to caller.

@fix

Test Plan:
In mobile profile, open entry
- Right click, choose select, double click -> selection handlers are shown.
- Drag selection handlers to change selection.
- Right click, do copy.
- Right click, do paste.
- See the pasted text is not same as selection.

Reviewers: raster, tasn, herdsman

Subscribers: seoz, JackDanielZ, cedric

Differential Revision: https://phab.enlightenment.org/D2746
This commit is contained in:
Thiep Ha 2015-11-26 09:52:48 +02:00 committed by Daniel Hirt
parent 08e60f0873
commit 7693925227
1 changed files with 8 additions and 1 deletions

View File

@ -3856,7 +3856,14 @@ _edje_entry_cursor_coord_set(Edje_Real_Part *rp, Edje_Cursor cur,
(cur == EDJE_CURSOR_SELECTION_END))
{
if (en->have_selection)
_edje_emit(en->ed, "selection,changed", rp->part->name);
{
if (en->selection)
{
free(en->selection);
en->selection = NULL;
}
_edje_emit(en->ed, "selection,changed", rp->part->name);
}
}
return evas_textblock_cursor_char_coord_set(c, x, y);
}