From 87f8a0e624e5aef18c1cf31fcf5e1fc9836ae40f Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Mon, 25 Jun 2012 11:17:03 +0000 Subject: [PATCH] handle selection loss cb's from elm now SVN revision: 72799 --- TODO | 3 --- src/bin/termio.c | 24 ++++++++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index a1df07bf..acca7084 100644 --- a/TODO +++ b/TODO @@ -5,9 +5,6 @@ make it a first-class terminal: [ ] blink and blink2 attributes need to be supported [ ] improve terminal emulation handling. known apps with problems: mc -[ ] elm_cnp has no way to call an event/cb to let you know your - selection has gone (selection_clear() doesnt do anything). also - elm_cnp doesn't track target object delections. [ ] dnd text (to/from terminal) [ ] handle multibyte displays better (does handle utf8 only atm and then maybe not according to convention like double cell spacing diff --git a/src/bin/termio.c b/src/bin/termio.c index 51203873..87792364 100644 --- a/src/bin/termio.c +++ b/src/bin/termio.c @@ -49,6 +49,7 @@ struct _Termio Config *config; Ecore_IMF_Context *imf; Eina_Bool jump_on_change : 1; + Eina_Bool have_sel : 1; }; static Evas_Smart *_smart = NULL; @@ -339,6 +340,20 @@ _smart_update_queue(Evas_Object *obj, Termio *sd) sd->anim = ecore_animator_add(_smart_cb_change, obj); } +static void +_lost_selection(void *data, Elm_Sel_Type selection) +{ + Termio *sd = evas_object_smart_data_get(data); + if (!sd) return; + if (sd->have_sel) + { + sd->cur.sel = 0; + elm_object_cnp_selection_clear(sd->win, selection); + _smart_update_queue(data, sd); + sd->have_sel = EINA_FALSE; + } +} + static void _take_selection(Evas_Object *obj, Elm_Sel_Type type) { @@ -362,8 +377,13 @@ _take_selection(Evas_Object *obj, Elm_Sel_Type type) if (s) { if (sd->win) - elm_cnp_selection_set(sd->win, type, - ELM_SEL_FORMAT_TEXT, s, strlen(s)); + { + sd->have_sel = EINA_FALSE; + elm_cnp_selection_set(sd->win, type, + ELM_SEL_FORMAT_TEXT, s, strlen(s)); + elm_cnp_selection_loss_callback_set(type, _lost_selection, obj); + sd->have_sel = EINA_TRUE; + } free(s); } }