Support input hint API 86/33586/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 27 Aug 2014 08:24:31 +0000 (17:24 +0900)
committerLi Zhang <li2012.zhang@samsung.com>
Tue, 13 Jan 2015 08:31:50 +0000 (16:31 +0800)
Change-Id: Ie421f77392c81018bd247645555b7b6ff08699bc

20 files changed:
ism/demos/isf_demo_efl.cpp
ism/extras/efl_immodule/isf_imf_context.cpp
ism/extras/efl_immodule/isf_imf_context.h
ism/extras/efl_immodule/isf_imf_control_ui.cpp
ism/extras/efl_immodule/isf_imf_module.cpp
ism/modules/frontend/scim_socket_frontend.cpp
ism/modules/frontend/scim_socket_frontend.h
ism/modules/imengine/scim_socket_imengine.cpp
ism/modules/imengine/scim_socket_imengine.h
ism/src/ise_context.h
ism/src/scim_frontend.cpp
ism/src/scim_frontend.h
ism/src/scim_helper.cpp
ism/src/scim_helper.h
ism/src/scim_imengine.cpp
ism/src/scim_imengine.h
ism/src/scim_panel_agent.cpp
ism/src/scim_panel_client.cpp
ism/src/scim_panel_client.h
ism/src/scim_trans_commands.h

index 739c442..05c8f7b 100644 (file)
@@ -42,6 +42,7 @@
 #include "isf_focus_movement_efl.h"
 #include "isf_language_efl.h"
 #include "isf_ondemand_efl.h"
+#include "isf_input_hint_efl.h"
 
 #if HAVE_UIGADGET
 #include <ui-gadget.h>
@@ -56,6 +57,7 @@ static struct _menu_item isf_demo_menu_its[] = {
     { "ISF Language", ise_language_bt },
     { "ISF Return Key Type", ise_return_key_type_bt },
     { "ISF Return Key Disable", ise_return_key_disable_bt },
+    { "ISF Input hint", ise_input_hint_bt },
     { "ISF IM Data", ise_imdata_set_bt },
 #ifdef _WEARABLE
     { "ISF ondemand", ise_ondemand_bt },
index 003d363..8a61d5f 100644 (file)
@@ -76,6 +76,7 @@ struct _EcoreIMFContextISFImpl {
     WideString               preedit_string;
     AttributeList            preedit_attrlist;
     Ecore_IMF_Autocapital_Type autocapital_type;
+    Ecore_IMF_Input_Hints    input_hint;
     void                    *imdata;
     int                      imdata_size;
     int                      preedit_caret;
@@ -206,6 +207,7 @@ static void     panel_req_update_spot_location          (EcoreIMFContextISF
 static void     panel_req_update_cursor_position        (EcoreIMFContextISF     *ic, int cursor_pos);
 static void     panel_req_show_help                     (EcoreIMFContextISF     *ic);
 static void     panel_req_show_factory_menu             (EcoreIMFContextISF     *ic);
+static void     panel_req_set_input_hint                (EcoreIMFContextISF     *ic, int hint);
 
 /* Panel iochannel handler*/
 static bool     panel_initialize                        (void);
@@ -425,6 +427,7 @@ new_ic_impl (EcoreIMFContextISF *parent)
     }
 
     impl->autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_NONE;
+    impl->input_hint = ECORE_IMF_INPUT_HINT_NONE;
     impl->next_shift_status = 0;
     impl->shift_mode_enabled = 0;
     impl->next = _used_ic_impl_list;
@@ -1481,6 +1484,7 @@ isf_imf_context_focus_in (Ecore_IMF_Context *ctx)
             context_scim->impl->si->set_prediction_allow (context_scim->impl->prediction_allow);
             LOGD ("ctx : %p. set autocapital type : %d\n", ctx, context_scim->impl->autocapital_type);
             context_scim->impl->si->set_autocapital_type (context_scim->impl->autocapital_type);
+            context_scim->impl->si->set_input_hint (context_scim->impl->input_hint);
             if (context_scim->impl->imdata)
                 context_scim->impl->si->set_imdata ((const char *)context_scim->impl->imdata, context_scim->impl->imdata_size);
         } else {
@@ -2191,6 +2195,28 @@ EAPI void isf_imf_context_imdata_get (Ecore_IMF_Context *ctx, void* data, int* l
     isf_imf_context_input_panel_imdata_get (ctx, data, length);
 }
 
+EAPI void
+isf_imf_context_input_hint_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Hints hint)
+{
+    SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
+
+    EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx);
+
+    if (context_scim && context_scim->impl) {
+        if (context_scim->impl->input_hint != hint) {
+            LOGD ("ctx : %p, input hint : %#x\n", ctx, hint);
+            context_scim->impl->input_hint = hint;
+
+            if (context_scim->impl->si && context_scim == _focused_ic) {
+                _panel_client.prepare (context_scim->id);
+                context_scim->impl->si->set_input_hint (hint);
+                panel_req_set_input_hint (context_scim, hint);
+                _panel_client.send ();
+            }
+        }
+    }
+}
+
 /* Panel Slot functions */
 static void
 panel_slot_reload_config (int context)
@@ -2889,6 +2915,15 @@ panel_req_update_cursor_position (EcoreIMFContextISF *ic, int cursor_pos)
         _panel_client.update_cursor_position (ic->id, cursor_pos);
 }
 
+static void
+panel_req_set_input_hint (EcoreIMFContextISF *ic, int hint)
+{
+    SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
+
+    if (ic)
+        _panel_client.set_input_hint (ic->id, hint);
+}
+
 static bool
 filter_hotkeys (EcoreIMFContextISF *ic, const KeyEvent &key)
 {
@@ -3159,6 +3194,7 @@ turn_on_ic (EcoreIMFContextISF *ic)
             ic->impl->si->set_prediction_allow (ic->impl->prediction_allow);
             LOGD ("ctx : %p. set autocapital type : %d\n", ic->ctx, ic->impl->autocapital_type);
             ic->impl->si->set_autocapital_type (ic->impl->autocapital_type);
+            ic->impl->si->set_input_hint (ic->impl->input_hint);
         }
 
         //Record the IC on/off status
index 3be25ce..2e1cfb3 100644 (file)
@@ -80,6 +80,7 @@ EAPI void isf_imf_context_prediction_allow_set (Ecore_IMF_Context* ctx, Eina_Boo
 EAPI void isf_imf_context_autocapital_type_set (Ecore_IMF_Context* ctx, Ecore_IMF_Autocapital_Type autocapital_type);
 EAPI void isf_imf_context_imdata_set (Ecore_IMF_Context* ctx, const void *data, int len);
 EAPI void isf_imf_context_imdata_get (Ecore_IMF_Context* ctx, void *data, int *len);
+EAPI void isf_imf_context_input_hint_set (Ecore_IMF_Context* ctx, Ecore_IMF_Input_Hints hint);
 
 EAPI EcoreIMFContextISF* isf_imf_context_new      (void);
 EAPI void                isf_imf_context_shutdown (void);
index 5c807ae..ce4e1ce 100644 (file)
@@ -394,7 +394,7 @@ static Eina_Bool _client_window_focus_out_cb (void *data, int ev_type, void *ev)
     Ecore_X_Window focus_out_win = e->win;
     Ecore_X_Window focus_in_win = ecore_x_window_focus_get ();
 
-    LOGD ("ctx : %p, client_window : %x, focus-out win : %x, focus-in win : %x\n", ctx, client_win, focus_out_win, focus_in_win);
+    LOGD ("ctx : %p, client_window : %#x, focus-out win : %#x, focus-in win : %#x\n", ctx, client_win, focus_out_win, focus_in_win);
 
     if (check_focus_out_by_popup_win (ctx))
         return ECORE_CALLBACK_PASS_ON;
@@ -429,7 +429,7 @@ Eina_Bool check_focus_out_by_popup_win (Ecore_IMF_Context *ctx)
     LOGD ("win type : %d\n", win_type);
 
     if (win_type == ECORE_X_WINDOW_TYPE_POPUP_MENU) {
-        LOGD ("client window : %x, focus window : %x\n", client_win, focus_win);
+        LOGD ("client window : %#x, focus window : %#x\n", client_win, focus_win);
 
         if (client_win != focus_win) {
             ret = EINA_TRUE;
@@ -609,10 +609,13 @@ void isf_imf_context_input_panel_show (Ecore_IMF_Context* ctx)
 
     iseContext.autocapital_type = ecore_imf_context_autocapital_type_get (ctx);
 
+    iseContext.input_hint = ecore_imf_context_input_hint_get (ctx);
+
     SECURE_LOGD ("ctx : %p, layout : %d, layout variation : %d\n", ctx, iseContext.layout, iseContext.layout_variation);
     SECURE_LOGD ("language : %d, cursor position : %d, caps mode : %d\n", iseContext.language, iseContext.cursor_pos, iseContext.caps_mode);
     SECURE_LOGD ("return_key_type : %d, return_key_disabled : %d, autocapital type : %d\n", iseContext.return_key_type, iseContext.return_key_disabled, iseContext.autocapital_type);
     SECURE_LOGD ("client_window : %#x, password mode : %d, prediction_allow : %d\n", iseContext.client_window, iseContext.password_mode, iseContext.prediction_allow);
+    SECURE_LOGD ("input hint : %#x\n", iseContext.input_hint);
 
     if (iseContext.client_window != ecore_x_window_focus_get ()) {
         LOGW ("Client window is different from focus window. client win : %#x, focus win : %#x\n", iseContext.client_window, ecore_x_window_focus_get ());
index a39d605..10d7922 100644 (file)
@@ -75,7 +75,8 @@ extern "C"
         NULL, /* input_panel_event_callback_add */
         NULL, /* input_panel_event_callback_del */
         isf_imf_context_input_panel_language_locale_get,
-        isf_imf_context_candidate_window_geometry_get
+        isf_imf_context_candidate_window_geometry_get,
+        isf_imf_context_input_hint_set
     };
 
     static Ecore_IMF_Context *imf_module_create (void);
index 5fba94d..9db4fa6 100644 (file)
@@ -1017,6 +1017,8 @@ SocketFrontEnd::socket_receive_callback (SocketServer *server, const Socket &cli
             socket_set_autocapital_type (id);
         else if (cmd == ISM_TRANS_CMD_SET_LAYOUT)
             socket_set_layout (id);
+        else if (cmd == ISM_TRANS_CMD_SET_INPUT_HINT)
+            socket_set_input_hint (id);
         else if (cmd == ISM_TRANS_CMD_RESET_ISE_OPTION)
             socket_reset_option (id);
         else if (cmd == SCIM_TRANS_CMD_RESET)
@@ -1633,6 +1635,29 @@ SocketFrontEnd::socket_set_layout (int /*client_id*/)
 }
 
 void
+SocketFrontEnd::socket_set_input_hint (int /*client_id*/)
+{
+    uint32 siid;
+    uint32 input_hint;
+
+    SCIM_DEBUG_FRONTEND (2) << __func__ << "\n";
+
+    if (m_receive_trans.get_data (siid) &&
+        m_receive_trans.get_data (input_hint)) {
+
+        SCIM_DEBUG_FRONTEND (3) << "  SI (" << siid << ").\n";
+
+        m_current_instance = (int) siid;
+
+        set_input_hint ((int) siid, input_hint);
+        m_send_trans.put_command (SCIM_TRANS_CMD_OK);
+
+        m_current_instance = -1;
+    }
+}
+
+
+void
 SocketFrontEnd::socket_update_candidate_item_layout (int /*client_id*/)
 {
     uint32 siid;
index 799308a..20c458d 100644 (file)
@@ -238,6 +238,7 @@ private:
     void socket_longpress_candidate         (int client_id);
     void socket_set_imdata                  (int client_id);
     void socket_set_autocapital_type        (int client_id);
+    void socket_set_input_hint              (int client_id);
 };
 
 #endif
index 95a9b1f..7e34956 100644 (file)
@@ -752,6 +752,22 @@ SocketInstance::set_layout (unsigned int layout)
 }
 
 void
+SocketInstance::set_input_hint (unsigned int input_hint)
+{
+    Transaction trans;
+
+    global->init_transaction (trans);
+
+    SCIM_DEBUG_IMENGINE(1) << __func__<< " (" << m_peer_id << ")\n";
+
+    trans.put_command (ISM_TRANS_CMD_SET_INPUT_HINT);
+    trans.put_data (m_peer_id);
+    trans.put_data (input_hint);
+
+    commit_transaction (trans);
+}
+
+void
 SocketInstance::update_candidate_item_layout (const std::vector<unsigned int> &row_items)
 {
     Transaction trans;
index a83cefc..d7b7ac5 100644 (file)
@@ -117,6 +117,7 @@ public:
     virtual void longpress_candidate (unsigned int index);
     virtual void set_imdata (const char *data, unsigned int len);
     virtual void set_autocapital_type (int mode);
+    virtual void set_input_hint (unsigned int input_hint);
 
 private:
     bool commit_transaction (Transaction &trans);
index 7d3febd..43111f8 100644 (file)
@@ -45,7 +45,8 @@ typedef struct {
     Eina_Bool caps_mode;
     int layout_variation;
     Ecore_IMF_Autocapital_Type autocapital_type;
-    int reserved[247];
+    Ecore_IMF_Input_Hints input_hint;
+    int reserved[246];
 } Ise_Context;
 
 #endif  /* __ISE_CONTEXT_H */
index 9f69fcf..69db2f2 100644 (file)
@@ -735,6 +735,14 @@ FrontEndBase::set_layout (int id, unsigned int layout) const
 }
 
 void
+FrontEndBase::set_input_hint (int id, unsigned int input_hint) const
+{
+    IMEngineInstancePointer si = m_impl->find_instance (id);
+
+    if (!si.null ()) si->set_input_hint (input_hint);
+}
+
+void
 FrontEndBase::update_candidate_item_layout (int id, const std::vector<unsigned int> &row_items) const
 {
     IMEngineInstancePointer si = m_impl->find_instance (id);
index 8c2058b..3105c43 100644 (file)
@@ -529,6 +529,13 @@ protected:
     void set_autocapital_type (int id, int mode) const;
 
     /**
+     * @brief Set input hint.
+     * @param id the IMEngine instance id.
+     * @param input_hint - the input hint.
+     */
+    void set_input_hint (int id, unsigned int input_hint) const;
+
+    /**
      * @}
      */
 
index ef9ae99..4baac32 100644 (file)
@@ -174,6 +174,7 @@ public:
     HelperAgentSignalInt                signal_longpress_candidate;
     HelperAgentSignalKeyEventUint       signal_process_key_event;
     HelperAgentSignalUintVoid           signal_set_input_mode;
+    HelperAgentSignalUintVoid           signal_set_input_hint;
 
 public:
     HelperAgentImpl () : magic (0), magic_active (0), timeout (-1), focused_ic ((uint32) -1) { }
@@ -869,6 +870,14 @@ HelperAgent::filter_event ()
                     m_impl->signal_longpress_candidate (this, ic, ic_uuid, index);
                 break;
             }
+            case ISM_TRANS_CMD_SET_INPUT_HINT:
+            {
+                uint32 input_hint;
+
+                if (m_impl->recv.get_data (input_hint))
+                    m_impl->signal_set_input_hint (this, input_hint);
+                break;
+            }
             default:
                 break;
         }
@@ -2149,6 +2158,20 @@ HelperAgent::signal_connect_set_input_mode (HelperAgentSlotUintVoid *slot)
 }
 
 /**
+ * @brief Connect a slot to Helper set input hint signal.
+ *
+ * This signal is used to set Helper ISE input hint.
+ *
+ * The prototype of the slot is:
+ * void set_input_hint (const HelperAgent *agent, uint32 &input_hint);
+ */
+Connection
+HelperAgent::signal_connect_set_input_hint (HelperAgentSlotUintVoid *slot)
+{
+    return m_impl->signal_set_input_hint.connect (slot);
+}
+
+/**
  * @brief Connect a slot to Helper set shift mode signal.
  *
  * This signal is used to set Helper shift mode.
index e3509e6..b0df02d 100644 (file)
@@ -1219,6 +1219,16 @@ public:
      * void set_input_mode (const HelperAgent *agent, uint32 &input_mode);
      */
     Connection signal_connect_set_input_mode                        (HelperAgentSlotUintVoid            *slot);
+
+    /**
+     * @brief Connect a slot to Helper set input hint signal.
+     *
+     * This signal is used to set Helper ISE input hint.
+     *
+     * The prototype of the slot is:
+     * void set_input_hint (const HelperAgent *agent, uint32 &input_hint);
+     */
+    Connection signal_connect_set_input_hint                        (HelperAgentSlotUintVoid            *slot);
 };
 
 /**  @} */
index 6cadfc6..999da4e 100644 (file)
@@ -406,6 +406,11 @@ IMEngineInstanceBase::set_layout (unsigned int layout)
 }
 
 void
+IMEngineInstanceBase::set_input_hint (unsigned int input_hint)
+{
+}
+
+void
 IMEngineInstanceBase::update_candidate_item_layout (const std::vector<unsigned int> &row_items)
 {
 }
index f1013e6..30c0368 100644 (file)
@@ -739,6 +739,13 @@ public:
      */
     virtual void set_autocapital_type (int mode);
 
+    /**
+     * @brief Set input hint
+     *
+     * @param input_hint - the input hint.
+     */
+    virtual void set_input_hint (unsigned int input_hint);
+
 protected:
     /**
      * @name Signal activation functions
index 5378b91..591697f 100644 (file)
@@ -1707,6 +1707,32 @@ public:
         return false;
     }
 
+    bool set_helper_input_hint (const String &uuid, uint32 &hint)
+    {
+        HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
+
+        if (it != m_helper_client_index.end ()) {
+            int client;
+            uint32 context;
+            Socket client_socket (it->second.id);
+            uint32 ctx;
+
+            get_focused_context (client, context);
+            ctx = get_helper_ic (client, context);
+
+            m_send_trans.clear ();
+            m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
+            m_send_trans.put_data (ctx);
+            m_send_trans.put_data (uuid);
+            m_send_trans.put_command (ISM_TRANS_CMD_SET_INPUT_HINT);
+            m_send_trans.put_data (hint);
+            m_send_trans.write_to_socket (client_socket);
+            return true;
+        }
+
+        return false;
+    }
+
     bool set_helper_caps_mode (const String &uuid, uint32 &mode)
     {
         HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
@@ -2131,6 +2157,17 @@ public:
         }
     }
 
+    void set_ise_input_hint (int client_id)
+    {
+        SCIM_DEBUG_MAIN(4) << "PanelAgent::set_ise_input_hint ()\n";
+        uint32 input_hint;
+
+        if (m_recv_trans.get_data (input_hint)) {
+            if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode || m_current_helper_option & ISM_HELPER_PROCESS_KEYBOARD_KEYEVENT)
+                set_helper_input_hint (m_current_helper_uuid, input_hint);
+        }
+    }
+
     void set_ise_language (int client_id)
     {
         SCIM_DEBUG_MAIN(4) << "PanelAgent::set_ise_language ()\n";
@@ -3415,6 +3452,9 @@ private:
                     } else if (cmd == ISM_TRANS_CMD_SET_INPUT_MODE) {
                         set_ise_input_mode (client_id);
                         continue;
+                    } else if (cmd == ISM_TRANS_CMD_SET_INPUT_HINT) {
+                        set_ise_input_hint (client_id);
+                        continue;
                     }
 
                     current = last = false;
index bd767b0..b7627c4 100644 (file)
@@ -1033,6 +1033,13 @@ public:
         }
     }
 
+    void set_input_hint (int icid, int input_hint) {
+        if (m_send_refcount > 0 && m_current_icid == icid) {
+            m_send_trans.put_command (ISM_TRANS_CMD_SET_INPUT_HINT);
+            m_send_trans.put_data (input_hint);
+        }
+    }
+
     void get_layout (int* layout) {
         if (m_send_refcount > 0) {
             int cmd;
@@ -1732,6 +1739,12 @@ PanelClient::set_input_mode         (int input_mode)
 }
 
 void
+PanelClient::set_input_hint         (int icid, int input_hint)
+{
+    m_impl->set_input_hint (icid, input_hint);
+}
+
+void
 PanelClient::set_ise_language       (int language)
 {
     m_impl->set_ise_language (language);
index d4fd578..9a18def 100644 (file)
@@ -246,6 +246,7 @@ public:
     void process_key_event      (KeyEvent& key, int* ret);
     void get_active_helper_option (int* option);
     void set_input_mode         (int input_mode);
+    void set_input_hint         (int icid, int input_hint);
 
     /** @} */
 
index b3519eb..93e6e67 100644 (file)
@@ -648,6 +648,7 @@ const int ISM_TRANS_CMD_GET_RETURN_KEY_TYPE               = 1119;
 const int ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE            = 1120;
 const int ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE            = 1121;
 const int ISM_TRANS_CMD_SET_INPUT_MODE                    = 1122;
+const int ISM_TRANS_CMD_SET_INPUT_HINT                    = 1123;
 
 /* ISE/Panel to IMControl */
 const int ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT          = 1151;