Reuse ecore_imf_context when theme is changed 56/64856/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Sat, 31 Jan 2015 12:17:16 +0000 (21:17 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 6 Apr 2016 00:01:58 +0000 (09:01 +0900)
Change-Id: Ie0374f9e3839a5da1527a0eab381f4d4dc632c9c

src/lib/edje/edje_entry.c
src/lib/edje/edje_load.c
src/lib/edje/edje_main.c
src/lib/edje/edje_private.h
src/lib/edje/edje_smart.c

index 77b1927..77f5408 100644 (file)
@@ -2669,7 +2669,7 @@ _edje_entry_shutdown(Edje *ed)
 }
 
 void
-_edje_entry_real_part_init(Edje *ed, Edje_Real_Part *rp)
+_edje_entry_real_part_init(Edje *ed, Edje_Real_Part *rp, Ecore_IMF_Context *ic)
 {
    Entry *en;
 #ifdef HAVE_ECORE_IMF
@@ -2753,28 +2753,35 @@ _edje_entry_real_part_init(Edje *ed, Edje_Real_Part *rp)
         edje_object_signal_callback_add(ed->obj, "focus,part,in", rp->part->name, _edje_entry_focus_in_cb, rp);
         edje_object_signal_callback_add(ed->obj, "focus,part,out", rp->part->name, _edje_entry_focus_out_cb, rp);
 
-        ctx_id = ecore_imf_context_default_id_get();
-        if (ctx_id)
+        // TIZEN_ONLY(20131129): Reuse ecore_imf_context when theme is changed
+
+        if (ic)
+          en->imf_context = ic;
+        else
           {
-             ctx_info = ecore_imf_context_info_by_id_get(ctx_id);
-             if (!ctx_info->canvas_type ||
-                 strcmp(ctx_info->canvas_type, "evas") == 0)
-               {
-                  en->imf_context = ecore_imf_context_add(ctx_id);
-               }
-             else
+             ctx_id = ecore_imf_context_default_id_get();
+             if (ctx_id)
                {
-                  ctx_id = ecore_imf_context_default_id_by_canvas_type_get("evas");
-                  if (ctx_id)
+                  ctx_info = ecore_imf_context_info_by_id_get(ctx_id);
+                  if (!ctx_info->canvas_type ||
+                      strcmp(ctx_info->canvas_type, "evas") == 0)
                     {
                        en->imf_context = ecore_imf_context_add(ctx_id);
                     }
+                  else
+                    {
+                       ctx_id = ecore_imf_context_default_id_by_canvas_type_get("evas");
+                       if (ctx_id)
+                         {
+                            en->imf_context = ecore_imf_context_add(ctx_id);
+                         }
+                    }
                }
-          }
-        else
-          en->imf_context = NULL;
+             else
+                en->imf_context = NULL;
 
-        if (!en->imf_context) goto done;
+             if (!en->imf_context) goto done;
+          }
 
         ecore_imf_context_client_window_set
           (en->imf_context,
@@ -2797,6 +2804,15 @@ _edje_entry_real_part_init(Edje *ed, Edje_Real_Part *rp)
           ecore_imf_context_input_panel_language_set(en->imf_context, ECORE_IMF_INPUT_PANEL_LANG_ALPHABET);
 #endif
      }
+   // TIZEN_ONLY(20131129): Reuse ecore_imf_context when theme is changed
+   else
+     {
+#ifdef HAVE_ECORE_IMF
+        if (ic)
+          ecore_imf_context_del(ic);
+#endif
+     }
+   //
 #ifdef HAVE_ECORE_IMF
 done:
 #endif
@@ -2804,7 +2820,7 @@ done:
 }
 
 void
-_edje_entry_real_part_shutdown(Edje *ed, Edje_Real_Part *rp)
+_edje_entry_real_part_shutdown(Edje *ed, Edje_Real_Part *rp, Eina_Bool reuse_ic)
 {
    Entry *en;
 
@@ -2839,8 +2855,13 @@ _edje_entry_real_part_shutdown(Edje *ed, Edje_Real_Part *rp)
              ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb);
              ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_SELECTION_SET, _edje_entry_imf_event_selection_set_cb);
 
-             ecore_imf_context_del(en->imf_context);
-             en->imf_context = NULL;
+             // TIZEN_ONLY(20131129): Reuse ecore_imf_context when theme is changed
+             if (!reuse_ic)
+               {
+                  ecore_imf_context_del(en->imf_context);
+                  en->imf_context = NULL;
+               }
+             //
           }
 
         edje_object_signal_callback_del(ed->obj, "focus,part,in", rp->part->name, _edje_entry_focus_in_cb);
index f91c0bf..0a04ec2 100644 (file)
@@ -37,6 +37,8 @@ struct _Edje_Nested_Support /* We builed nested-parts list using this struct */
    unsigned char nested_children_count; /* Number of nested children */
 };
 
+static Eina_List *ic_list = NULL;
+
 Evas_Smart *
 _edje_smart_nested_smart_class_new(void)
 {
@@ -523,7 +525,7 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
      }
 #endif
 
-   _edje_file_del(ed);
+   _edje_file_del(ed, EINA_TRUE);
 
    eina_stringshare_replace(&ed->path, file ? eina_file_filename_get(file) : NULL);
    eina_stringshare_replace(&ed->group, group);
@@ -850,6 +852,9 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
                {
                   ed->table_parts = malloc(sizeof(Edje_Real_Part *) * n);
                   ed->table_parts_size = n;
+                  // TIZEN_ONLY(20131129): Reuse ecore_imf_context when theme is changed
+                  Eina_List *l = ic_list;
+
                   /* FIXME: check malloc return */
                   n = eina_array_count(&parts) - 1;
                   while ((rp = eina_array_pop(&parts)))
@@ -926,12 +931,26 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
                               }
                             if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
                               {
-                                 _edje_entry_real_part_init(ed, rp);
+                                 // TIZEN_ONLY(20131129): Reuse ecore_imf_context when theme is changed
+                                 Ecore_IMF_Context *ic = NULL;
+                                 if (l)
+                                   {
+                                      ic = l->data;
+                                      l = eina_list_next(l);
+                                   }
+                                 _edje_entry_real_part_init(ed, rp, ic);
+                                 //
+
                                  if (!ed->has_entries)
                                    ed->has_entries = EINA_TRUE;
                               }
                          }
                     }
+
+                  // TIZEN_ONLY(20131129): Reuse ecore_imf_context when theme is changed
+                  if (ic_list)
+                    ic_list = eina_list_free(ic_list);
+                  //
                }
 
              _edje_ref(ed);
@@ -1299,7 +1318,7 @@ on_error:
    _edje_util_thaw(ed);
    _edje_unblock(ed);
    _edje_unref(ed);
-   _edje_file_del(ed);
+   _edje_file_del(ed, EINA_FALSE);
    if (group_path_started)
      {
         const char *path;
@@ -1436,7 +1455,7 @@ _edje_object_collect(Edje *ed)
 }
 
 void
-_edje_file_del(Edje *ed)
+_edje_file_del(Edje *ed, Eina_Bool reuse_ic)
 {
    Edje_User_Defined *eud;
    Evas *tev = NULL;
@@ -1491,7 +1510,17 @@ _edje_file_del(Edje *ed)
 #endif
 
              if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
-               _edje_entry_real_part_shutdown(ed, rp);
+               {
+                  // TIZEN_ONLY(20131129): Reuse ecore_imf_context when theme is changed
+                  if (reuse_ic)
+                    {
+                       Ecore_IMF_Context *ic = _edje_entry_imf_context_get (rp);
+                       ic_list = eina_list_append(ic_list, ic);
+                    }
+
+                  _edje_entry_real_part_shutdown(ed, rp, reuse_ic);
+                  //
+               }
 
              if ((rp->type == EDJE_RP_TYPE_CONTAINER) &&
                  (rp->typedata.container))
index 6601d2c..80e0708 100644 (file)
@@ -296,7 +296,7 @@ _edje_del(Edje *ed)
      }
    _edje_message_del(ed);
    _edje_signal_callback_free(ed->callbacks);
-   _edje_file_del(ed);
+   _edje_file_del(ed, EINA_FALSE);
    if (ed->path) eina_stringshare_del(ed->path);
    if (ed->group) eina_stringshare_del(ed->group);
    if (ed->parent) eina_stringshare_del(ed->parent);
index 62c899c..fb5eb66 100644 (file)
@@ -2321,7 +2321,7 @@ EAPI void _edje_edd_shutdown(void);
 
 int _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const char *group, const char *parent, Eina_List *group_path, Eina_Array *nested);
 
-void  _edje_file_del(Edje *ed);
+void  _edje_file_del(Edje *ed, Eina_Bool reuse_ic);
 void  _edje_file_free(Edje_File *edf);
 void  _edje_file_cache_shutdown(void);
 void  _edje_collection_free(Edje_File *edf,
@@ -2613,8 +2613,8 @@ void _edje_lua_script_only_message(Edje *ed, Edje_Message *em);
 
 void _edje_entry_init(Edje *ed);
 void _edje_entry_shutdown(Edje *ed);
-void _edje_entry_real_part_init(Edje *ed, Edje_Real_Part *rp);
-void _edje_entry_real_part_shutdown(Edje *ed, Edje_Real_Part *rp);
+void _edje_entry_real_part_init(Edje *ed, Edje_Real_Part *rp, Ecore_IMF_Context *ic);
+void _edje_entry_real_part_shutdown(Edje *ed, Edje_Real_Part *rp, Eina_Bool reuse_ic);
 void _edje_entry_real_part_configure(Edje *ed, Edje_Real_Part *rp);
 // TIZEN_ONLY(20150128): Add evas_textblock_cursor_range_text_valid_markup_get API.
 const char *_edje_entry_selection_valid_markup_get(Edje_Real_Part *rp);
index 43227a0..59e4af9 100644 (file)
@@ -127,7 +127,7 @@ _edje_object_evas_object_smart_del(Eo *obj, Edje *ed)
      }
 #endif
    if (ed->persp) edje_object_perspective_set(obj, NULL);
-   _edje_file_del(ed);
+   _edje_file_del(ed, EINA_FALSE);
    _edje_clean_objects(ed);
    _edje_unref(ed);
    _edje_lib_unref();