Enlightenment CVS committal Author : andrunko Project : e17 Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_imf Modified Files: Ecore_IMF.h Makefile.am ecore_imf_context.c ecore_imf_module.c ecore_imf_private.h Log Message: Added Ecore_IMF_Evas. Removed Evas dependency from Ecore_IMF, that was requested by Ewl developers in order to be able to integrate Ecore_IMF on it. Added Ecore_IMF_Evas, a library with helper functions to use Ecore_IMF together with Evas. Now everybody should be happy. =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_imf/Ecore_IMF.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- Ecore_IMF.h 21 Nov 2007 01:33:50 -0000 1.2 +++ Ecore_IMF.h 21 Nov 2007 22:20:16 -0000 1.3 @@ -26,18 +26,29 @@ #endif #include <Ecore_Data.h> -#include <Evas.h> #ifdef __cplusplus extern "C" { #endif + /* Events sent by the Input Method */ typedef struct _Ecore_IMF_Event_Preedit_Start Ecore_IMF_Event_Preedit_Start; typedef struct _Ecore_IMF_Event_Preedit_End Ecore_IMF_Event_Preedit_End; typedef struct _Ecore_IMF_Event_Preedit_Changed Ecore_IMF_Event_Preedit_Changed; typedef struct _Ecore_IMF_Event_Commit Ecore_IMF_Event_Commit; typedef struct _Ecore_IMF_Event_Delete_Surrounding Ecore_IMF_Event_Delete_Surrounding; + /* Events to filter */ + typedef struct _Ecore_IMF_Event_Mouse_Down Ecore_IMF_Event_Mouse_Down; + typedef struct _Ecore_IMF_Event_Mouse_Up Ecore_IMF_Event_Mouse_Up; + typedef struct _Ecore_IMF_Event_Mouse_In Ecore_IMF_Event_Mouse_In; + typedef struct _Ecore_IMF_Event_Mouse_Out Ecore_IMF_Event_Mouse_Out; + typedef struct _Ecore_IMF_Event_Mouse_Move Ecore_IMF_Event_Mouse_Move; + typedef struct _Ecore_IMF_Event_Mouse_Wheel Ecore_IMF_Event_Mouse_Wheel; + typedef struct _Ecore_IMF_Event_Key_Down Ecore_IMF_Event_Key_Down; + typedef struct _Ecore_IMF_Event_Key_Up Ecore_IMF_Event_Key_Up; + typedef union _Ecore_IMF_Event Ecore_IMF_Event; + typedef struct _Ecore_IMF_Context Ecore_IMF_Context; /**< An Input Method Context */ typedef struct _Ecore_IMF_Context_Class Ecore_IMF_Context_Class; /**< An Input Method Context class */ typedef struct _Ecore_IMF_Context_Info Ecore_IMF_Context_Info; /**< An Input Method Context info */ @@ -50,6 +61,42 @@ typedef enum { + ECORE_IMF_EVENT_MOUSE_DOWN, + ECORE_IMF_EVENT_MOUSE_UP, + ECORE_IMF_EVENT_MOUSE_IN, + ECORE_IMF_EVENT_MOUSE_OUT, + ECORE_IMF_EVENT_MOUSE_MOVE, + ECORE_IMF_EVENT_MOUSE_WHEEL, + ECORE_IMF_EVENT_KEY_DOWN, + ECORE_IMF_EVENT_KEY_UP + } Ecore_IMF_Event_Type; + + typedef enum + { + ECORE_IMF_KEYBOARD_MODIFIER_NONE = 0, /**< No active modifiers */ + ECORE_IMF_KEYBOARD_MODIFIER_CTRL = 1 << 0, /**< "Control" is pressed */ + ECORE_IMF_KEYBOARD_MODIFIER_ALT = 1 << 1, /**< "Alt" is pressed */ + ECORE_IMF_KEYBOARD_MODIFIER_SHIFT = 1 << 2, /**< "Shift" is pressed */ + ECORE_IMF_KEYBOARD_MODIFIER_WIN = 1 << 3 /**< "Win" (between "Ctrl" and "Alt") is pressed */ + } Ecore_IMF_Keyboard_Modifiers; + + typedef enum + { + ECORE_IMF_KEYBOARD_LOCK_NONE = 0, /**< No locks are active */ + ECORE_IMF_KEYBOARD_LOCK_NUM = 1 << 0, /**< "Num" lock is active */ + ECORE_IMF_KEYBOARD_LOCK_CAPS = 1 << 1, /**< "Caps" lock is active */ + ECORE_IMF_KEYBOARD_LOCK_SCROLL = 1 << 2 /**< "Scroll" lock is active */ + } Ecore_IMF_Keyboard_Locks; + + typedef enum + { + ECORE_IMF_MOUSE_NONE = 0, /**< A single click */ + ECORE_IMF_MOUSE_DOUBLE_CLICK = 1 << 0, /**< A double click */ + ECORE_IMF_MOUSE_TRIPLE_CLICK = 1 << 1 /**< A triple click */ + } Ecore_IMF_Mouse_Flags; + + typedef enum + { ECORE_IMF_INPUT_MODE_ALPHA = 1 << 0, ECORE_IMF_INPUT_MODE_NUMERIC = 1 << 1, ECORE_IMF_INPUT_MODE_SPECIAL = 1 << 2, @@ -88,11 +135,135 @@ int n_chars; }; + struct _Ecore_IMF_Event_Mouse_Down + { + int button; /**< The button which has been pressed */ + struct { + int x, y; + } output; + struct { + int x, y; + } canvas; + Ecore_IMF_Keyboard_Modifiers modifiers; /**< The keyboard modifiers active when the event has been emitted */ + Ecore_IMF_Keyboard_Locks locks; /**< The keyboard locks active when the event has been emitted */ + Ecore_IMF_Mouse_Flags flags; /**< The flags corresponding the mouse click (single, double or triple click) */ + unsigned int timestamp; /**< The timestamp when the event occured */ + }; + + struct _Ecore_IMF_Event_Mouse_Up + { + int button; /**< The button which has been pressed */ + struct { + int x, y; + } output; + struct { + int x, y; + } canvas; + Ecore_IMF_Keyboard_Modifiers modifiers; /**< The keyboard modifiers active when the event has been emitted */ + Ecore_IMF_Keyboard_Locks locks; /**< The keyboard locks active when the event has been emitted */ + Ecore_IMF_Mouse_Flags flags; /**< The flags corresponding the mouse click (single, double or triple click) */ + unsigned int timestamp; /**< The timestamp when the event occured */ + }; + + struct _Ecore_IMF_Event_Mouse_In + { + int buttons; + struct { + int x, y; + } output; + struct { + int x, y; + } canvas; + Ecore_IMF_Keyboard_Modifiers modifiers; /**< The keyboard modifiers active when the event has been emitted */ + Ecore_IMF_Keyboard_Locks locks; /**< The keyboard locks active when the event has been emitted */ + unsigned int timestamp; /**< The timestamp when the event occured */ + }; + + struct _Ecore_IMF_Event_Mouse_Out + { + int buttons; + struct { + int x, y; + } output; + struct { + int x, y; + } canvas; + Ecore_IMF_Keyboard_Modifiers modifiers; /**< The keyboard modifiers active when the event has been emitted */ + Ecore_IMF_Keyboard_Locks locks; /**< The keyboard locks active when the event has been emitted */ + unsigned int timestamp; /**< The timestamp when the event occured */ + }; + + struct _Ecore_IMF_Event_Mouse_Move + { + int buttons; + struct { + struct { + int x, y; + } output; + struct { + int x, y; + } canvas; + } cur, prev; + Ecore_IMF_Keyboard_Modifiers modifiers; /**< The keyboard modifiers active when the event has been emitted */ + Ecore_IMF_Keyboard_Locks locks; /**< The keyboard locks active when the event has been emitted */ + unsigned int timestamp; /**< The timestamp when the event occured */ + }; + + struct _Ecore_IMF_Event_Mouse_Wheel + { + int direction; /* 0 = default up/down wheel */ + int z; /* ...,-2,-1 = down, 1,2,... = up */ + struct { + int x, y; + } output; + struct { + int x, y; + } canvas; + Ecore_IMF_Keyboard_Modifiers modifiers; /**< The keyboard modifiers active when the event has been emitted */ + Ecore_IMF_Keyboard_Locks locks; /**< The keyboard locks active when the event has been emitted */ + unsigned int timestamp; /**< The timestamp when the event occured */ + }; + + struct _Ecore_IMF_Event_Key_Down + { + char *keyname; /**< The string name of the key pressed */ + Ecore_IMF_Keyboard_Modifiers modifiers; /**< The keyboard modifiers active when the event has been emitted */ + Ecore_IMF_Keyboard_Locks locks; /**< The keyboard locks active when the event has been emitted */ + const char *key; /**< The logical key : (eg shift+1 == exclamation) */ + const char *string; /**< A UTF8 string if this keystroke has produced a visible string to be ADDED */ + const char *compose; /**< A UTF8 string if this keystroke has modified a string in the middle of being composed - this string replaces the previous one */ + unsigned int timestamp; /**< The timestamp when the event occured */ + }; + + struct _Ecore_IMF_Event_Key_Up + { + char *keyname; /**< The string name of the key pressed */ + Ecore_IMF_Keyboard_Modifiers modifiers; /**< The keyboard modifiers active when the event has been emitted */ + Ecore_IMF_Keyboard_Locks locks; /**< The keyboard locks active when the event has been emitted */ + const char *key; /**< The logical key : (eg shift+1 == exclamation) */ + const char *string; /**< A UTF8 string if this keystroke has produced a visible string to be ADDED */ + const char *compose; /**< A UTF8 string if this keystroke has modified a string in the middle of being composed - this string replaces the previous one */ + unsigned int timestamp; /**< The timestamp when the event occured */ + }; + + union _Ecore_IMF_Event + { + Ecore_IMF_Event_Mouse_Down mouse_down; + Ecore_IMF_Event_Mouse_Up mouse_up; + Ecore_IMF_Event_Mouse_In mouse_in; + Ecore_IMF_Event_Mouse_Out mouse_out; + Ecore_IMF_Event_Mouse_Move mouse_move; + Ecore_IMF_Event_Mouse_Wheel mouse_wheel; + Ecore_IMF_Event_Key_Down key_down; + Ecore_IMF_Event_Key_Up key_up; + }; + struct _Ecore_IMF_Context_Class { void (*add) (Ecore_IMF_Context *ctx); void (*del) (Ecore_IMF_Context *ctx); - void (*client_window_set) (Ecore_IMF_Context *ctx, Evas *evas); + void (*client_window_set) (Ecore_IMF_Context *ctx, void *window); + void (*client_canvas_set) (Ecore_IMF_Context *ctx, void *canvas); void (*show) (Ecore_IMF_Context *ctx); void (*hide) (Ecore_IMF_Context *ctx); void (*preedit_string_get) (Ecore_IMF_Context *ctx, char **str, int *cursor_pos); @@ -102,7 +273,7 @@ void (*cursor_position_set) (Ecore_IMF_Context *ctx, int cursor_pos); void (*use_preedit_set) (Ecore_IMF_Context *ctx, int use_preedit); void (*input_mode_set) (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Mode input_mode); - int (*filter_event) (Ecore_IMF_Context *ctx, Evas_Callback_Type type, void *event_info); + int (*filter_event) (Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type, Ecore_IMF_Event *event); }; struct _Ecore_IMF_Context_Info @@ -110,18 +281,24 @@ const char *id; /* ID */ const char *description; /* Human readable description */ const char *default_locales; /* Languages for which this context is the default, separated by : */ + const char *canvas_type; /* The canvas type used by the input method. Eg.: evas */ + int canvas_required; /* Whether the canvas usage is required for this input method */ }; EAPI int ecore_imf_init(void); EAPI int ecore_imf_shutdown(void); EAPI Ecore_List *ecore_imf_context_available_ids_get(void); + EAPI Ecore_List *ecore_imf_context_available_ids_by_canvas_type_get(const char *canvas_type); EAPI const char *ecore_imf_context_default_id_get(void); + EAPI const char *ecore_imf_context_default_id_by_canvas_type_get(const char *canvas_type); EAPI const Ecore_IMF_Context_Info *ecore_imf_context_info_by_id_get(const char *id); EAPI Ecore_IMF_Context *ecore_imf_context_add(const char *id); + EAPI const Ecore_IMF_Context_Info *ecore_imf_context_info_get(Ecore_IMF_Context *ctx); EAPI void ecore_imf_context_del(Ecore_IMF_Context *ctx); - EAPI void ecore_imf_context_client_window_set(Ecore_IMF_Context *ctx, Evas *evas); + EAPI void ecore_imf_context_client_window_set(Ecore_IMF_Context *ctx, void *window); + EAPI void ecore_imf_context_client_canvas_set(Ecore_IMF_Context *ctx, void *canvas); EAPI void ecore_imf_context_show(Ecore_IMF_Context *ctx); EAPI void ecore_imf_context_hide(Ecore_IMF_Context *ctx); EAPI void ecore_imf_context_preedit_string_get(Ecore_IMF_Context *ctx, char **str, int *cursor_pos); @@ -133,7 +310,7 @@ EAPI void ecore_imf_context_retrieve_surrounding_callback_set(Ecore_IMF_Context *ctx, int (*func)(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos), const void *data); EAPI void ecore_imf_context_input_mode_set(Ecore_IMF_Context *ctx, Ecore_IMF_Input_Mode input_mode); EAPI Ecore_IMF_Input_Mode ecore_imf_context_input_mode_get(Ecore_IMF_Context *ctx); - EAPI int ecore_imf_context_filter_event(Ecore_IMF_Context *ctx, Evas_Callback_Type type, void *event_info); + EAPI int ecore_imf_context_filter_event(Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type, Ecore_IMF_Event *event); /* plugin specific functions */ EAPI Ecore_IMF_Context *ecore_imf_context_new(const Ecore_IMF_Context_Class *ctxc); =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_imf/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- Makefile.am 19 Nov 2007 18:27:11 -0000 1.1 +++ Makefile.am 21 Nov 2007 22:20:16 -0000 1.2 @@ -3,8 +3,7 @@ if BUILD_ECORE_IMF AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib/ecore \ --DPACKAGE_LIB_DIR=\"$(libdir)\" \ [EMAIL PROTECTED]@ +-DPACKAGE_LIB_DIR=\"$(libdir)\" lib_LTLIBRARIES = libecore_imf.la include_HEADERS = \ @@ -17,8 +16,7 @@ ecore_imf_private.h libecore_imf_la_LIBADD = \ -$(top_builddir)/src/lib/ecore/libecore.la \ [EMAIL PROTECTED]@ +$(top_builddir)/src/lib/ecore/libecore.la libecore_imf_la_LDFLAGS = -version-info @version_info@ endif =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_imf/ecore_imf_context.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- ecore_imf_context.c 21 Nov 2007 01:33:50 -0000 1.2 +++ ecore_imf_context.c 21 Nov 2007 22:20:16 -0000 1.3 @@ -32,6 +32,12 @@ return ecore_imf_module_context_ids_get(); } +EAPI Ecore_List * +ecore_imf_context_available_ids_by_canvas_type_get(const char *canvas_type) +{ + return ecore_imf_module_context_ids_by_canvas_type_get(canvas_type); +} + /* * Match @locale against @against. * @@ -67,6 +73,11 @@ EAPI const char * ecore_imf_context_default_id_get(void) { + return ecore_imf_context_default_id_by_canvas_type_get(NULL); +} + +EAPI const char *ecore_imf_context_default_id_by_canvas_type_get(const char *canvas_type) +{ const char *id; Ecore_List *modules; Ecore_IMF_Module *module; @@ -95,6 +106,10 @@ ecore_list_first_goto(modules); while ((module = ecore_list_next(modules))) { + if (canvas_type && + strcmp(module->info->canvas_type, canvas_type) == 0) + continue; + const char *p = module->info->default_locales; while (p) { @@ -162,6 +177,26 @@ } /** + * Retrieve the info for the given Input Method Context. + * + * @param ctx An #Ecore_IMF_Context. + * @return Return a #Ecore_IMF_Context_Info for the given Input Method Context; + * on failure it returns NULL. + * @ingroup Ecore_IMF_Context_Group + */ +EAPI const Ecore_IMF_Context_Info * +ecore_imf_context_info_get(Ecore_IMF_Context *ctx) +{ + if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) + { + ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT, + "ecore_imf_context_info_get"); + return NULL; + } + return ctx->module->info; +} + +/** * Delete the given Input Method Context and free its memory. * * @param ctx An #Ecore_IMF_Context. @@ -183,7 +218,7 @@ /** * Set the client window for the Input Method Context; this is the - * Evas canvas in which the input appears. + * Ecore_X_Window when using X11, Ecore_Win32_Window when using Win32, etc. * This window is used in order to correctly position status windows, and may * also be used for purposes internal to the Input Method Context. * @@ -193,7 +228,32 @@ * @ingroup Ecore_IMF_Context_Group */ EAPI void -ecore_imf_context_client_window_set(Ecore_IMF_Context *ctx, Evas *evas) +ecore_imf_context_client_window_set(Ecore_IMF_Context *ctx, void *window) +{ + if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) + { + ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT, + "ecore_imf_context_client_window_set"); + return; + } + if (ctx->klass->client_window_set) ctx->klass->client_window_set(ctx, window); +} + +/** + * Set the client canvas for the Input Method Context; this is the + * canvas in which the input appears. + * The canvas type can be determined by using the context canvas type. + * Actually only canvas with type "evas" (Evas *) is supported. + * This canvas may be used in order to correctly position status windows, and may + * also be used for purposes internal to the Input Method Context. + * + * @param ctx An #Ecore_IMF_Context. + * @param canas The client canvas. This may be NULL to indicate + * that the previous client canvas no longer exists. + * @ingroup Ecore_IMF_Context_Group + */ +EAPI void +ecore_imf_context_client_canvas_set(Ecore_IMF_Context *ctx, void *canvas) { if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) { @@ -201,7 +261,7 @@ "ecore_imf_context_client_window_set"); return; } - if (ctx->klass->client_window_set) ctx->klass->client_window_set(ctx, evas); + if (ctx->klass->client_canvas_set) ctx->klass->client_canvas_set(ctx, canvas); } /** @@ -449,15 +509,13 @@ * obligation of any events to be submitted to this function. * * @param ctx An #Ecore_IMF_Context. - * @param type The type of event defined in #Evas_Callback_Type - * @param event_info The event itself; This should be one of - * Evas_Event_* types or NULL for some event types as - * EVAS_CALLBACK_SHOW/HIDE for example. + * @param type The type of event defined by #Ecore_IMF_Event_Type. + * @param event The event itself. * @return 1 if the event was handled; otherwise 0. * @ingroup Ecore_IMF_Context_Group */ EAPI int -ecore_imf_context_filter_event(Ecore_IMF_Context *ctx, Evas_Callback_Type type, void *event_info) +ecore_imf_context_filter_event(Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type, Ecore_IMF_Event *event) { if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) { @@ -465,7 +523,7 @@ "ecore_imf_context_filter_event"); return 0; } - if (ctx->klass->filter_event) return ctx->klass->filter_event(ctx, type, event_info); + if (ctx->klass->filter_event) return ctx->klass->filter_event(ctx, type, event); return 0; } =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_imf/ecore_imf_module.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- ecore_imf_module.c 19 Nov 2007 18:27:11 -0000 1.1 +++ ecore_imf_module.c 21 Nov 2007 22:20:16 -0000 1.2 @@ -91,11 +91,22 @@ ecore_imf_module_context_create(const char *ctx_id) { Ecore_IMF_Module *module; + Ecore_IMF_Context *ctx = NULL; if (!modules) return NULL; module = ecore_hash_get(modules, ctx_id); - if (module) return module->create(); - return NULL; + if (module) + { + ctx = module->create(); + if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) + { + ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT, + "ecore_imf_module_context_create"); + return NULL; + } + ctx->module = module; + } + return ctx; } Ecore_List * @@ -103,6 +114,38 @@ { if (!modules) return NULL; return ecore_hash_keys(modules); +} + +Ecore_List * +ecore_imf_module_context_ids_by_canvas_type_get(const char *canvas_type) +{ + Ecore_List *values; + unsigned int i = 0; + + if (!modules) return NULL; + + if (!canvas_type) + return ecore_imf_module_context_ids_get(); + + values = ecore_list_new(); + while (i < ecore_prime_table[modules->size]) + { + if (modules->buckets[i]) + { + Ecore_Hash_Node *node; + + for (node = modules->buckets[i]; node; node = node->next) + { + Ecore_IMF_Module *module = node->value; + if (strcmp(module->info->canvas_type, canvas_type) == 0) + ecore_list_append(values, (void *) module->info->id); + } + } + i++; + } + ecore_list_first_goto(values); + + return values; } static void =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_imf/ecore_imf_private.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- ecore_imf_private.h 19 Nov 2007 18:27:11 -0000 1.1 +++ ecore_imf_private.h 21 Nov 2007 22:20:16 -0000 1.2 @@ -12,6 +12,7 @@ struct _Ecore_IMF_Context { ECORE_MAGIC; + const Ecore_IMF_Module *module; const Ecore_IMF_Context_Class *klass; void *data; int input_mode; @@ -32,5 +33,6 @@ Ecore_IMF_Module *ecore_imf_module_get(const char *ctx_id); Ecore_IMF_Context *ecore_imf_module_context_create(const char *ctx_id); Ecore_List *ecore_imf_module_context_ids_get(void); +Ecore_List *ecore_imf_module_context_ids_by_canvas_type_get(const char *canvas_type); #endif ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs