From: Jihoon Kim Date: Fri, 17 Feb 2017 08:14:08 +0000 (+0900) Subject: Add recapture_string interface X-Git-Tag: accepted/tizen/3.0/common/20170220.130033~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F45%2F115345%2F2;p=platform%2Fcore%2Fuifw%2Fisf.git Add recapture_string interface recapture string will be used for deleting the existed text and inserting preedit or commit string. It's for avoiding the blinking due to the deleting and update preedit or commit string Change-Id: I509755429e1e9c78cd1e2d27e4c821c669fc234f Signed-off-by: Jihoon Kim --- diff --git a/ism/extras/wayland_immodule/wayland_imcontext.c b/ism/extras/wayland_immodule/wayland_imcontext.c index 8ad3329..8676fd2 100644 --- a/ism/extras/wayland_immodule/wayland_imcontext.c +++ b/ism/extras/wayland_immodule/wayland_imcontext.c @@ -1145,12 +1145,12 @@ text_input_commit_string(void *data, text, imcontext->preedit_text ? imcontext->preedit_text : ""); - old_preedit = - imcontext->preedit_text && strlen(imcontext->preedit_text) > 0; - if (!imcontext->ctx) return; + old_preedit = + imcontext->preedit_text && strlen(imcontext->preedit_text) > 0; + if (!check_serial(imcontext, serial)) return; @@ -1631,6 +1631,19 @@ show_input_panel(Ecore_IMF_Context *ctx) return EINA_TRUE; } +static void delete_surrounding_text(WaylandIMContext *imcontext, int index, int length) +{ + Ecore_IMF_Event_Delete_Surrounding ev; + LOGD("delete surrounding text (index: %d, length: %u)", + index, length); + + ev.offset = index; + ev.n_chars = length; + + ecore_imf_context_delete_surrounding_event_add(imcontext->ctx, ev.offset, ev.n_chars); + ecore_imf_context_event_callback_call(imcontext->ctx, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, &ev); +} + static void text_input_preedit_string(void *data, struct wl_text_input *text_input EINA_UNUSED, @@ -1696,15 +1709,7 @@ text_input_delete_surrounding_text(void *data, uint32_t length) { WaylandIMContext *imcontext = (WaylandIMContext *)data; - Ecore_IMF_Event_Delete_Surrounding ev; - LOGD("delete surrounding text (index: %d, length: %u)", - index, length); - - ev.offset = index; - ev.n_chars = length; - - ecore_imf_context_delete_surrounding_event_add(imcontext->ctx, ev.offset, ev.n_chars); - ecore_imf_context_event_callback_call(imcontext->ctx, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, &ev); + delete_surrounding_text(imcontext, index, length); } static void @@ -2233,6 +2238,83 @@ text_input_hide_permission(void *data, if (permission) ecore_imf_context_input_panel_hide(imcontext->ctx); } + +static void +text_input_recapture_string(void *data, + struct wl_text_input *text_input EINA_UNUSED, + uint32_t serial, + int32_t index, + uint32_t length, + const char *preedit, + const char *preedit_commit, + const char *commit) +{ + WaylandIMContext *imcontext = (WaylandIMContext *)data; + Eina_Bool old_preedit = EINA_FALSE; + Eina_Bool preedit_changed = EINA_FALSE; + + SECURE_LOGD("preedit event (preedit: '%s', current pre-edit: '%s')", + preedit, + imcontext->preedit_text ? imcontext->preedit_text : ""); + + if (!check_serial(imcontext, serial)) + return; + + old_preedit = + imcontext->preedit_text && strlen(imcontext->preedit_text) > 0; + + if (imcontext->preedit_text) + preedit_changed = (strcmp(imcontext->preedit_text, preedit) != 0); + else + preedit_changed = (strlen(preedit) != 0); + + clear_preedit(imcontext); + + // send transaction start + ecore_imf_context_event_callback_call(imcontext->ctx, ECORE_IMF_CALLBACK_PRIVATE_COMMAND_SEND, (void *)"TRANSACTION_START"); + + // delete surrounding text + delete_surrounding_text(imcontext, index, length); + + // update preedit string + imcontext->preedit_text = strdup(preedit); + imcontext->preedit_commit = (strlen(preedit) > 0 ? strdup(preedit_commit) : NULL); + imcontext->preedit_cursor = + utf8_offset_to_characters(preedit, imcontext->pending_preedit.cursor); + imcontext->preedit_attrs = imcontext->pending_preedit.attrs; + + imcontext->pending_preedit.attrs = NULL; + + if (preedit_changed) { + if (!old_preedit) { + ecore_imf_context_preedit_start_event_add(imcontext->ctx); + ecore_imf_context_event_callback_call(imcontext->ctx, + ECORE_IMF_CALLBACK_PREEDIT_START, + NULL); + } + + ecore_imf_context_preedit_changed_event_add(imcontext->ctx); + ecore_imf_context_event_callback_call(imcontext->ctx, + ECORE_IMF_CALLBACK_PREEDIT_CHANGED, + NULL); + + if (imcontext->preedit_text && strlen(imcontext->preedit_text) == 0) { + ecore_imf_context_preedit_end_event_add(imcontext->ctx); + ecore_imf_context_event_callback_call(imcontext->ctx, + ECORE_IMF_CALLBACK_PREEDIT_END, + NULL); + } + } + + // commit string + if (commit && strlen(commit) != 0) { + ecore_imf_context_commit_event_add(imcontext->ctx, commit); + ecore_imf_context_event_callback_call(imcontext->ctx, ECORE_IMF_CALLBACK_COMMIT, (void *)commit); + } + + // send transaction end + ecore_imf_context_event_callback_call(imcontext->ctx, ECORE_IMF_CALLBACK_PRIVATE_COMMAND_SEND, (void *)"TRANSACTION_END"); +} // static const struct wl_text_input_listener text_input_listener = @@ -2258,7 +2340,8 @@ static const struct wl_text_input_listener text_input_listener = text_input_get_selection_text, text_input_get_surrounding_text, text_input_filter_key_event_done, - text_input_hide_permission + text_input_hide_permission, + text_input_recapture_string // }; diff --git a/ism/modules/frontend/scim_socket_frontend.cpp b/ism/modules/frontend/scim_socket_frontend.cpp index fb9c47d..309d870 100644 --- a/ism/modules/frontend/scim_socket_frontend.cpp +++ b/ism/modules/frontend/scim_socket_frontend.cpp @@ -541,6 +541,19 @@ SocketFrontEnd::commit_utf8_string (int id, const char * buf, int buflen) } void +SocketFrontEnd::recapture_string (int id, int offset, int len, const WideString & preedit, const WideString & commit, const AttributeList & attrs) +{ + if (m_current_instance == id) { + m_send_trans.put_command (ISM_TRANS_CMD_RECAPTURE_STRING); + m_send_trans.put_data ((uint32) offset); + m_send_trans.put_data ((uint32) len); + m_send_trans.put_data (preedit); + m_send_trans.put_data (attrs); + m_send_trans.put_data (commit); + } +} + +void SocketFrontEnd::forward_key_event (int id, const KeyEvent & key) { if (m_current_instance == id) { diff --git a/ism/modules/frontend/scim_socket_frontend.h b/ism/modules/frontend/scim_socket_frontend.h index 38787c5..17941b8 100644 --- a/ism/modules/frontend/scim_socket_frontend.h +++ b/ism/modules/frontend/scim_socket_frontend.h @@ -135,6 +135,7 @@ protected: virtual void update_aux_utf8_string (int id, const char * buf, int buflen, const AttributeList & attrs); virtual void commit_string (int id, const WideString & str); virtual void commit_utf8_string (int id, const char * buf, int buflen); + virtual void recapture_string (int id, int offset, int len, const WideString & preedit, const WideString & commit, const AttributeList & attrs); virtual void forward_key_event (int id, const KeyEvent & key); virtual void update_lookup_table (int id, const LookupTable & table); diff --git a/ism/modules/imengine/Makefile.am b/ism/modules/imengine/Makefile.am index 54634f6..bd9ac35 100644 --- a/ism/modules/imengine/Makefile.am +++ b/ism/modules/imengine/Makefile.am @@ -55,6 +55,6 @@ socket_la_LDFLAGS = -avoid-version \ $(LD_VERSION_SCRIPT_OPTION) \ @LIBTOOL_EXPORT_OPTIONS@ \ @LTLIBINTL@ - + socket_la_LIBADD = $(top_builddir)/ism/src/libscim@SCIM_EPOCH@.la diff --git a/ism/modules/imengine/scim_socket_imengine.cpp b/ism/modules/imengine/scim_socket_imengine.cpp index 265de92..2461590 100644 --- a/ism/modules/imengine/scim_socket_imengine.cpp +++ b/ism/modules/imengine/scim_socket_imengine.cpp @@ -56,7 +56,6 @@ #include "scim_stl_map.h" #include "isf_query_utility.h" - #define scim_module_init socket_LTX_scim_module_init #define scim_module_exit socket_LTX_scim_module_exit #define scim_imengine_module_init socket_LTX_scim_imengine_module_init @@ -1102,6 +1101,19 @@ SocketInstance::do_transaction (Transaction &trans, bool &ret) } break; } + case ISM_TRANS_CMD_RECAPTURE_STRING: + { + uint32 offset; + uint32 len; + WideString preedit, commit; + AttributeList attrs; + if (trans.get_data (offset) && trans.get_data (len) && + trans.get_data (preedit) && trans.get_data (commit) && trans.get_data (attrs)) { + SCIM_DEBUG_IMENGINE(3) << " recapture_string ()\n"; + recapture_string (offset, len, preedit, commit, attrs); + } + break; + } case SCIM_TRANS_CMD_UPDATE_AUX_STRING: { WideString str; diff --git a/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp b/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp index d26dad1..3a2fa9c 100644 --- a/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp +++ b/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp @@ -2343,6 +2343,26 @@ private: m_info_manager->socket_update_aux_string(str, attrs); else LOGW ("wrong format of transaction\n"); + } else if (cmd == ISM_TRANS_CMD_RECAPTURE_STRING) { + uint32 target_ic; + String target_uuid; + uint32 offset; + uint32 len; + WideString preedit; + WideString commit; + AttributeList attrs; + + if (m_recv_trans.get_data(target_ic) && + m_recv_trans.get_data(target_uuid) && + m_recv_trans.get_data(offset) && + m_recv_trans.get_data(len) && + m_recv_trans.get_data(preedit) && + m_recv_trans.get_data(commit) && + m_recv_trans.get_data(attrs)) { + m_info_manager->socket_helper_recapture_string(client_id, target_ic, target_uuid, offset, len, preedit, commit, attrs); + } else { + LOGW ("wrong format of transaction\n"); + } } else if (cmd == SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE) { CommonLookupTable _isf_candidate_table; @@ -2543,7 +2563,6 @@ private: m_info_manager->socket_update_aux_string(str, attrs); else LOGW ("wrong format of transaction\n"); - } else if (cmd == SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE) { CommonLookupTable _isf_candidate_table; @@ -2761,6 +2780,26 @@ private: } } else if (cmd == ISM_TRANS_CMD_REQUEST_ISE_HIDE) { m_info_manager->request_ise_hide(); + } else if (cmd == ISM_TRANS_CMD_RECAPTURE_STRING) { + uint32 target_ic; + String target_uuid; + uint32 offset; + uint32 len; + WideString preedit; + WideString commit; + AttributeList attrs; + + if (m_recv_trans.get_data(target_ic) && + m_recv_trans.get_data(target_uuid) && + m_recv_trans.get_data(offset) && + m_recv_trans.get_data(len) && + m_recv_trans.get_data(preedit) && + m_recv_trans.get_data(commit) && + m_recv_trans.get_data(attrs)) { + m_info_manager->socket_helper_recapture_string(client_id, target_ic, target_uuid, offset, len, preedit, commit, attrs); + } else { + LOGW ("wrong format of transaction\n"); + } } else { LOGW ("unknown cmd: %d\n", cmd); } diff --git a/ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp b/ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp index d2b9841..b5b45a8 100644 --- a/ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp +++ b/ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp @@ -1676,15 +1676,12 @@ wsc_commit_preedit (WSCContextISF* wsc_ctx) } static void -wsc_send_preedit (WSCContextISF* wsc_ctx, int32_t cursor) +wsc_send_preedit_style (WSCContextISF* wsc_ctx) { LOGD (""); if (!wsc_ctx) return; - - uint32_t index = strlen (wsc_ctx->preedit_str); - - if (wsc_ctx && wsc_ctx->impl && wsc_ctx->impl->is_on) { + if (wsc_ctx->impl && wsc_ctx->impl->is_on) { String mbs = utf8_wcstombs (wsc_ctx->impl->preedit_string); if (!wsc_ctx->impl->preedit_attrlist.empty ()) { @@ -1777,6 +1774,18 @@ wsc_send_preedit (WSCContextISF* wsc_ctx, int32_t cursor) if (!wsc_ctx->impl->preedit_attrlist.empty ()) wsc_ctx->impl->preedit_attrlist.clear (); } +} + +static void +wsc_send_preedit (WSCContextISF* wsc_ctx, int32_t cursor) +{ + LOGD (""); + + if (!wsc_ctx) return; + + uint32_t index = strlen (wsc_ctx->preedit_str); + + wsc_send_preedit_style (wsc_ctx); if (cursor > 0) index = cursor; @@ -2870,6 +2879,47 @@ public: } } + void + recapture_string (int id, uint32 context_id, int offset, int len, WideString preedit, WideString commit, AttributeList& attrs) { + LOGD ("client id:%d", id); + SCIM_DEBUG_FRONTEND (1) << __FUNCTION__ << "...\n"; + WSCContextISF* ic = find_ic (context_id); + String preedit_str = utf8_wcstombs (preedit); + String commit_str = utf8_wcstombs (commit); + + if (ic && ic->impl && _focused_ic == ic) { + if (!ic->impl->is_on) + ic->impl->is_on = true; + + check_input_resource (ic, INPUT_RESOURCE_LOCAL); + + ic->impl->preedit_string = preedit; + ic->impl->preedit_attrlist = attrs; + ic->impl->commit_string = commit; + + if (ic->impl->use_preedit) { + if (!ic->impl->preedit_started) { + if (!check_valid_ic (ic)) + return; + + ic->impl->preedit_started = true; + ic->impl->need_commit_preedit = true; + } + ic->impl->preedit_caret = preedit.length (); + + // FIXME : cursor position + wl_input_method_context_preedit_cursor (ic->im_ctx, preedit.length()); + + wsc_send_preedit_style (ic); + + wl_input_method_context_recapture_string (ic->im_ctx, ic->serial, + offset, len, preedit_str.c_str(), preedit_str.c_str(), commit_str.c_str()); + } else { + g_info_manager->socket_recapture_string (offset, len, preedit_str, commit_str, attrs); + } + } + } + static Eina_Bool surrounding_text_fd_read_func (void* data, Ecore_Fd_Handler* fd_handler) { if (fd_handler == NULL || data == NULL) diff --git a/ism/src/isf_info_manager.cpp b/ism/src/isf_info_manager.cpp index 9245557..2ee58e1 100644 --- a/ism/src/isf_info_manager.cpp +++ b/ism/src/isf_info_manager.cpp @@ -142,6 +142,9 @@ InfoManagerSignalIntHelperInfo; typedef Signal3 InfoManagerSignalAttributeStringInt; +typedef Signal5 +InfoManagerSignalAttributeInt2String2; + typedef Signal2 InfoManagerSignalAttributeString; @@ -330,6 +333,7 @@ class InfoManager::InfoManagerImpl InfoManagerSignalVoid m_signal_hide_lookup_table; InfoManagerSignalVoid m_signal_hide_associate_table; InfoManagerSignalAttributeStringInt m_signal_update_preedit_string; + InfoManagerSignalAttributeInt2String2 m_signal_recapture_string; InfoManagerSignalInt m_signal_update_preedit_caret; InfoManagerSignalAttributeString m_signal_update_aux_string; InfoManagerSignalLookupTable m_signal_update_lookup_table; @@ -2169,6 +2173,10 @@ public: return m_signal_update_preedit_caret.connect (slot); } + Connection signal_connect_recapture_string (InfoManagerSlotAttributeInt2String2* slot) { + return m_signal_recapture_string.connect (slot); + } + Connection signal_connect_update_aux_string (InfoManagerSlotAttributeString* slot) { return m_signal_update_aux_string.connect (slot); } @@ -2915,7 +2923,6 @@ client context helpers: %d, helpers uuid count: %d", m_signal_show_factory_menu (vec); } - //SCIM_TRANS_CMD_SHOW_PREEDIT_STRING void socket_show_preedit_string (void) { LOGD (""); @@ -2976,6 +2983,12 @@ client context helpers: %d, helpers uuid count: %d", LOGD (""); m_signal_update_preedit_caret ((int) caret); } + //ISM_TRANS_CMD_RECAPTURE_STRING + void socket_recapture_string (int offset, int len, String& preedit, String& commit, const AttributeList& attrs) { + SCIM_DEBUG_MAIN (4) << "InfoManager::socket_update_preedit_caret ()\n"; + LOGD (""); + m_signal_recapture_string (offset, len, preedit, commit, attrs); + } //SCIM_TRANS_CMD_UPDATE_AUX_STRING void socket_update_aux_string (String& str, const AttributeList& attrs) { SCIM_DEBUG_MAIN (4) << "InfoManager::socket_update_aux_string ()\n"; @@ -3569,6 +3582,37 @@ client context helpers: %d, helpers uuid count: %d", } } + //ISM_TRANS_CMD_RECAPTURE_STRING + void socket_helper_recapture_string (int client, uint32 target_ic, String target_uuid, int offset, int len, WideString preedit, + WideString commit, AttributeList& attrs) { + SCIM_DEBUG_MAIN (4) << "InfoManager::socket_helper_recapture_string (" << client << ")\n"; + int target_client; + uint32 target_context; + get_imengine_client_context (target_ic, target_client, target_context); + int focused_client; + uint32 focused_context; + String focused_uuid; + focused_uuid = get_focused_context (focused_client, focused_context); + + if (target_ic == (uint32) (-1)) { + target_client = focused_client; + target_context = focused_context; + } + + if (target_uuid.length () == 0) + target_uuid = focused_uuid; + + if (target_uuid == focused_uuid && + clients_equal (target_client, focused_client) && + contexts_equal (target_context, focused_context)) { + ClientInfo client_info = socket_get_client_info (focused_client); + + if (client_info.type == FRONTEND_CLIENT) { + m_panel_agent_manager.recapture_string (focused_client, focused_context, offset, len, preedit, commit, attrs); + } + } + } + //SCIM_TRANS_CMD_PANEL_REGISTER_HELPER void socket_helper_register_helper (int client, HelperInfo& info) { SCIM_DEBUG_MAIN (4) << "InfoManager::socket_helper_register_helper (" << client << ")\n"; @@ -4887,6 +4931,12 @@ void InfoManager::socket_update_preedit_caret (uint32 caret) m_impl->socket_update_preedit_caret (caret); } +//ISM_TRANS_CMD_RECAPTURE_STRING +void InfoManager::socket_recapture_string (int offset, int len, String& preedit, String& commit, const AttributeList& attrs) +{ + m_impl->socket_recapture_string (offset, len, preedit, commit, attrs); +} + //SCIM_TRANS_CMD_UPDATE_AUX_STRING void InfoManager::socket_update_aux_string (String& str, const AttributeList& attrs) { @@ -5081,6 +5131,13 @@ void InfoManager::socket_helper_update_preedit_caret (int client, uint32 caret) m_impl->socket_helper_update_preedit_caret (client, caret); } +//ISM_TRANS_CMD_RECAPTURE_STRING +void InfoManager::socket_helper_recapture_string (int client, uint32 target_ic, String target_uuid, int offset, int len, WideString preedit, + WideString commit, AttributeList& attrs) +{ + m_impl->socket_helper_recapture_string (client, target_ic, target_uuid, offset, len, preedit, commit, attrs); +} + //SCIM_TRANS_CMD_PANEL_REGISTER_HELPER void InfoManager::socket_helper_register_helper (int client, HelperInfo& info) { diff --git a/ism/src/isf_info_manager.h b/ism/src/isf_info_manager.h index 6d21384..e2e4c3d 100644 --- a/ism/src/isf_info_manager.h +++ b/ism/src/isf_info_manager.h @@ -151,6 +151,9 @@ InfoManagerSlotAttributeString; typedef Slot3 InfoManagerSlotAttributeStringInt; +typedef Slot5 +InfoManagerSlotAttributeInt2String2; + typedef Slot1 &> InfoManagerSlotStringVector; @@ -821,6 +824,9 @@ public: //SCIM_TRANS_CMD_UPDATE_AUX_STRING void socket_update_aux_string (String& str, const AttributeList& attrs); + //ISM_TRANS_CMD_RECAPTURE_STRING + void socket_recapture_string (int offset, int len, String& preedit, String& commit, const AttributeList& attrs); + //SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE void socket_update_lookup_table (const LookupTable& table); @@ -915,6 +921,9 @@ public: //SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET void socket_helper_update_preedit_caret (int client, uint32 caret); + //ISM_TRANS_CMD_RECAPTURE_STRING + void socket_helper_recapture_string (int client, uint32 target_ic, String target_uuid, int offset, int len, WideString preedit, WideString commit, AttributeList& attrs); + //SCIM_TRANS_CMD_PANEL_REGISTER_HELPER void socket_helper_register_helper (int client, HelperInfo& info); @@ -1164,6 +1173,13 @@ public: Connection signal_connect_update_preedit_caret (InfoManagerSlotInt* slot); /** + * @brief Signal: Recapture string. + * + * slot prototype: void recapture_string (int offset, int length, String preedit, String commit, Attribute &attrs); + */ + Connection signal_connect_recapture_string (InfoManagerSlotAttributeInt2String2* slot); + + /** * @brief Signal: Update aux string. * * slot prototype: void update_aux_string (const String &str, const AttributeList &attrs); diff --git a/ism/src/isf_panel_agent_base.cpp b/ism/src/isf_panel_agent_base.cpp index 4594dcf..c12c120 100644 --- a/ism/src/isf_panel_agent_base.cpp +++ b/ism/src/isf_panel_agent_base.cpp @@ -511,6 +511,12 @@ void PanelAgentBase::update_preedit_caret (int client, uint32 context, uint32 ca { LOGW ("not implemented for %s", m_name.c_str ()); } +//socket_helper_recapture_string +//ISM_TRANS_CMD_RECAPTURE_STRING +void PanelAgentBase::recapture_string (int client, uint32 context, int offset, int len, WideString preedit, WideString commit, AttributeList& attrs) +{ + LOGW ("not implemented for %s", m_name.c_str ()); +} //socket_helper_register_helper //SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT //SCIM_TRANS_CMD_UPDATE_SCREEN diff --git a/ism/src/isf_panel_agent_base.h b/ism/src/isf_panel_agent_base.h index 0cdf061..cf45eac 100644 --- a/ism/src/isf_panel_agent_base.h +++ b/ism/src/isf_panel_agent_base.h @@ -818,6 +818,15 @@ public: virtual void update_preedit_caret (int client, uint32 context, uint32 caret); /** + * @brief recapture_string. + * + * @param + * + * @return none. + */ + virtual void recapture_string (int client, uint32 context, int offset, int len, WideString preedit, WideString commit, AttributeList& attrs); + + /** * @brief attach_input_context and update_screen. * * @param diff --git a/ism/src/isf_panel_agent_manager.cpp b/ism/src/isf_panel_agent_manager.cpp index 5b6a742..e76b208 100644 --- a/ism/src/isf_panel_agent_manager.cpp +++ b/ism/src/isf_panel_agent_manager.cpp @@ -813,6 +813,14 @@ void PanelAgentManager::update_preedit_caret (int id, uint32 context_id, uint32 _p->update_preedit_caret (id, context_id, caret); } +void PanelAgentManager::recapture_string (int id, uint32 context_id, int offset, int len, WideString preedit, WideString commit, AttributeList& attrs) +{ + PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id); + + if (!_p.null ()) + _p->recapture_string (id, context_id, offset, len, preedit, commit, attrs); +} + void PanelAgentManager::helper_attach_input_context_and_update_screen (int id, std::vector < std::pair >& helper_ic_index, uint32 current_screen) { diff --git a/ism/src/isf_panel_agent_manager.h b/ism/src/isf_panel_agent_manager.h index 2a84f91..5308b0f 100644 --- a/ism/src/isf_panel_agent_manager.h +++ b/ism/src/isf_panel_agent_manager.h @@ -345,6 +345,7 @@ public: void hide_preedit_string (int target_client, uint32 target_context); void update_preedit_string (int target_client, uint32 target_context, WideString preedit, WideString commit, AttributeList& attrs, uint32 caret); void update_preedit_caret (int focused_client, uint32 focused_context, uint32 caret); + void recapture_string (int target_client, uint32 target_context, int offset, int len, WideString preedit, WideString commit, AttributeList& attrs); void helper_attach_input_context_and_update_screen (int client, std::vector < std::pair >& helper_ic_index, uint32 current_screen); void hide_helper_ise (int id, uint32 context); bool process_input_device_event(int client, uint32 context, const String& uuid, uint32 type, const char *data, size_t len, _OUT_ uint32& result); diff --git a/ism/src/scim_frontend.cpp b/ism/src/scim_frontend.cpp index d2e672f..1ad0643 100644 --- a/ism/src/scim_frontend.cpp +++ b/ism/src/scim_frontend.cpp @@ -131,6 +131,10 @@ public: m_frontend->commit_utf8_string (si->get_id (), buf, buflen); } + void slot_recapture_string (IMEngineInstanceBase * si, int offset, int len, const WideString & preedit, const WideString & commit, const AttributeList & attrs) { + m_frontend->recapture_string (si->get_id (), offset, len, preedit, commit, attrs); + } + void slot_forward_key_event (IMEngineInstanceBase * si, const KeyEvent & key) { m_frontend->forward_key_event (si->get_id (), key); } @@ -225,6 +229,9 @@ public: si->signal_connect_commit_utf8_string ( slot (this, &FrontEndBase::FrontEndBaseImpl::slot_commit_utf8_string)); + si->signal_connect_recapture_string ( + slot (this, &FrontEndBase::FrontEndBaseImpl::slot_recapture_string)); + si->signal_connect_forward_key_event ( slot (this, &FrontEndBase::FrontEndBaseImpl::slot_forward_key_event)); @@ -921,6 +928,10 @@ FrontEndBase::commit_utf8_string (int id, const char * buf, int buflen) { } void +FrontEndBase::recapture_string (int id, int offset, int len, const WideString & preedit, const WideString & commit, const AttributeList & attrs) +{ +} +void FrontEndBase::forward_key_event (int id, const KeyEvent & key) { } diff --git a/ism/src/scim_frontend.h b/ism/src/scim_frontend.h index 4e8fbe1..04e4300 100644 --- a/ism/src/scim_frontend.h +++ b/ism/src/scim_frontend.h @@ -655,6 +655,8 @@ protected: */ virtual void commit_utf8_string (int id, const char * buf, int buflen); + virtual void recapture_string (int id, int offset, int len, const WideString & preedit, const WideString & commit, const AttributeList & attrs); + /** * @brief forward a keyevent to the client of an IMEngine instance. * @param id the id of the IMEngine instance. diff --git a/ism/src/scim_helper.cpp b/ism/src/scim_helper.cpp index bb3ca9d..5df13c3 100644 --- a/ism/src/scim_helper.cpp +++ b/ism/src/scim_helper.cpp @@ -331,6 +331,18 @@ public: } void + slot_recapture_string (IMEngineInstanceBase *si, + int offset, + int len, + const WideString & preedit, + const WideString & commit, + const AttributeList & attrs) + { + LOGD (""); + thiz->recapture_string (-1, "", offset, len, preedit, commit, attrs); + } + + void slot_forward_key_event (IMEngineInstanceBase *si, const KeyEvent & key) { @@ -490,6 +502,8 @@ public: slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string)); si->signal_connect_update_preedit_string_with_commit ( slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string_with_commit)); + si->signal_connect_recapture_string ( + slot (this, &HelperAgent::HelperAgentImpl::slot_recapture_string)); si->signal_connect_update_aux_string ( slot (this, &HelperAgent::HelperAgentImpl::slot_update_aux_string)); @@ -2543,6 +2557,46 @@ HelperAgent::request_ise_hide (void) const } /** + * @brief Recapture + */ +void +HelperAgent::recapture_string (int ic, + const String &ic_uuid, + int offset, + int len, + const WideString &preedit_str, + const WideString &commit_str, + const AttributeList &attrs) const +{ + LOGD ("offset = %d, len = %d", offset, len); + + if (m_impl->socket_active.is_connected ()) { + m_impl->send.clear (); + m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST); + m_impl->send.put_data (m_impl->magic_active); + m_impl->send.put_command (ISM_TRANS_CMD_RECAPTURE_STRING); + + m_impl->send.put_data ((uint32)ic); + m_impl->send.put_data (ic_uuid); + + // Deleting surrounding text + m_impl->send.put_data (offset); + m_impl->send.put_data (len); + + // Update preedit text + m_impl->send.put_data (preedit_str); + + // Commit + m_impl->send.put_data (commit_str); + + // preedit attributes + m_impl->send.put_data (attrs); + + m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active); + } +} + +/** * @brief Connect a slot to Helper exit signal. * * This signal is used to let the Helper exit. diff --git a/ism/src/scim_helper.h b/ism/src/scim_helper.h index cdaa134..8985bc3 100644 --- a/ism/src/scim_helper.h +++ b/ism/src/scim_helper.h @@ -754,6 +754,14 @@ public: */ void request_ise_hide (void) const; + void recapture_string (int ic, + const String &ic_uuid, + int offset, + int len, + const WideString &preedit_str, + const WideString &commit_str, + const AttributeList &attrs) const; + public: /** * @brief Connect a slot to Helper exit signal. diff --git a/ism/src/scim_imengine.cpp b/ism/src/scim_imengine.cpp index f49321d..42d177f 100644 --- a/ism/src/scim_imengine.cpp +++ b/ism/src/scim_imengine.cpp @@ -94,6 +94,9 @@ typedef Signal4 IMEngineSignalWideStringWideStringAttributeListInt; +typedef Signal6 + IMEngineSignalInt2WideStringWideStringAttributeList; + typedef Signal5 IMEngineSignalGetSurroundingText; @@ -137,6 +140,7 @@ public: IMEngineSignalWideStringAttributeList m_signal_update_aux_string; IMEngineSignalUTF8StringAttributeList m_signal_update_aux_utf8_string; IMEngineSignalWideStringWideStringAttributeListInt m_signal_update_preedit_string_with_commit; + IMEngineSignalInt2WideStringWideStringAttributeList m_signal_recapture_string; IMEngineSignalWideString m_signal_commit_string; IMEngineSignalUTF8String m_signal_commit_utf8_string; IMEngineSignalLookupTable m_signal_update_lookup_table; @@ -598,6 +602,12 @@ IMEngineInstanceBase::signal_connect_commit_utf8_string (IMEngineSlotUTF8String } Connection +IMEngineInstanceBase::signal_connect_recapture_string (IMEngineSlotInt2WideStringWideStringAttributeList *slot) +{ + return m_impl->m_signal_recapture_string.connect (slot); +} + +Connection IMEngineInstanceBase::signal_connect_forward_key_event (IMEngineSlotKeyEvent *slot) { return m_impl->m_signal_forward_key_event.connect (slot); @@ -771,6 +781,16 @@ IMEngineInstanceBase::update_preedit_string (const WideString &preedit, } void +IMEngineInstanceBase::recapture_string (int offset, + int len, + const WideString &preedit, + const WideString &commit, + const AttributeList &attrs) +{ + m_impl->m_signal_recapture_string (this, offset, len, preedit, commit, attrs); +} + +void IMEngineInstanceBase::update_aux_string (const WideString &str, const AttributeList &attrs) { diff --git a/ism/src/scim_imengine.h b/ism/src/scim_imengine.h index ba88201..f4e42fc 100644 --- a/ism/src/scim_imengine.h +++ b/ism/src/scim_imengine.h @@ -161,6 +161,9 @@ typedef Slot4 typedef Slot5 IMEngineSlotWideStringWideStringAttributeListInt; +typedef Slot6 + IMEngineSlotInt2WideStringWideStringAttributeList; + typedef Slot5 IMEngineSlotGetSurroundingText; @@ -514,6 +517,7 @@ public: Connection signal_connect_update_preedit_string (IMEngineSlotWideStringAttributeListInt *slot); Connection signal_connect_update_preedit_utf8_string (IMEngineSlotUTF8StringAttributeListInt *slot); Connection signal_connect_update_preedit_string_with_commit (IMEngineSlotWideStringWideStringAttributeListInt *slot); + Connection signal_connect_recapture_string (IMEngineSlotInt2WideStringWideStringAttributeList *slot); Connection signal_connect_update_aux_string (IMEngineSlotWideStringAttributeList *slot); Connection signal_connect_update_aux_utf8_string (IMEngineSlotUTF8StringAttributeList *slot); @@ -951,6 +955,12 @@ protected: void commit_string (const char *buf, int buflen); + void recapture_string (int offset, + int len, + const WideString &preedit, + const WideString &commit, + const AttributeList &attrs = AttributeList ()); + /** * @brief Forward a key event to the client application. * diff --git a/ism/src/scim_trans_commands.h b/ism/src/scim_trans_commands.h index bd5ff68..c63e13c 100644 --- a/ism/src/scim_trans_commands.h +++ b/ism/src/scim_trans_commands.h @@ -693,6 +693,7 @@ const int ISM_TRANS_CMD_UPDATE_ISE_EXIT = 1216; const int ISM_TRANS_CMD_SELECT_CANDIDATE = 1217; const int ISM_TRANS_CMD_PROCESS_KEY_EVENT_DONE = 1218; const int ISM_TRANS_CMD_REQUEST_ISE_HIDE = 1219; +const int ISM_TRANS_CMD_RECAPTURE_STRING = 1220; /* Panel to ISE */