aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_imf/ecore_imf_context.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ecore/src/lib/ecore_imf/ecore_imf_context.c')
-rw-r--r--libraries/ecore/src/lib/ecore_imf/ecore_imf_context.c141
1 files changed, 139 insertions, 2 deletions
diff --git a/libraries/ecore/src/lib/ecore_imf/ecore_imf_context.c b/libraries/ecore/src/lib/ecore_imf/ecore_imf_context.c
index 417fad3..b65ee26 100644
--- a/libraries/ecore/src/lib/ecore_imf/ecore_imf_context.c
+++ b/libraries/ecore/src/lib/ecore_imf/ecore_imf_context.c
@@ -223,6 +223,8 @@ ecore_imf_context_info_get(Ecore_IMF_Context *ctx)
223EAPI void 223EAPI void
224ecore_imf_context_del(Ecore_IMF_Context *ctx) 224ecore_imf_context_del(Ecore_IMF_Context *ctx)
225{ 225{
226 Ecore_IMF_Func_Node *fn;
227
226 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) 228 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
227 { 229 {
228 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT, 230 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
@@ -230,6 +232,13 @@ ecore_imf_context_del(Ecore_IMF_Context *ctx)
230 return; 232 return;
231 } 233 }
232 if (ctx->klass->del) ctx->klass->del(ctx); 234 if (ctx->klass->del) ctx->klass->del(ctx);
235
236 if (ctx->callbacks)
237 {
238 EINA_LIST_FREE(ctx->callbacks, fn)
239 free(fn);
240 }
241
233 ECORE_MAGIC_SET(ctx, ECORE_MAGIC_NONE); 242 ECORE_MAGIC_SET(ctx, ECORE_MAGIC_NONE);
234 free(ctx); 243 free(ctx);
235} 244}
@@ -529,7 +538,7 @@ ecore_imf_context_cursor_location_set(Ecore_IMF_Context *ctx, int x, int y, int
529 538
530/** 539/**
531 * Set whether the IM context should use the preedit string 540 * Set whether the IM context should use the preedit string
532 * to display feedback. If @use_preedit is EINA_FALSE (default 541 * to display feedback. If @c use_preedit is EINA_FALSE (default
533 * is EINA_TRUE), then the IM context may use some other method to display 542 * is EINA_TRUE), then the IM context may use some other method to display
534 * feedback, such as displaying it in a child of the root window. 543 * feedback, such as displaying it in a child of the root window.
535 * 544 *
@@ -551,7 +560,7 @@ ecore_imf_context_use_preedit_set(Ecore_IMF_Context *ctx, Eina_Bool use_preedit)
551 560
552/** 561/**
553 * Set whether the IM context should allow to use the text prediction. 562 * Set whether the IM context should allow to use the text prediction.
554 * If @prediction is EINA_FALSE (default is EINA_TRUE), then the IM context will not display the text prediction window. 563 * If @c prediction is EINA_FALSE (default is EINA_TRUE), then the IM context will not display the text prediction window.
555 * 564 *
556 * @param ctx An #Ecore_IMF_Context. 565 * @param ctx An #Ecore_IMF_Context.
557 * @param prediction Whether the IM context should allow to use the text prediction. 566 * @param prediction Whether the IM context should allow to use the text prediction.
@@ -1016,6 +1025,134 @@ ecore_imf_context_delete_surrounding_event_add(Ecore_IMF_Context *ctx, int offse
1016} 1025}
1017 1026
1018/** 1027/**
1028 * Add (register) a callback function to a given context event.
1029 *
1030 * This function adds a function callback to the context @p ctx when the
1031 * event of type @p type occurs on it. The function pointer is @p
1032 * func.
1033 *
1034 * The event type @p type to trigger the function may be one of
1035 * #ECORE_IMF_CALLBACK_PREEDIT_START, #ECORE_IMF_CALLBACK_PREEDIT_END,
1036 * #ECORE_IMF_CALLBACK_PREEDIT_CHANGED, #ECORE_IMF_CALLBACK_COMMIT and
1037 * #ECORE_IMF_CALLBACK_DELETE_SURROUNDING.
1038 *
1039 * @param ctx Ecore_IMF_Context to attach a callback to.
1040 * @param type The type of event that will trigger the callback
1041 * @param func The (callback) function to be called when the event is
1042 * triggered
1043 * @param data The data pointer to be passed to @p func
1044 * @ingroup Ecore_IMF_Context_Module_Group
1045 * @since 1.2.0
1046 */
1047EAPI void
1048ecore_imf_context_event_callback_add(Ecore_IMF_Context *ctx, Ecore_IMF_Callback_Type type, Ecore_IMF_Event_Cb func, const void *data)
1049{
1050 Ecore_IMF_Func_Node *fn = NULL;
1051
1052 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1053 {
1054 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
1055 "ecore_imf_context_event_callback_add");
1056 return;
1057 }
1058
1059 if (!func) return;
1060
1061 fn = calloc(1, sizeof (Ecore_IMF_Func_Node));
1062 if (!fn) return;
1063
1064 fn->func = func;
1065 fn->data = data;
1066 fn->type = type;
1067
1068 ctx->callbacks = eina_list_append(ctx->callbacks, fn);
1069}
1070
1071/**
1072 * Delete (unregister) a callback function registered to a given
1073 * context event.
1074 *
1075 * This function removes a function callback from the context @p ctx when the
1076 * event of type @p type occurs on it. The function pointer is @p
1077 * func.
1078 *
1079 * @see ecore_imf_context_event_callback_add() for more details
1080 *
1081 * @param ctx Ecore_IMF_Context to remove a callback from.
1082 * @param type The type of event that was trigerring the callback
1083 * @param func The (callback) function that was to be called when the event was triggered
1084 * @return the data pointer
1085 * @ingroup Ecore_IMF_Context_Module_Group
1086 * @since 1.2.0
1087 */
1088EAPI void *
1089ecore_imf_context_event_callback_del(Ecore_IMF_Context *ctx, Ecore_IMF_Callback_Type type, Ecore_IMF_Event_Cb func)
1090{
1091 Eina_List *l = NULL;
1092 Eina_List *l_next = NULL;
1093 Ecore_IMF_Func_Node *fn = NULL;
1094
1095 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1096 {
1097 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
1098 "ecore_imf_context_event_callback_del");
1099 return;
1100 }
1101
1102 if (!func) return NULL;
1103 if (!ctx->callbacks) return NULL;
1104
1105 EINA_LIST_FOREACH_SAFE(ctx->callbacks, l, l_next, fn)
1106 {
1107 if ((fn) && (fn->func == func) && (fn->type == type))
1108 {
1109 void *tmp = fn->data;
1110 free(fn);
1111 ctx->callbacks = eina_list_remove_list(ctx->callbacks, l);
1112 return tmp;
1113 }
1114 }
1115 return NULL;
1116}
1117
1118/**
1119 * Call a given callback on the context @p ctx.
1120 *
1121 * ecore_imf_context_preedit_start_event_add, ecore_imf_context_preedit_end_event_add,
1122 * ecore_imf_context_preedit_changed_event_add, ecore_imf_context_commit_event_add and
1123 * ecore_imf_context_delete_surrounding_event_add APIs are asynchronous
1124 * because those API adds each event to the event queue.
1125 *
1126 * This API provides the way to call each callback function immediately.
1127 *
1128 * @param ctx Ecore_IMF_Context.
1129 * @param type The type of event that will trigger the callback
1130 * @param event_info The pointer to event specific struct or information to
1131 * pass to the callback functions registered on this event
1132 * @ingroup Ecore_IMF_Context_Module_Group
1133 * @since 1.2.0
1134 */
1135EAPI void
1136ecore_imf_context_event_callback_call(Ecore_IMF_Context *ctx, Ecore_IMF_Callback_Type type, void *event_info)
1137{
1138 Ecore_IMF_Func_Node *fn = NULL;
1139 Eina_List *l = NULL;
1140
1141 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1142 {
1143 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
1144 "ecore_imf_context_event_callback_call");
1145 return;
1146 }
1147
1148 EINA_LIST_FOREACH(ctx->callbacks, l, fn)
1149 {
1150 if ((fn) && (fn->type == type) && (fn->func))
1151 fn->func(fn->data, ctx, event_info);
1152 }
1153}
1154
1155/**
1019 * Ask the Input Method Context to show the control panel of using Input Method. 1156 * Ask the Input Method Context to show the control panel of using Input Method.
1020 * 1157 *
1021 * @param ctx An #Ecore_IMF_Context. 1158 * @param ctx An #Ecore_IMF_Context.