From 825a3d837a33f226c879cd02ad15c3fba57e8b2c Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 23 Jan 2012 23:30:42 +1000 Subject: Update the EFL to what I'm actually using, coz I'm using some stuff not yet released. --- libraries/ecore/src/lib/ecore_imf/Ecore_IMF.h | 19 ++- libraries/ecore/src/lib/ecore_imf/Makefile.in | 14 +- .../ecore/src/lib/ecore_imf/ecore_imf_context.c | 141 ++++++++++++++++++++- .../ecore/src/lib/ecore_imf/ecore_imf_private.h | 9 ++ 4 files changed, 178 insertions(+), 5 deletions(-) (limited to 'libraries/ecore/src/lib/ecore_imf') diff --git a/libraries/ecore/src/lib/ecore_imf/Ecore_IMF.h b/libraries/ecore/src/lib/ecore_imf/Ecore_IMF.h index 21df2a0..adea35d 100644 --- a/libraries/ecore/src/lib/ecore_imf/Ecore_IMF.h +++ b/libraries/ecore/src/lib/ecore_imf/Ecore_IMF.h @@ -64,6 +64,17 @@ EAPI extern int ECORE_IMF_EVENT_PREEDIT_CHANGED; EAPI extern int ECORE_IMF_EVENT_COMMIT; EAPI extern int ECORE_IMF_EVENT_DELETE_SURROUNDING; +typedef void (*Ecore_IMF_Event_Cb) (void *data, Ecore_IMF_Context *ctx, void *event_info); + +typedef enum +{ + ECORE_IMF_CALLBACK_PREEDIT_START, + ECORE_IMF_CALLBACK_PREEDIT_END, + ECORE_IMF_CALLBACK_PREEDIT_CHANGED, + ECORE_IMF_CALLBACK_COMMIT, + ECORE_IMF_CALLBACK_DELETE_SURROUNDING +} Ecore_IMF_Callback_Type; + typedef enum { ECORE_IMF_EVENT_MOUSE_DOWN, @@ -138,7 +149,10 @@ typedef enum ECORE_IMF_INPUT_PANEL_LAYOUT_IP, /**< IP layout */ ECORE_IMF_INPUT_PANEL_LAYOUT_MONTH, /**< Month layout */ ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY, /**< Number Only layout */ - ECORE_IMF_INPUT_PANEL_LAYOUT_INVALID + ECORE_IMF_INPUT_PANEL_LAYOUT_INVALID, /**< Never use this */ + ECORE_IMF_INPUT_PANEL_LAYOUT_HEX, /**< Hexadecimal layout @since 1.2 */ + ECORE_IMF_INPUT_PANEL_LAYOUT_TERMINAL, /**< Command-line terminal layout @since 1.2 */ + ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD /**< Like normal, but no auto-correct, no auto-capitalization etc. @since 1.2 */ } Ecore_IMF_Input_Panel_Layout; typedef enum @@ -385,6 +399,9 @@ EAPI void ecore_imf_context_preedit_end_event_add(Ecore EAPI void ecore_imf_context_preedit_changed_event_add(Ecore_IMF_Context *ctx); EAPI void ecore_imf_context_commit_event_add(Ecore_IMF_Context *ctx, const char *str); EAPI void ecore_imf_context_delete_surrounding_event_add(Ecore_IMF_Context *ctx, int offset, int n_chars); +EAPI void ecore_imf_context_event_callback_add(Ecore_IMF_Context *ctx, Ecore_IMF_Callback_Type type, Ecore_IMF_Event_Cb func, const void *data); +EAPI void *ecore_imf_context_event_callback_del(Ecore_IMF_Context *ctx, Ecore_IMF_Callback_Type type, Ecore_IMF_Event_Cb func); +EAPI void ecore_imf_context_event_callback_call(Ecore_IMF_Context *ctx, Ecore_IMF_Callback_Type type, void *event_info); EAPI void ecore_imf_context_prediction_allow_set(Ecore_IMF_Context *ctx, Eina_Bool prediction); EAPI Eina_Bool ecore_imf_context_prediction_allow_get(Ecore_IMF_Context *ctx); EAPI void ecore_imf_context_autocapital_type_set(Ecore_IMF_Context *ctx, Ecore_IMF_Autocapital_Type autocapital_type); diff --git a/libraries/ecore/src/lib/ecore_imf/Makefile.in b/libraries/ecore/src/lib/ecore_imf/Makefile.in index adf8dea..9f91360 100644 --- a/libraries/ecore/src/lib/ecore_imf/Makefile.in +++ b/libraries/ecore/src/lib/ecore_imf/Makefile.in @@ -248,10 +248,10 @@ PATH_SEPARATOR = @PATH_SEPARATOR@ PIXMAN_CFLAGS = @PIXMAN_CFLAGS@ PIXMAN_LIBS = @PIXMAN_LIBS@ PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POSUB = @POSUB@ RANLIB = @RANLIB@ +SCIM_CFLAGS = @SCIM_CFLAGS@ +SCIM_LIBS = @SCIM_LIBS@ SDL_CFLAGS = @SDL_CFLAGS@ SDL_CONFIG = @SDL_CONFIG@ SDL_LIBS = @SDL_LIBS@ @@ -270,6 +270,10 @@ TSLIB_LIBS = @TSLIB_LIBS@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ VMAJ = @VMAJ@ +WAYLAND_CFLAGS = @WAYLAND_CFLAGS@ +WAYLAND_EGL_CFLAGS = @WAYLAND_EGL_CFLAGS@ +WAYLAND_EGL_LIBS = @WAYLAND_EGL_LIBS@ +WAYLAND_LIBS = @WAYLAND_LIBS@ WIN32_CFLAGS = @WIN32_CFLAGS@ WIN32_CPPFLAGS = @WIN32_CPPFLAGS@ WIN32_LIBS = @WIN32_LIBS@ @@ -383,6 +387,8 @@ ecore_imf_cflags = @ecore_imf_cflags@ ecore_imf_evas_cflags = @ecore_imf_evas_cflags@ ecore_imf_evas_libs = @ecore_imf_evas_libs@ ecore_imf_libs = @ecore_imf_libs@ +ecore_imf_scim_cflags = @ecore_imf_scim_cflags@ +ecore_imf_scim_libs = @ecore_imf_scim_libs@ ecore_imf_xim_cflags = @ecore_imf_xim_cflags@ ecore_imf_xim_libs = @ecore_imf_xim_libs@ ecore_input_cflags = @ecore_input_cflags@ @@ -395,6 +401,8 @@ ecore_psl1ght_cflags = @ecore_psl1ght_cflags@ ecore_psl1ght_libs = @ecore_psl1ght_libs@ ecore_sdl_cflags = @ecore_sdl_cflags@ ecore_sdl_libs = @ecore_sdl_libs@ +ecore_wayland_cflags = @ecore_wayland_cflags@ +ecore_wayland_libs = @ecore_wayland_libs@ ecore_win32_cflags = @ecore_win32_cflags@ ecore_win32_libs = @ecore_win32_libs@ ecore_wince_cflags = @ecore_wince_cflags@ @@ -439,12 +447,14 @@ requirements_ecore_fb = @requirements_ecore_fb@ requirements_ecore_file = @requirements_ecore_file@ requirements_ecore_imf = @requirements_ecore_imf@ requirements_ecore_imf_evas = @requirements_ecore_imf_evas@ +requirements_ecore_imf_scim = @requirements_ecore_imf_scim@ requirements_ecore_imf_xim = @requirements_ecore_imf_xim@ requirements_ecore_input = @requirements_ecore_input@ requirements_ecore_input_evas = @requirements_ecore_input_evas@ requirements_ecore_ipc = @requirements_ecore_ipc@ requirements_ecore_psl1ght = @requirements_ecore_psl1ght@ requirements_ecore_sdl = @requirements_ecore_sdl@ +requirements_ecore_wayland = @requirements_ecore_wayland@ requirements_ecore_win32 = @requirements_ecore_win32@ requirements_ecore_wince = @requirements_ecore_wince@ requirements_ecore_x = @requirements_ecore_x@ 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) EAPI void ecore_imf_context_del(Ecore_IMF_Context *ctx) { + Ecore_IMF_Func_Node *fn; + if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) { ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT, @@ -230,6 +232,13 @@ ecore_imf_context_del(Ecore_IMF_Context *ctx) return; } if (ctx->klass->del) ctx->klass->del(ctx); + + if (ctx->callbacks) + { + EINA_LIST_FREE(ctx->callbacks, fn) + free(fn); + } + ECORE_MAGIC_SET(ctx, ECORE_MAGIC_NONE); free(ctx); } @@ -529,7 +538,7 @@ ecore_imf_context_cursor_location_set(Ecore_IMF_Context *ctx, int x, int y, int /** * Set whether the IM context should use the preedit string - * to display feedback. If @use_preedit is EINA_FALSE (default + * to display feedback. If @c use_preedit is EINA_FALSE (default * is EINA_TRUE), then the IM context may use some other method to display * feedback, such as displaying it in a child of the root window. * @@ -551,7 +560,7 @@ ecore_imf_context_use_preedit_set(Ecore_IMF_Context *ctx, Eina_Bool use_preedit) /** * Set whether the IM context should allow to use the text prediction. - * If @prediction is EINA_FALSE (default is EINA_TRUE), then the IM context will not display the text prediction window. + * If @c prediction is EINA_FALSE (default is EINA_TRUE), then the IM context will not display the text prediction window. * * @param ctx An #Ecore_IMF_Context. * @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 } /** + * Add (register) a callback function to a given context event. + * + * This function adds a function callback to the context @p ctx when the + * event of type @p type occurs on it. The function pointer is @p + * func. + * + * The event type @p type to trigger the function may be one of + * #ECORE_IMF_CALLBACK_PREEDIT_START, #ECORE_IMF_CALLBACK_PREEDIT_END, + * #ECORE_IMF_CALLBACK_PREEDIT_CHANGED, #ECORE_IMF_CALLBACK_COMMIT and + * #ECORE_IMF_CALLBACK_DELETE_SURROUNDING. + * + * @param ctx Ecore_IMF_Context to attach a callback to. + * @param type The type of event that will trigger the callback + * @param func The (callback) function to be called when the event is + * triggered + * @param data The data pointer to be passed to @p func + * @ingroup Ecore_IMF_Context_Module_Group + * @since 1.2.0 + */ +EAPI void +ecore_imf_context_event_callback_add(Ecore_IMF_Context *ctx, Ecore_IMF_Callback_Type type, Ecore_IMF_Event_Cb func, const void *data) +{ + Ecore_IMF_Func_Node *fn = NULL; + + if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) + { + ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT, + "ecore_imf_context_event_callback_add"); + return; + } + + if (!func) return; + + fn = calloc(1, sizeof (Ecore_IMF_Func_Node)); + if (!fn) return; + + fn->func = func; + fn->data = data; + fn->type = type; + + ctx->callbacks = eina_list_append(ctx->callbacks, fn); +} + +/** + * Delete (unregister) a callback function registered to a given + * context event. + * + * This function removes a function callback from the context @p ctx when the + * event of type @p type occurs on it. The function pointer is @p + * func. + * + * @see ecore_imf_context_event_callback_add() for more details + * + * @param ctx Ecore_IMF_Context to remove a callback from. + * @param type The type of event that was trigerring the callback + * @param func The (callback) function that was to be called when the event was triggered + * @return the data pointer + * @ingroup Ecore_IMF_Context_Module_Group + * @since 1.2.0 + */ +EAPI void * +ecore_imf_context_event_callback_del(Ecore_IMF_Context *ctx, Ecore_IMF_Callback_Type type, Ecore_IMF_Event_Cb func) +{ + Eina_List *l = NULL; + Eina_List *l_next = NULL; + Ecore_IMF_Func_Node *fn = NULL; + + if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) + { + ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT, + "ecore_imf_context_event_callback_del"); + return; + } + + if (!func) return NULL; + if (!ctx->callbacks) return NULL; + + EINA_LIST_FOREACH_SAFE(ctx->callbacks, l, l_next, fn) + { + if ((fn) && (fn->func == func) && (fn->type == type)) + { + void *tmp = fn->data; + free(fn); + ctx->callbacks = eina_list_remove_list(ctx->callbacks, l); + return tmp; + } + } + return NULL; +} + +/** + * Call a given callback on the context @p ctx. + * + * ecore_imf_context_preedit_start_event_add, ecore_imf_context_preedit_end_event_add, + * ecore_imf_context_preedit_changed_event_add, ecore_imf_context_commit_event_add and + * ecore_imf_context_delete_surrounding_event_add APIs are asynchronous + * because those API adds each event to the event queue. + * + * This API provides the way to call each callback function immediately. + * + * @param ctx Ecore_IMF_Context. + * @param type The type of event that will trigger the callback + * @param event_info The pointer to event specific struct or information to + * pass to the callback functions registered on this event + * @ingroup Ecore_IMF_Context_Module_Group + * @since 1.2.0 + */ +EAPI void +ecore_imf_context_event_callback_call(Ecore_IMF_Context *ctx, Ecore_IMF_Callback_Type type, void *event_info) +{ + Ecore_IMF_Func_Node *fn = NULL; + Eina_List *l = NULL; + + if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) + { + ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT, + "ecore_imf_context_event_callback_call"); + return; + } + + EINA_LIST_FOREACH(ctx->callbacks, l, fn) + { + if ((fn) && (fn->type == type) && (fn->func)) + fn->func(fn->data, ctx, event_info); + } +} + +/** * Ask the Input Method Context to show the control panel of using Input Method. * * @param ctx An #Ecore_IMF_Context. diff --git a/libraries/ecore/src/lib/ecore_imf/ecore_imf_private.h b/libraries/ecore/src/lib/ecore_imf/ecore_imf_private.h index 07a5b09..d9dae80 100644 --- a/libraries/ecore/src/lib/ecore_imf/ecore_imf_private.h +++ b/libraries/ecore/src/lib/ecore_imf/ecore_imf_private.h @@ -35,6 +35,7 @@ extern int _ecore_imf_log_dom; #define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_imf_log_dom, __VA_ARGS__) typedef struct _Ecore_IMF_Module Ecore_IMF_Module; +typedef struct _Ecore_IMF_Func_Node Ecore_IMF_Func_Node; struct _Ecore_IMF_Context { @@ -47,6 +48,7 @@ struct _Ecore_IMF_Context void *client_canvas; Eina_Bool (*retrieve_surrounding_func)(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos); void *retrieve_surrounding_data; + Eina_List *callbacks; Ecore_IMF_Autocapital_Type autocapital_type; Ecore_IMF_Input_Panel_Layout input_panel_layout; Ecore_IMF_Input_Panel_Lang input_panel_lang; @@ -61,6 +63,13 @@ struct _Ecore_IMF_Module Ecore_IMF_Context *(*exit)(void); }; +struct _Ecore_IMF_Func_Node +{ + void (*func) (); + const void *data; + Ecore_IMF_Callback_Type type; +}; + void ecore_imf_module_init(void); void ecore_imf_module_shutdown(void); Eina_List *ecore_imf_module_available_get(void); -- cgit v1.1