From 0d733b0912ca645f6f00be0227ebaa3238f3093b Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 10 Feb 2017 14:45:36 +0900 Subject: [PATCH] Remove unnecessary CCoreEventCallback class Change-Id: I2c59bc51e74bb2cc2122a61259e25fd5bb229653 Signed-off-by: Jihoon Kim --- src/include/ise.h | 49 +----- src/ise.cpp | 463 ++++++++++++++++++------------------------------------ src/sdk/sdk.cpp | 1 - 3 files changed, 150 insertions(+), 363 deletions(-) diff --git a/src/include/ise.h b/src/include/ise.h index 9fff443..c422cb8 100644 --- a/src/include/ise.h +++ b/src/include/ise.h @@ -20,8 +20,8 @@ #include #include - #include +#include #include "languages.h" @@ -43,8 +43,6 @@ //#define INPUT_MODE_NATIVE MAX_INPUT_MODE /* Native mode. It will distinguish to the current user language */ //#define ISE_RELEASE_AUTOCOMMIT_BLOCK_INTERVAL 1300 - -#include #undef LOG_TAG #define LOG_TAG "ISE_DEFAULT" @@ -180,51 +178,6 @@ typedef struct { sclboolean disable_force_latin; } KEYBOARD_STATE; -using namespace scl; - -class CCoreEventCallback : public ISCLCoreEventCallback -{ -public: - void on_init(); - void on_exit(); - - void on_attach_input_context(sclint ic, const sclchar *ic_uuid); - void on_detach_input_context(sclint ic, const sclchar *ic_uuid); - - void on_focus_out(sclint ic, const sclchar *ic_uuid); - void on_focus_in(sclint ic, const sclchar *ic_uuid); - - void on_ise_show(sclint ic, const sclint degree, Ise_Context &context); - void on_ise_hide(sclint ic, const sclchar *ic_uuid); - - void on_reset_input_context(sclint ic, const sclchar *uuid); - - void on_set_display_language(const sclchar *language); - void on_set_accessibility_state(const sclboolean state); - void on_set_rotation_degree(sclint degree); - - void on_set_layout(sclu32 layout); - void on_set_caps_mode(sclu32 mode); - void on_update_cursor_position(sclint ic, const sclchar *ic_uuid, sclint cursor_pos); - void on_update_surrounding_text(sclint ic, const sclchar *text, sclint cursor); - - void on_set_return_key_type(sclu32 type); - void on_set_return_key_disable(sclu32 disabled); - - void on_set_imdata(sclchar *buf, sclu32 len); - void on_get_language_locale(sclint ic, sclchar **locale); - void on_update_lookup_table(SclCandidateTable &table); - - void on_create_option_window(sclwindow window, SCLOptionWindowType type); - void on_destroy_option_window(sclwindow window); - void on_check_option_window_availability(sclboolean *ret); - - void on_process_key_event(scim::KeyEvent &key, sclu32 *ret);// only for TV profile to handle remote control button - - void on_candidate_show(sclint ic, const sclchar *ic_uuid); - void on_candidate_hide(sclint ic, const sclchar *ic_uuid); -}; - void ise_send_string(const sclchar *key_value); void ise_update_preedit_string(const sclchar *str, const sclboolean underline = TRUE); void ise_send_event(sclulong key_event, sclulong key_mask); diff --git a/src/ise.cpp b/src/ise.cpp index 8e68ae2..edfd1f5 100644 --- a/src/ise.cpp +++ b/src/ise.cpp @@ -55,7 +55,6 @@ CSCLUI *g_ui = NULL; static cbhm_h cbhm_handle; #endif -static CCoreEventCallback g_core_event_callback; int g_imdata_state = 0; extern emoticon_group_t current_emoticon_group; @@ -352,282 +351,6 @@ static void create_softcandidate(void) } } -void CCoreEventCallback::on_init() -{ - LOGD("CCoreEventCallback::init()\n"); - ise_create(); - -#ifdef HAVE_CBHM - cbhm_open_service(&cbhm_handle); -#endif -} - -void CCoreEventCallback::on_exit() -{ - ::ise_hide(); - ise_destroy(); - -#ifdef HAVE_CBHM - cbhm_close_service(cbhm_handle); - cbhm_handle = NULL; -#endif -} - -void CCoreEventCallback::on_attach_input_context(sclint ic, const sclchar *ic_uuid) -{ - ise_attach_input_context(ic); -} - -void CCoreEventCallback::on_detach_input_context(sclint ic, const sclchar *ic_uuid) -{ - ise_detach_input_context(ic); -} - -void CCoreEventCallback::on_focus_in(sclint ic, const sclchar *ic_uuid) -{ - LOGD("Enter\n"); - ise_focus_in(ic); -} - -void CCoreEventCallback::on_focus_out(sclint ic, const sclchar *ic_uuid) -{ - LOGD("Enter\n"); - ise_focus_out(ic); - g_imdata_state = 0; -} - -void CCoreEventCallback::on_ise_show(sclint ic, const sclint degree, Ise_Context &context) -{ - LOGD("Enter\n"); - //g_ise_common->set_keyboard_ise_by_uuid(KEYBD_ISE_UUID); - - /* Don't update screen until all the information is correctly set */ - if (g_ui) - g_ui->set_update_pending(TRUE); - - ise_reset_context(); // reset ISE - - /*if (context.language == ECORE_IMF_INPUT_PANEL_LANG_ALPHABET) { - ise_explictly_set_language(PRIMARY_LATIN_LANGUAGE_INDEX); - }*/ - - _context_layout = context.layout; - _context_layout_variation = context.layout_variation; - ise_set_layout(context.layout, context.layout_variation); - - ise_set_return_key_type(context.return_key_type); - ise_set_return_key_disable(context.return_key_disabled); - - ise_set_caps_mode(context.caps_mode); - ise_update_cursor_position(context.cursor_pos); - - /* Do not follow the application's rotation angle if we are already in visible state, - since in that case we will receive the angle through ROTATION_CHANGE_REQUEST message */ - if (!(g_keyboard_state.visible_state)) { - ise_set_screen_rotation(degree); - } else { - LOGD("Skipping rotation angle , %d\n", degree); - } - - ::ise_show(ic); - - /* Now we update the whole screen */ - if (g_ui) - g_ui->set_update_pending(FALSE); -} - -void CCoreEventCallback::on_ise_hide(sclint ic, const sclchar *ic_uuid) -{ - LOGD("Enter\n"); - ::ise_hide(); -} - -void CCoreEventCallback::on_reset_input_context(sclint ic, const sclchar *uuid) -{ - ise_reset_input_context(); -} - -void CCoreEventCallback::on_set_display_language(const sclchar *language) -{ - setlocale(LC_ALL, language); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); - - LOGD("Language : %s\n", (language ? language : "NULL")); -} - -void CCoreEventCallback::on_set_accessibility_state(const sclboolean state) -{ - LOGD("state=%d\n", state); - ise_set_accessibility_state(state); -} - -void CCoreEventCallback::on_set_rotation_degree(sclint degree) -{ - ise_set_screen_rotation(degree); - - LOGD("degree=%d\n", degree); - if (is_emoticon_show()) { - ise_destroy_emoticon_layout(); - } - if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE) { - ise_hide_stt_mode(); - } - if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_EMOTICON) { - ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window()); - } else if (g_ui) { - const sclchar *input_mode = g_ui->get_input_mode(); - if (input_mode) { - if (!(strcmp(input_mode, "EMOTICON_LAYOUT"))) - ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window()); - else if (!(strcmp(input_mode, "STT_3X4"))) - ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window())); - } - } -} - -void CCoreEventCallback::on_set_layout(sclu32 layout) -{ - LOGD("layout=%d\n", layout); - /* Check if the layoutIdx is in the valid range */ - if (layout < ISE_LAYOUT_STYLE_MAX) { - if (g_keyboard_state.layout != layout) { - g_keyboard_state.need_reset = TRUE; - } - g_keyboard_state.layout = layout; - _context_layout = layout; - _context_layout_variation = 0; - } - if (g_keyboard_state.visible_state) - ise_show(g_keyboard_state.ic); -} - -void CCoreEventCallback::on_set_caps_mode(sclu32 mode) -{ - ise_set_caps_mode(mode); -} - -void CCoreEventCallback::on_update_cursor_position(sclint ic, const sclchar *ic_uuid, sclint cursor_pos) -{ - ise_update_cursor_position(cursor_pos); -} - -void CCoreEventCallback::on_update_surrounding_text(sclint ic, const sclchar *text, sclint cursor) -{ - LOGD("surrounding text:%s, cursor=%d\n", text, cursor); - ime_delete_surrounding_text(-cursor, strlen(text)); -} - -void CCoreEventCallback::on_set_return_key_type(sclu32 type) -{ - LOGD("Enter\n"); - ise_set_return_key_type(type); - - if (g_keyboard_state.visible_state) - ise_show(g_keyboard_state.ic); -} - -void CCoreEventCallback::on_set_return_key_disable(sclu32 disabled) -{ - ise_set_return_key_disable(disabled); -} - -void CCoreEventCallback::on_set_imdata(sclchar *buf, sclu32 len) -{ - LOGD("Enter\n"); - g_imdata_state = 0; - size_t _len = len; - set_ise_imdata(buf, _len); -} - -void CCoreEventCallback::on_get_language_locale(sclint ic, sclchar **locale) -{ - ise_get_language_locale(locale); -} - -void CCoreEventCallback::on_update_lookup_table(SclCandidateTable &table) -{ - LOGD("Enter\n"); - g_softcandidate_string = table.candidate; - ise_update_table(g_softcandidate_string); -} - -void CCoreEventCallback::on_create_option_window(sclwindow window, SCLOptionWindowType type) -{ - if (window) { - option_window_created(NATIVE_WINDOW_CAST(window), type); - } -} - -void CCoreEventCallback::on_destroy_option_window(sclwindow window) -{ - option_window_destroyed(NATIVE_WINDOW_CAST(window)); -} - -void CCoreEventCallback::on_check_option_window_availability(sclboolean *ret) -{ - if (ret) - *ret = true; // Tizen keyboard (ise-default) has the option window, but 3rd party IME may not. This interface is for it. -} - -/** -* This is only for the TV profile to handle remote control button -* It will be called in the TV profile by ISF logic. -*/ -void CCoreEventCallback::on_process_key_event(scim::KeyEvent &key, sclu32 *ret) -{ - LOGD("Enter\n"); - if (g_keyboard_state.visible_state) - ise_process_key_event(key, *ret); - else - ret = FALSE; -} - -void CCoreEventCallback::on_candidate_show(sclint ic, const sclchar *ic_uuid) -{ - LOGD("Enter\n"); - delete_softcandidate_hide_timer(); - - create_softcandidate(); - - g_softcandidate_show = true; - if (g_candidate) { - g_candidate->show(); - if (g_ui) { - g_ui->set_custom_starting_coordinates(0, g_candidate->get_height()); - SclSize size_portrait = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_PORTRAIT); - SclSize size_landscape = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_LANDSCAPE); - size_portrait.height += g_candidate->get_height(); - size_landscape.height += g_candidate->get_height(); - ime_set_size(size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height); - - LOGD("Showing candidate , position [%d %d] size [%d %d] [%d %d]", 0, g_candidate->get_height(), - size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height); - } - } -} - -void CCoreEventCallback::on_candidate_hide(sclint ic, const sclchar *ic_uuid) -{ - LOGD("Enter\n"); - - if (!g_candidate || !g_softcandidate_show) { - LOGD("No candidate\n"); - return; - } - - add_softcandidate_hide_timer(); - if (g_ui) { - g_ui->set_custom_starting_coordinates(0, 0); - SclSize size_portrait = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_PORTRAIT); - SclSize size_landscape = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_LANDSCAPE); - ime_set_size(size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height); - - LOGD("Hiding candidate , position [%d %d] size [%d %d] [%d %d]", 0, 0, - size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height); - } -} - /** * Send the given string to input framework */ @@ -1023,7 +746,7 @@ SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_d } else if (strncmp(event_desc.key_value, delete_all, strlen(delete_all)) == 0) { ime_delete_surrounding_text((INT_MAX / 2) * -1, INT_MAX); } else if (strncmp(event_desc.key_value, hide_panel, strlen(hide_panel)) == 0) { - ::ise_hide(); + ise_hide(); ime_request_hide(); } else if (event_desc.key_event) { ise_send_event(event_desc.key_event, KEY_MASK_NULL); @@ -1197,21 +920,6 @@ ise_focus_out(int ic) } void -ise_attach_input_context(int ic) -{ - LOGD("attaching, ic : %x , %x , g_ic : %x , %x, g_focused_ic : %x , %x\n", ic, check_ic_temporary(ic), - g_keyboard_state.ic, check_ic_temporary(g_keyboard_state.ic), - g_keyboard_state.focused_ic, check_ic_temporary(g_keyboard_state.focused_ic)); - ise_focus_in(ic); -} - -void -ise_detach_input_context(int ic) -{ - ise_focus_out(ic); -} - -void ise_show(int ic) { sclboolean reset_inputmode = FALSE; @@ -1877,12 +1585,22 @@ static void update_recent_used_punctuation(const char * key_value) static void ime_app_create_cb(void *user_data) { - g_core_event_callback.on_init(); + ise_create(); + +#ifdef HAVE_CBHM + cbhm_open_service(&cbhm_handle); +#endif } static void ime_app_exit_cb(void *user_data) { - g_core_event_callback.on_exit(); + ise_hide(); + ise_destroy(); + +#ifdef HAVE_CBHM + cbhm_close_service(cbhm_handle); + cbhm_handle = NULL; +#endif } static void ime_app_show_cb(int ic, ime_context_h ime_ctx, void *user_data) @@ -1917,24 +1635,64 @@ static void ime_app_show_cb(int ic, ime_context_h ime_ctx, void *user_data) g_ic = ic; - g_core_event_callback.on_ise_show(ic, 0, iseContext); + //g_ise_common->set_keyboard_ise_by_uuid(KEYBD_ISE_UUID); + + /* Don't update screen until all the information is correctly set */ + if (g_ui) + g_ui->set_update_pending(TRUE); + + ise_reset_context(); // reset ISE + + /*if (context.language == ECORE_IMF_INPUT_PANEL_LANG_ALPHABET) { + ise_explictly_set_language(PRIMARY_LATIN_LANGUAGE_INDEX); + }*/ + + _context_layout = iseContext.layout; + _context_layout_variation = iseContext.layout_variation; + ise_set_layout(iseContext.layout, iseContext.layout_variation); + + ise_set_return_key_type(iseContext.return_key_type); + ise_set_return_key_disable(iseContext.return_key_disabled); + + ise_set_caps_mode(iseContext.caps_mode); + ise_update_cursor_position(iseContext.cursor_pos); + + /* Do not follow the application's rotation angle if we are already in visible state, + since in that case we will receive the angle through ROTATION_CHANGE_REQUEST message */ + int degree = 0; + + if (!(g_keyboard_state.visible_state)) { + ise_set_screen_rotation(degree); + } else { + LOGD("Skipping rotation angle , %d\n", degree); + } + + ise_show(ic); + + /* Now we update the whole screen */ + if (g_ui) + g_ui->set_update_pending(FALSE); } static void ime_app_hide_cb(int ic, void *user_data) { - g_core_event_callback.on_ise_hide(ic, NULL); + LOGD("Enter\n"); + ise_hide(); } static void ime_app_return_key_type_set_cb(Ecore_IMF_Input_Panel_Return_Key_Type type, void *user_data) { LOGD("return key type : %d\n", type); - g_core_event_callback.on_set_return_key_type(type); + ise_set_return_key_type(type); + + if (g_keyboard_state.visible_state) + ise_show(g_keyboard_state.ic); } static void ime_app_return_key_state_set_cb(bool disabled, void *user_data) { LOGD("return key disabled : %d\n", disabled); - g_core_event_callback.on_set_return_key_disable(disabled); + ise_set_return_key_disable(disabled); } static void ime_app_input_context_reset_cb(void *user_data) @@ -1945,7 +1703,7 @@ static void ime_app_input_context_reset_cb(void *user_data) static void ime_app_cursor_position_updated_cb(int cursor_pos, void *user_data) { LOGD("cursor position : %d\n", cursor_pos); - g_core_event_callback.on_update_cursor_position(g_ic, "", cursor_pos); + ise_update_cursor_position(cursor_pos); } static void ime_app_language_requested_cb(void *user_data, char **lang_code) @@ -1955,72 +1713,149 @@ static void ime_app_language_requested_cb(void *user_data, char **lang_code) static void ime_app_surrounding_text_updated_cb(int context_id, const char *text, int cursor_pos, void *user_data) { - LOGD("cursor position : %d\n", cursor_pos); - g_core_event_callback.on_update_surrounding_text(context_id, text, cursor_pos); + LOGD("surrounding text:%s, cursor=%d\n", text, cursor_pos); + ime_delete_surrounding_text(-cursor_pos, strlen(text)); } static void ime_app_focus_in_cb(int context_id, void *user_data) { - g_core_event_callback.on_focus_in(context_id, NULL); + LOGD("Enter\n"); + ise_focus_in(context_id); } static void ime_app_focus_out_cb(int context_id, void *user_data) { - g_core_event_callback.on_focus_out(context_id, NULL); + LOGD("Enter\n"); + ise_focus_out(context_id); + g_imdata_state = 0; } static void ime_app_layout_set_cb(Ecore_IMF_Input_Panel_Layout layout, void *user_data) { - g_core_event_callback.on_set_layout(layout); + LOGD("layout=%d\n", layout); + /* Check if the layoutIdx is in the valid range */ + if ((ISE_LAYOUT)layout < ISE_LAYOUT_STYLE_MAX) { + if (g_keyboard_state.layout != layout) { + g_keyboard_state.need_reset = TRUE; + } + g_keyboard_state.layout = layout; + _context_layout = layout; + _context_layout_variation = 0; + } + if (g_keyboard_state.visible_state) + ise_show(g_keyboard_state.ic); } static void ime_app_option_window_created_cb(Evas_Object *window, ime_option_window_type_e type, void *user_data) { - g_core_event_callback.on_create_option_window(SCL_WINDOW_CAST(window), (SCLOptionWindowType)type); + if (window) { + option_window_created(window, (SCLOptionWindowType)type); + } } static void ime_app_option_window_destroyed_cb(Evas_Object *window, void *user_data) { - g_core_event_callback.on_destroy_option_window(SCL_WINDOW_CAST(window)); + option_window_destroyed(window); } static void ime_app_rotation_degree_changed_cb(int degree, void *user_data) { - g_core_event_callback.on_set_rotation_degree(degree); + ise_set_screen_rotation(degree); + + LOGD("degree=%d\n", degree); + if (is_emoticon_show()) { + ise_destroy_emoticon_layout(); + } + if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE) { + ise_hide_stt_mode(); + } + if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_EMOTICON) { + ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window()); + } else if (g_ui) { + const sclchar *input_mode = g_ui->get_input_mode(); + if (input_mode) { + if (!(strcmp(input_mode, "EMOTICON_LAYOUT"))) + ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window()); + else if (!(strcmp(input_mode, "STT_3X4"))) + ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window())); + } + } } static void ime_app_accessibility_state_changed_cb(bool state, void *user_data) { - g_core_event_callback.on_set_accessibility_state(state); + LOGD("state=%d\n", state); + ise_set_accessibility_state(state); } static void ime_app_imdata_set_cb(void *data, unsigned int data_length, void *user_data) { - g_core_event_callback.on_set_imdata((sclchar *)data, data_length); + LOGD("Enter\n"); + g_imdata_state = 0; + size_t _len = data_length; + set_ise_imdata((sclchar *)data, _len); } static bool ime_app_process_key_event_cb(ime_key_code_e keycode, ime_key_mask_e keymask, ime_device_info_h dev_info, void *user_data) { scim::KeyEvent key(keycode, keymask); unsigned int ret; - g_core_event_callback.on_process_key_event(key, &ret); + if (g_keyboard_state.visible_state) + ise_process_key_event(key, ret); + else + ret = FALSE; return ret; } static void ime_app_caps_mode_changed_cb(int mode, void *user_data) { - g_core_event_callback.on_set_caps_mode(mode); + ise_set_caps_mode(mode); } static void ime_app_candidate_show_cb(int context_id, void *user_data) { - g_core_event_callback.on_candidate_show(context_id, ""); + LOGD("Enter\n"); + delete_softcandidate_hide_timer(); + + create_softcandidate(); + + g_softcandidate_show = true; + if (g_candidate) { + g_candidate->show(); + if (g_ui) { + g_ui->set_custom_starting_coordinates(0, g_candidate->get_height()); + SclSize size_portrait = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_PORTRAIT); + SclSize size_landscape = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_LANDSCAPE); + size_portrait.height += g_candidate->get_height(); + size_landscape.height += g_candidate->get_height(); + ime_set_size(size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height); + + LOGD("Showing candidate , position [%d %d] size [%d %d] [%d %d]", 0, g_candidate->get_height(), + size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height); + } + } } static void ime_app_candidate_hide_cb(int context_id, void *user_data) { - g_core_event_callback.on_candidate_hide(context_id, ""); + LOGD("Enter\n"); + + if (!g_candidate || !g_softcandidate_show) { + LOGD("No candidate\n"); + return; + } + + add_softcandidate_hide_timer(); + if (g_ui) { + g_ui->set_custom_starting_coordinates(0, 0); + SclSize size_portrait = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_PORTRAIT); + SclSize size_landscape = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_LANDSCAPE); + ime_set_size(size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height); + + LOGD("Hiding candidate , position [%d %d] size [%d %d] [%d %d]", 0, 0, + size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height); + } } static void ime_app_lookup_table_changed_cb(Eina_List *list, void *user_data) diff --git a/src/sdk/sdk.cpp b/src/sdk/sdk.cpp index f798fec..a870aad 100644 --- a/src/sdk/sdk.cpp +++ b/src/sdk/sdk.cpp @@ -16,7 +16,6 @@ */ #include -#include #include #include -- 2.7.4