Add commit string as parameter for update_preedit_string() 54/82854/7
authorLi Zhang <li2012.zhang@samsung.com>
Mon, 8 Aug 2016 07:20:58 +0000 (15:20 +0800)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 24 Aug 2016 08:38:58 +0000 (01:38 -0700)
Change-Id: I29f69489b128ef1c7ccedecc4abe0edf65be6c9f

13 files changed:
ism/extras/wayland_immodule/wayland_imcontext.c
ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp
ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp
ism/src/isf_info_manager.cpp
ism/src/isf_info_manager.h
ism/src/isf_panel_agent_base.cpp
ism/src/isf_panel_agent_base.h
ism/src/isf_panel_agent_manager.cpp
ism/src/isf_panel_agent_manager.h
ism/src/scim_helper.cpp
ism/src/scim_helper.h
ism/src/scim_imengine.cpp
ism/src/scim_imengine.h

index 24d1580..4d34365 100644 (file)
 
 #define IME_DEVICE_NAME "ime"
 
-#ifdef _TV
-# define ENABLE_RESET_DONE_FUNC 0
-#else
-# define ENABLE_RESET_DONE_FUNC 1
-#endif
-
 #define HIDE_TIMER_INTERVAL     0.05
 #define WAIT_FOR_FILTER_DONE_SECOND 2
 
@@ -147,11 +141,8 @@ struct _WaylandIMContext
         uint32_t state;
     } last_key_event_filter;
     Eina_List *keysym_list;
-#if ENABLE_RESET_DONE_FUNC
-    uint32_t last_reset_serial;
-#else
+
     uint32_t reset_serial;
-#endif
     //
 };
 
@@ -485,6 +476,32 @@ update_state(WaylandIMContext *imcontext)
     }
 }
 
+static Eina_Bool
+check_serial(WaylandIMContext *imcontext, uint32_t serial)
+{
+#ifdef _TV
+    return EINA_TRUE;
+#endif
+    Ecore_IMF_Preedit_Attr *attr;
+
+    if ((imcontext->serial - serial) >
+        (imcontext->serial - imcontext->reset_serial)) {
+        LOGD("outdated serial: %u, current: %u, reset: %u",
+                serial, imcontext->serial, imcontext->reset_serial);
+
+        imcontext->pending_preedit.cursor = 0;
+
+        if (imcontext->pending_preedit.attrs) {
+            EINA_LIST_FREE(imcontext->pending_preedit.attrs, attr) free(attr);
+            imcontext->pending_preedit.attrs = NULL;
+        }
+
+        return EINA_FALSE;
+    }
+
+    return EINA_TRUE;
+}
+
 static void
 clear_preedit(WaylandIMContext *imcontext)
 {
@@ -529,6 +546,9 @@ text_input_commit_string(void                 *data,
     if (!imcontext->ctx)
         return;
 
+    if (!check_serial(imcontext, serial))
+        return;
+
     if (old_preedit)
     {
         ecore_imf_context_preedit_end_event_add(imcontext->ctx);
@@ -954,6 +974,9 @@ text_input_preedit_string(void                 *data,
                 text,
                 imcontext->preedit_text ? imcontext->preedit_text : "");
 
+    if (!check_serial(imcontext, serial))
+        return;
+
     old_preedit =
         imcontext->preedit_text && strlen(imcontext->preedit_text) > 0;
 
@@ -1196,9 +1219,8 @@ text_input_enter(void                 *data,
     WaylandIMContext *imcontext = (WaylandIMContext *)data;
 
     update_state(imcontext);
-#if !(ENABLE_RESET_DONE_FUNC)
+
     imcontext->reset_serial = imcontext->serial;
-#endif
 }
 
 static void
@@ -1500,20 +1522,6 @@ text_input_filter_key_event_done(void                 *data,
     imcontext->last_key_event_filter.state = state;
 }
 
-static void
-text_input_reset_done(void                 *data,
-                      struct wl_text_input *text_input EINA_UNUSED,
-                      uint32_t              serial)
-{
-    LOGD("serial: %d", serial);
-#if ENABLE_RESET_DONE_FUNC
-    WaylandIMContext *imcontext = (WaylandIMContext *)data;
-    if (!imcontext) return;
-
-    imcontext->last_reset_serial = serial;
-#endif
-}
-
 //
 
 static const struct wl_text_input_listener text_input_listener =
@@ -1538,8 +1546,7 @@ static const struct wl_text_input_listener text_input_listener =
     text_input_input_panel_data,
     text_input_get_selection_text,
     text_input_get_surrounding_text,
-    text_input_filter_key_event_done,
-    text_input_reset_done
+    text_input_filter_key_event_done
     //
 };
 
@@ -1692,31 +1699,17 @@ wayland_im_context_reset(Ecore_IMF_Context *ctx)
 
     if (!imcontext) return;
 
+    commit_preedit (imcontext);
     clear_preedit(imcontext);
 
     if (!imcontext->input) return;
-#if !(ENABLE_RESET_DONE_FUNC)
-    wl_text_input_reset(imcontext->text_input);
-#else
+
     if (imcontext->text_input) {
-        int serial = imcontext->serial++;
-        double start_time = ecore_time_get();
-        //send "reset_sync" to IME with serial
-        wl_text_input_reset_sync(imcontext->text_input, serial);
-        //wait for "reset_done" from IME according to serial
-        while (ecore_time_get() - start_time < WAIT_FOR_FILTER_DONE_SECOND){
-            wl_display_dispatch(ecore_wl_display_get());
-            if (imcontext->last_reset_serial >= serial) {
-                LOGD("reset_serial %d, serial %d", imcontext->last_reset_serial, serial);
-                break;
-            }
-        }
+        wl_text_input_reset(imcontext->text_input);
     }
-#endif
     update_state(imcontext);
-#if !(ENABLE_RESET_DONE_FUNC)
+
     imcontext->reset_serial = imcontext->serial;
-#endif
 }
 
 EAPI void
index 85f9204..8329309 100755 (executable)
@@ -919,7 +919,6 @@ private:
     void reset_helper_context(int client, uint32 context, const String& uuid) {
         LOGD ("client id:%d\n", client);
         Transaction trans;
-        int cmd;
         Socket client_socket(client);
         m_send_trans.clear();
         m_send_trans.put_command(SCIM_TRANS_CMD_REPLY);
@@ -927,11 +926,6 @@ private:
         m_send_trans.put_data(uuid);
         m_send_trans.put_command(ISM_TRANS_CMD_RESET_ISE_CONTEXT);
         m_send_trans.write_to_socket(client_socket);
-
-        if (!trans.read_from_socket(client_socket, m_socket_timeout) ||
-            !trans.get_command(cmd) || cmd != SCIM_TRANS_CMD_REPLY) {
-            LOGW ("ISM_TRANS_CMD_RESET_ISE_CONTEXT failed\n");
-        }
     }
 
     void reload_config(int client) {
@@ -1348,7 +1342,7 @@ private:
         unlock();
     }
 
-    void update_preedit_string(int client, uint32  target_context, WideString wstr, AttributeList& attrs, uint32 caret) {
+    void update_preedit_string(int client, uint32  target_context, WideString preedit, WideString commit, AttributeList& attrs, uint32 caret) {
         LOGD ("client id:%d\n", client);
 
         Socket socket_client(client);
@@ -1357,7 +1351,8 @@ private:
         m_send_trans.put_command(SCIM_TRANS_CMD_REPLY);
         m_send_trans.put_data(target_context);
         m_send_trans.put_command(SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
-        m_send_trans.put_data(wstr);
+        m_send_trans.put_data(preedit);
+        m_send_trans.put_data(commit);
         m_send_trans.put_data(attrs);
         m_send_trans.put_data(caret);
         m_send_trans.write_to_socket(socket_client);
@@ -2408,16 +2403,18 @@ private:
                 } else if (cmd == SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING) {
                     uint32 target_ic;
                     String target_uuid;
-                    WideString wstr;
+                    WideString preedit;
+                    WideString commit;
                     AttributeList attrs;
                     uint32 caret;
 
                     if (m_recv_trans.get_data(target_ic)    &&
                         m_recv_trans.get_data(target_uuid)  &&
-                        m_recv_trans.get_data(wstr) &&
+                        m_recv_trans.get_data(preedit) &&
+                        m_recv_trans.get_data(commit) &&
                         m_recv_trans.get_data(attrs) &&
                         m_recv_trans.get_data(caret)) {
-                        m_info_manager->socket_helper_update_preedit_string(client_id, target_ic, target_uuid, wstr, attrs, caret);
+                        m_info_manager->socket_helper_update_preedit_string(client_id, target_ic, target_uuid, preedit, commit, attrs, caret);
                     } else {
                         LOGW ("wrong format of transaction\n");
                     }
index 65849b8..3c56b1a 100644 (file)
@@ -80,6 +80,7 @@ struct _WSCContextISFImpl {
     WideString               surrounding_text;
     WideString               preedit_string;
     AttributeList            preedit_attrlist;
+    WideString               commit_string;
     Ecore_IMF_Autocapital_Type autocapital_type;
     Ecore_IMF_Input_Hints    input_hint;
     Ecore_IMF_BiDi_Direction bidi_direction;
@@ -185,10 +186,7 @@ static void     panel_slot_commit_string                (int
 static void     panel_slot_forward_key_event            (int                     context,
                                                          const KeyEvent         &key);
 static void     _show_preedit_string          (int                     context);
-static void     _update_preedit_string        (int                     context,
-                                                         const WideString       &str,
-                                                         const AttributeList    &attrs,
-                                                         int               caret);
+
 static void     panel_req_update_bidi_direction         (WSCContextISF     *ic, int direction);
 
 /* utility functions */
@@ -266,10 +264,6 @@ _wsc_im_ctx_reset(void *data, struct wl_input_method_context *im_ctx)
     LOGD ("");
     if (context_scim && context_scim->impl && context_scim == _focused_ic) {
         g_info_manager->socket_reset_input_context (WAYLAND_MODULE_CLIENT_ID, context_scim->id);
-        if (context_scim->impl->need_commit_preedit) {
-            _hide_preedit_string (context_scim->id, false);
-            wsc_context_commit_preedit_string (context_scim);
-        }
     }
 }
 
@@ -433,21 +427,6 @@ _wsc_im_ctx_filter_key_event(void *data, struct wl_input_method_context *im_ctx,
 #endif
 }
 
-static void
-_wsc_im_ctx_reset_sync(void *data, struct wl_input_method_context *im_ctx, uint32_t serial)
-{
-    WSCContextISF *context_scim = (WSCContextISF*)data;
-    LOGD ("");
-    if (context_scim && context_scim->impl && context_scim == _focused_ic) {
-        g_info_manager->socket_reset_input_context (WAYLAND_MODULE_CLIENT_ID, context_scim->id);
-        if (context_scim->impl->need_commit_preedit) {
-            _hide_preedit_string (context_scim->id, false);
-            wsc_context_commit_preedit_string (context_scim);
-        }
-    }
-    wl_input_method_context_reset_done (im_ctx, serial);
-}
-
 
 static const struct wl_input_method_context_listener wsc_im_context_listener = {
      _wsc_im_ctx_reset,
@@ -461,8 +440,7 @@ static const struct wl_input_method_context_listener wsc_im_context_listener = {
      _wsc_im_ctx_bidi_direction,
      _wsc_im_ctx_cursor_position,
      _wsc_im_ctx_process_input_device_event,
-     _wsc_im_ctx_filter_key_event,
-     _wsc_im_ctx_reset_sync
+     _wsc_im_ctx_filter_key_event
 };
 
 #if ENABLE_GRAB_KEYBOARD
@@ -905,6 +883,7 @@ delete_ic_impl (WSCContextISFImpl *impl)
             rec->surrounding_text = WideString ();
             rec->preedit_string = WideString ();
             rec->preedit_attrlist.clear ();
+            rec->commit_string = WideString ();
 
             return;
         }
@@ -1426,6 +1405,7 @@ isf_wsc_context_focus_in (WSCContextISF *wsc_ctx)
         context_scim->impl->surrounding_text.clear ();
         context_scim->impl->preedit_string.clear ();
         context_scim->impl->preedit_attrlist.clear ();
+        context_scim->impl->commit_string.clear ();
         context_scim->impl->preedit_caret = 0;
         context_scim->impl->preedit_started = false;
 
@@ -1927,7 +1907,7 @@ wsc_send_preedit (WSCContextISF* wsc_ctx, int32_t cursor)
     wl_input_method_context_preedit_string (wsc_ctx->im_ctx,
                                             wsc_ctx->serial,
                                             wsc_ctx->preedit_str,
-                                            wsc_ctx->preedit_str);
+                                            utf8_wcstombs (wsc_ctx->impl->commit_string).c_str());
 }
 
 bool wsc_context_surrounding_get (WSCContextISF *wsc_ctx, char **text, int *cursor_pos)
@@ -2438,6 +2418,7 @@ _hide_preedit_string (int context, bool update_preedit)
             ic->impl->preedit_attrlist.clear ();
             emit = true;
         }
+        ic->impl->commit_string = WideString ();
         if (ic->impl->use_preedit) {
             if (update_preedit && emit) {
                 if (!check_valid_ic (ic))
@@ -2456,48 +2437,6 @@ _hide_preedit_string (int context, bool update_preedit)
     }
 }
 
-static void
-_update_preedit_string (int context,
-                                  const WideString    &str,
-                                  const AttributeList &attrs,
-                                  int caret)
-{
-    SCIM_DEBUG_FRONTEND (1) << __FUNCTION__ << "...\n";
-    LOGD ("");
-    WSCContextISF* ic = find_ic (context);
-
-    if (ic && ic->impl && _focused_ic == ic) {
-        if (!ic->impl->is_on)
-            ic->impl->is_on = true;
-
-        if (ic->impl->preedit_string != str || str.length ()) {
-            ic->impl->preedit_string   = str;
-            ic->impl->preedit_attrlist = attrs;
-
-            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;
-                }
-                if (caret >= 0 && caret <= (int)str.length ())
-                    ic->impl->preedit_caret    = caret;
-                else
-                    ic->impl->preedit_caret    = str.length ();
-                ic->impl->preedit_updating = true;
-                if (check_valid_ic (ic))
-                    ic->impl->preedit_updating = false;
-                wsc_context_send_preedit_string (ic);
-            } else {
-                String _str = utf8_wcstombs (str);
-                g_info_manager->socket_update_preedit_string (_str, attrs, (uint32)caret);
-            }
-        }
-    }
-}
-
 static uint32_t _keyname_to_keysym (uint32_t keyname, uint32_t *modifiers)
 {
     if (!modifiers)
@@ -2829,9 +2768,40 @@ public:
     }
 
     void
-    update_preedit_string (int id, uint32 context_id, WideString wstr, AttributeList& attrs, uint32 caret) {
+    update_preedit_string (int id, uint32 context_id, WideString preedit, WideString commit, AttributeList& attrs, uint32 caret) {
         LOGD ("client id:%d", id);
-        _update_preedit_string (context_id, wstr, attrs, caret);
+        SCIM_DEBUG_FRONTEND (1) << __FUNCTION__ << "...\n";
+        WSCContextISF* ic = find_ic (context_id);
+
+        if (ic && ic->impl && _focused_ic == ic) {
+            if (!ic->impl->is_on)
+                ic->impl->is_on = true;
+
+            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;
+                }
+                if (caret <= preedit.length ())
+                    ic->impl->preedit_caret    = caret;
+                else
+                    ic->impl->preedit_caret    = preedit.length ();
+                ic->impl->preedit_updating = true;
+                if (check_valid_ic (ic))
+                    ic->impl->preedit_updating = false;
+                wsc_context_send_preedit_string (ic);
+            } else {
+                String _str = utf8_wcstombs (preedit);
+                g_info_manager->socket_update_preedit_string (_str, attrs, (uint32)caret);
+            }
+        }
     }
 
     static Eina_Bool
index 7c597b8..6f59317 100644 (file)
@@ -1920,7 +1920,7 @@ public:
 
         get_focused_context (client, context);
         if (client >= 0) {
-            m_panel_agent_manager.update_preedit_string (client, context, str, attrs, caret);
+            m_panel_agent_manager.update_preedit_string (client, context, str, str, attrs, caret);
         }
 
         unlock ();
@@ -3397,7 +3397,7 @@ client context helpers: %d, helpers uuid count: %d",
         }
     }
     //SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING
-    void socket_helper_update_preedit_string (int client, uint32 target_ic, String target_uuid, WideString wstr, AttributeList& attrs, uint32 caret) {
+    void socket_helper_update_preedit_string (int client, uint32 target_ic, String target_uuid, WideString preedit, WideString commit, AttributeList& attrs, uint32 caret) {
         SCIM_DEBUG_MAIN (4) << "InfoManager::socket_helper_update_preedit_string (" << client << ")\n";
         LOGD ("");
         int     target_client;
@@ -3422,7 +3422,7 @@ client context helpers: %d, helpers uuid count: %d",
             ClientInfo client_info = socket_get_client_info (target_client);
 
             if (client_info.type == FRONTEND_CLIENT) {
-                m_panel_agent_manager.update_preedit_string (target_client, target_context, wstr, attrs, caret);
+                m_panel_agent_manager.update_preedit_string (target_client, target_context, preedit, commit, attrs, caret);
             }
         }
     }
@@ -4847,10 +4847,10 @@ void InfoManager::socket_helper_hide_preedit_string (int client, uint32 target_i
 }
 
 //SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING
-void InfoManager::socket_helper_update_preedit_string (int client, uint32 target_ic, String target_uuid, WideString wstr,
-        AttributeList& attrs, uint32 caret)
+void InfoManager::socket_helper_update_preedit_string (int client, uint32 target_ic, String target_uuid, WideString preedit,
+        WideString commit, AttributeList& attrs, uint32 caret)
 {
-    m_impl->socket_helper_update_preedit_string (client, target_ic, target_uuid, wstr, attrs, caret);
+    m_impl->socket_helper_update_preedit_string (client, target_ic, target_uuid, preedit, commit, attrs, caret);
 }
 
 //SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET
index e61e5e7..94387af 100644 (file)
@@ -912,7 +912,7 @@ public:
     void socket_helper_hide_preedit_string (int client, uint32 target_ic, String target_uuid);
 
     //SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING
-    void socket_helper_update_preedit_string (int client, uint32 target_ic, String target_uuid, WideString wstr, AttributeList& attrs, uint32 caret);
+    void socket_helper_update_preedit_string (int client, uint32 target_ic, String target_uuid, WideString preedit, WideString commit, AttributeList& attrs, uint32 caret);
 
     //SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET
     void socket_helper_update_preedit_caret (int client, uint32 caret);
index e78de0c..2af0253 100644 (file)
@@ -484,7 +484,7 @@ void PanelAgentBase::hide_preedit_string (int client, uint32 context)
 }
 //socket_helper_update_preedit_string
 //SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING
-void PanelAgentBase::update_preedit_string (int client, uint32 context, WideString wstr, AttributeList& attrs, uint32 caret)
+void PanelAgentBase::update_preedit_string (int client, uint32 context, WideString preedit, WideString commit, AttributeList& attrs, uint32 caret)
 {
     LOGW ("not implemented for %s", m_name.c_str ());
 }
index 1316a3e..2e9e19e 100644 (file)
@@ -782,7 +782,7 @@ public:
      *
      * @return none.
      */
-    virtual void update_preedit_string (int client, uint32  context, WideString wstr, AttributeList& attrs, uint32 caret);
+    virtual void update_preedit_string (int client, uint32  context, WideString preedit, WideString commit, AttributeList& attrs, uint32 caret);
 
     /**
      * @brief update_preedit_caret.
index 03f886b..e732440 100644 (file)
@@ -782,12 +782,12 @@ void PanelAgentManager::hide_preedit_string (int id, uint32 context_id)
         _p->hide_preedit_string (id, context_id);
 }
 
-void PanelAgentManager::update_preedit_string (int id, uint32 context_id, WideString wstr, AttributeList& attrs, uint32 caret)
+void PanelAgentManager::update_preedit_string (int id, uint32 context_id, WideString preedit, WideString commit, AttributeList& attrs, uint32 caret)
 {
     PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
 
     if (!_p.null ())
-        _p->update_preedit_string (id, context_id, wstr, attrs, caret);
+        _p->update_preedit_string (id, context_id, preedit, commit, attrs, caret);
 }
 
 void PanelAgentManager::update_preedit_caret (int id, uint32 context_id, uint32 caret)
index a0f6352..90130f1 100644 (file)
@@ -333,7 +333,7 @@ public:
     void commit_string (int target_client, uint32  target_context,const WideString& wstr);
     void show_preedit_string (int target_client, uint32  target_context);
     void hide_preedit_string (int target_client, uint32  target_context);
-    void update_preedit_string (int target_client, uint32  target_context, WideString wstr, AttributeList& attrs, uint32 caret);
+    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 helper_attach_input_context_and_update_screen (int client, std::vector < std::pair <uint32, String> >& helper_ic_index, uint32 current_screen);
     void hide_helper_ise (int id, uint32 context);
index 417965b..353177c 100644 (file)
@@ -302,6 +302,17 @@ public:
     }
 
     void
+    slot_update_preedit_string_with_commit (IMEngineInstanceBase *si,
+                                            const WideString & preedit,
+                                            const WideString & commit,
+                                            const AttributeList & attrs,
+                                            int caret)
+    {
+        LOGD ("");
+        thiz->update_preedit_string (-1, "", preedit, commit, attrs, caret);
+    }
+
+    void
     slot_update_aux_string (IMEngineInstanceBase *si,
                             const WideString & str,
                             const AttributeList & attrs)
@@ -476,6 +487,9 @@ public:
             slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_caret));
         si->signal_connect_update_preedit_string (
             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_update_aux_string (
             slot (this, &HelperAgent::HelperAgentImpl::slot_update_aux_string));
         si->signal_connect_update_lookup_table (
@@ -1264,9 +1278,6 @@ HelperAgent::handle_message (MessageItem *message)
             m_impl->signal_reset_ise_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
             m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
             if (!m_impl->si.null ()) m_impl->si->reset();
-            m_impl->send.clear ();
-            m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
-            m_impl->send.write_to_socket (m_impl->socket);
             break;
         }
         case ISM_TRANS_CMD_TURN_ON_LOG:
@@ -1746,7 +1757,7 @@ HelperAgent::update_preedit_string (int                  ic,
                                     const AttributeList &attrs) const
 {
     LOGD ("");
-    update_preedit_string (ic, ic_uuid, str, attrs, -1);
+    update_preedit_string (ic, ic_uuid, str, str, attrs, -1);
 }
 
 void
@@ -1774,7 +1785,19 @@ HelperAgent::update_preedit_string (int                  ic,
 void
 HelperAgent::update_preedit_string (int                  ic,
                                     const String        &ic_uuid,
-                                    const WideString    &str,
+                                    const WideString    &wstr,
+                                    const AttributeList &attrs,
+                                    int            caret) const
+{
+    LOGD ("");
+    update_preedit_string (ic, ic_uuid, wstr, wstr, attrs, caret);
+}
+
+void
+HelperAgent::update_preedit_string (int                 ic,
+                                    const String       &ic_uuid,
+                                    const char         *buf,
+                                    int                 buflen,
                                     const AttributeList &attrs,
                                     int            caret) const
 {
@@ -1787,7 +1810,8 @@ HelperAgent::update_preedit_string (int                  ic,
         m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
         m_impl->send.put_data ((uint32)ic);
         m_impl->send.put_data (ic_uuid);
-        m_impl->send.put_data (str);
+        m_impl->send.put_dataw (buf, buflen);
+        m_impl->send.put_dataw (buf, buflen);
         m_impl->send.put_data (attrs);
         m_impl->send.put_data (caret);
         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
@@ -1795,15 +1819,14 @@ HelperAgent::update_preedit_string (int                  ic,
 }
 
 void
-HelperAgent::update_preedit_string (int                 ic,
-                                    const String       &ic_uuid,
-                                    const char         *buf,
-                                    int                 buflen,
+HelperAgent::update_preedit_string (int                  ic,
+                                    const String        &ic_uuid,
+                                    const WideString    &preedit,
+                                    const WideString    &commit,
                                     const AttributeList &attrs,
-                                    int            caret) const
+                                    int                  caret) const
 {
     LOGD ("");
-
     if (m_impl->socket_active.is_connected ()) {
         m_impl->send.clear ();
         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
@@ -1811,7 +1834,8 @@ HelperAgent::update_preedit_string (int                 ic,
         m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
         m_impl->send.put_data ((uint32)ic);
         m_impl->send.put_data (ic_uuid);
-        m_impl->send.put_dataw (buf, buflen);
+        m_impl->send.put_data (preedit);
+        m_impl->send.put_data (commit);
         m_impl->send.put_data (attrs);
         m_impl->send.put_data (caret);
         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
index b41260c..6d1c538 100644 (file)
@@ -509,7 +509,7 @@ public:
      */
     void update_preedit_string  (int                 ic,
                                  const String       &ic_uuid,
-                                 const WideString   &wstr,
+                                 const WideString    &wstr,
                                  const AttributeList &attrs,
                                  int                 caret) const;
 
@@ -533,6 +533,29 @@ public:
                                  int                 caret) const;
 
     /**
+     * @brief Update a new WideString and caret for preedit.
+     *
+     * @param ic The handle of the client Input Context to receive the WideString.
+     *        -1 means the currently focused Input Context.
+     * @param ic_uuid The UUID of the IMEngine used by the Input Context.
+     *        Empty means don't match.
+     * @param preedit The WideString to be updated.
+     * @param commit The WideString to be commited on reset.
+     * @param attrs The attribute list for preedit string.
+     * @param caret The caret position in preedit string.
+     *
+     * The commit string can be used to replace the preedit string on reset
+     * for example on unfocus.
+     */
+
+    void update_preedit_string (int                  ic,
+                                            const String        &ic_uuid,
+                                            const WideString    &preedit,
+                                            const WideString    &commit,
+                                            const AttributeList &attrs,
+                                            int                  caret) const;
+
+    /**
      * @brief Update a new string for aux.
      *
      * @param str The string to be updated.
index 3f5466c..2f0696d 100644 (file)
@@ -91,6 +91,9 @@ typedef Signal3<void, IMEngineInstanceBase*,const WideString&,const AttributeLis
 typedef Signal4<void, IMEngineInstanceBase*,const char*,int,const AttributeList&>
         IMEngineSignalUTF8StringAttributeList;
 
+typedef Signal5<void, IMEngineInstanceBase*,const WideString&,const WideString&,const AttributeList&,int>
+        IMEngineSignalWideStringWideStringAttributeListInt;
+
 typedef Signal5<bool, IMEngineInstanceBase*,WideString&,int&,int,int>
         IMEngineSignalGetSurroundingText;
 
@@ -133,6 +136,7 @@ public:
     IMEngineSignalUTF8StringAttributeListInt m_signal_update_preedit_utf8_string;
     IMEngineSignalWideStringAttributeList m_signal_update_aux_string;
     IMEngineSignalUTF8StringAttributeList m_signal_update_aux_utf8_string;
+    IMEngineSignalWideStringWideStringAttributeListInt m_signal_update_preedit_string_with_commit;
     IMEngineSignalWideString              m_signal_commit_string;
     IMEngineSignalUTF8String              m_signal_commit_utf8_string;
     IMEngineSignalLookupTable             m_signal_update_lookup_table;
@@ -553,6 +557,12 @@ IMEngineInstanceBase::signal_connect_update_preedit_utf8_string (IMEngineSlotUTF
 }
 
 Connection
+IMEngineInstanceBase::signal_connect_update_preedit_string_with_commit (IMEngineSlotWideStringWideStringAttributeListInt *slot)
+{
+    return m_impl->m_signal_update_preedit_string_with_commit.connect (slot);
+}
+
+Connection
 IMEngineInstanceBase::signal_connect_update_aux_string (IMEngineSlotWideStringAttributeList *slot)
 {
     return m_impl->m_signal_update_aux_string.connect (slot);
@@ -747,6 +757,15 @@ IMEngineInstanceBase::update_preedit_string (const char    *buf,
 }
 
 void
+IMEngineInstanceBase::update_preedit_string (const WideString    &preedit,
+                                             const WideString    &commit,
+                                             const AttributeList &attrs,
+                                             int                  caret)
+{
+    m_impl->m_signal_update_preedit_string_with_commit (this, preedit, commit, attrs, caret);
+}
+
+void
 IMEngineInstanceBase::update_aux_string (const WideString    &str,
                                          const AttributeList &attrs)
 {
index 5616191..afb64c3 100644 (file)
@@ -158,6 +158,9 @@ typedef Slot3<void, IMEngineInstanceBase*,const WideString&,const AttributeList&
 typedef Slot4<void, IMEngineInstanceBase*,const char*, int,const AttributeList&>
         IMEngineSlotUTF8StringAttributeList;
 
+typedef Slot5<void, IMEngineInstanceBase*,const WideString&, const WideString&, const AttributeList&,int>
+        IMEngineSlotWideStringWideStringAttributeListInt;
+
 typedef Slot5<bool, IMEngineInstanceBase*,WideString&,int&,int,int>
         IMEngineSlotGetSurroundingText;
 
@@ -510,6 +513,8 @@ public:
     Connection signal_connect_update_preedit_caret    (IMEngineSlotInt *slot);
     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_update_aux_string       (IMEngineSlotWideStringAttributeList *slot);
     Connection signal_connect_update_aux_utf8_string  (IMEngineSlotUTF8StringAttributeList *slot);
     Connection signal_connect_update_lookup_table     (IMEngineSlotLookupTable *slot);
@@ -870,6 +875,22 @@ protected:
                                 int                  caret);
 
     /**
+     * @brief Update the content of the preedit string,
+     *
+     * @param preedit - the preedit string
+     * @param commit - the commit string
+     * @param attrs - the string attribute
+     * @param caret - the caret position
+     *
+     * The commit string can be used to replace the preedit string on reset
+     * for example on unfocus.
+     */
+     void update_preedit_string (const WideString    &preedit,
+                                 const WideString    &commit,
+                                 const AttributeList &attrs = AttributeList (),
+                                 int                  caret = -1);
+
+    /**
      * @brief Update the content of the aux string,
      *
      * @param str - the string content