Added interface for supporting unconventional input devices 89/70589/6
authorJi-hoon Lee <dalton.lee@samsung.com>
Wed, 18 May 2016 08:01:28 +0000 (17:01 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 15 Jun 2016 05:32:22 +0000 (22:32 -0700)
Change-Id: I7c60f8e8c02dcb2e6f878c7651c2100a595a9a10

17 files changed:
ism/extras/wayland_immodule/wayland_imcontext.c
ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp
ism/modules/panelagent/wayland/isf_wsc_control.cpp
ism/modules/panelagent/wayland/isf_wsc_control.h
ism/modules/panelagent/wayland/isf_wsc_control_ui.cpp
ism/modules/panelagent/wayland/isf_wsc_control_ui.h
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_panel_client.cpp [changed mode: 0755->0644]
ism/src/scim_trans_commands.h

index 8203f1a..ed72a97 100644 (file)
@@ -162,6 +162,34 @@ key_up_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
     return EINA_FALSE;
 }
 
+#ifdef _WEARABLE
+static Eina_Bool
+rotary_event_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
+{
+    Ecore_Event_Detent_Rotate *ev = event;
+    if (!ev) return EINA_TRUE;
+
+    Ecore_IMF_Context *active_ctx = NULL;
+    if (_show_req_ctx)
+        active_ctx = _show_req_ctx;
+    else if (_focused_ctx)
+        active_ctx = _focused_ctx;
+
+    if (!active_ctx) return EINA_TRUE;
+
+    if (_input_panel_state == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
+        return EINA_TRUE;
+
+    WaylandIMContext *imcontext = (WaylandIMContext *)ecore_imf_context_data_get(active_ctx);
+    if (imcontext) {
+        wl_text_input_process_input_device_event(imcontext->text_input,
+            (unsigned int)ECORE_EVENT_DETENT_ROTATE, (char*)event, sizeof(Ecore_Event_Detent_Rotate));
+    }
+
+    return EINA_FALSE;
+}
+#endif
+
 static Eina_Bool
 _ecore_event_filter_cb(void *data, void *loop_data EINA_UNUSED, int type, void *event)
 {
@@ -171,6 +199,12 @@ _ecore_event_filter_cb(void *data, void *loop_data EINA_UNUSED, int type, void *
     else if (type == ECORE_EVENT_KEY_UP) {
         return key_up_cb(data, type, event);
     }
+#ifdef _WEARABLE
+    /* The IME needs to process Rotary event prior to client application */
+    else if (type == ECORE_EVENT_DETENT_ROTATE) {
+        return rotary_event_cb(data, type, event);
+    }
+#endif
 
     return EINA_TRUE;
 }
index d1f21c1..f430e38 100644 (file)
@@ -973,6 +973,36 @@ private:
         m_send_trans.write_to_socket(client_socket);
     }
 
+    bool process_input_device_event(int client, uint32 context, const String& uuid, uint32 type, const char *data, size_t len, _OUT_ uint32& result) {
+        LOGD("client id:%d\n", client);
+
+        Socket client_socket(client);
+
+        Transaction trans;
+
+        trans.clear();
+        trans.put_command(SCIM_TRANS_CMD_REPLY);
+        trans.put_data(context);
+        trans.put_data(uuid);
+        trans.put_command(ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT);
+        trans.put_data(type);
+        trans.put_data(data, len);
+        int cmd;
+
+        if (trans.write_to_socket(client_socket)
+            && trans.read_from_socket(client_socket)
+            && trans.get_command(cmd) && cmd == SCIM_TRANS_CMD_REPLY
+            && trans.get_data(result)) {
+            SCIM_DEBUG_MAIN(1) << __func__ << " success\n";
+            return true;
+        }
+        else {
+            LOGW("read failed\n");
+        }
+
+        return false;
+    }
+
     void socket_update_surrounding_text(int client, uint32 context, const String& uuid, String& text, uint32 cursor) {
         SCIM_DEBUG_MAIN(4) << __FUNCTION__ << "...\n";
         LOGD ("client id:%d\n", client);
index 737aef0..be8c9bd 100644 (file)
@@ -206,6 +206,12 @@ int _isf_wsc_context_input_panel_send_candidate_will_hide_ack (int context)
     return 0;
 }
 
+int _isf_wsc_context_process_input_device_event(int context, int type, const void* data, int len)
+{
+    uint32 result;
+    g_info_manager->process_input_device_event(context, (unsigned int)type, (const char*)data, (size_t)len, result);
+    return 0;
+}
 /*
 vi:ts=4:expandtab:nowrap
 */
index d5f69d7..29ba0b9 100644 (file)
@@ -63,6 +63,7 @@ extern "C"
     int _isf_wsc_context_set_keyboard_mode (int context, scim::TOOLBAR_MODE_T mode);
 
     int _isf_wsc_context_input_panel_send_candidate_will_hide_ack (int context);
+    int _isf_wsc_context_process_input_device_event(int context, int type, const void* data, int len);
 
 #ifdef __cplusplus
 }
index 2ec9715..64b1e73 100644 (file)
@@ -265,3 +265,8 @@ void isf_wsc_context_input_panel_imdata_get (WSCContextISF *ctx, void **imdata,
 {
     _isf_wsc_context_input_panel_imdata_get (_get_context_id (ctx), imdata, len);
 }
+
+void isf_wsc_context_process_input_device_event (WSCContextISF *ctx, uint32_t type, const char *data, uint32_t len)
+{
+    _isf_wsc_context_process_input_device_event (_get_context_id(ctx), type, data, len);
+}
index a99e33a..4145eea 100644 (file)
@@ -53,6 +53,7 @@ extern "C"
     void isf_wsc_context_input_panel_return_key_disabled_set (WSCContextISF *ctx, Eina_Bool disabled);
     void isf_wsc_context_input_panel_imdata_set (WSCContextISF *ctx, const void *imdata, int len);
     void isf_wsc_context_input_panel_imdata_get (WSCContextISF *ctx, void **imdata, int* len);
+    void isf_wsc_context_process_input_device_event (WSCContextISF *ctx, uint32_t type, const char *data, uint32_t len);
 
 #ifdef __cplusplus
 }
index 555b26a..77f3104 100644 (file)
@@ -403,6 +403,17 @@ _wsc_im_ctx_cursor_position(void *data, struct wl_input_method_context *im_ctx,
     g_info_manager->socket_update_cursor_position (cursor_pos);
 }
 
+static void
+_wsc_im_ctx_process_input_device_event(void *data, struct wl_input_method_context *im_ctx, uint32_t type, const char *input_data, uint32_t input_data_len)
+{
+    WSCContextISF *wsc_ctx = (WSCContextISF*)data;
+
+    LOGD("im_context = %p type = %d, data = (%p) %d\n", im_ctx, type, input_data, input_data_len);
+    if (!wsc_ctx) return;
+
+    isf_wsc_context_process_input_device_event(wsc_ctx, type, input_data, input_data_len);
+}
+
 static const struct wl_input_method_context_listener wsc_im_context_listener = {
      _wsc_im_ctx_reset,
      _wsc_im_ctx_content_type,
@@ -413,7 +424,8 @@ static const struct wl_input_method_context_listener wsc_im_context_listener = {
      _wsc_im_ctx_return_key_disabled,
      _wsc_im_ctx_input_panel_data,
      _wsc_im_ctx_bidi_direction,
-     _wsc_im_ctx_cursor_position
+     _wsc_im_ctx_cursor_position,
+     _wsc_im_ctx_process_input_device_event
 };
 
 static void
index 8505aeb..451fb1c 100644 (file)
@@ -1358,6 +1358,23 @@ public:
         return false;
     }
 
+    //ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT
+    bool process_input_device_event(int client_id, uint32 type, const char *data, size_t len, _OUT_ uint32& result) {
+        SCIM_DEBUG_MAIN(4) << "InfoManager::process_input_device_event ()\n";
+        HelperClientIndex::iterator it = m_helper_client_index.find(m_current_helper_uuid);
+
+        if (it != m_helper_client_index.end()) {
+            int    client;
+            uint32 context;
+            uint32 ctx;
+            get_focused_context(client, context);
+            ctx = get_helper_ic(client, context);
+            return m_panel_agent_manager.process_input_device_event(it->second.id, ctx, m_current_helper_uuid, type, data, len, result);
+        }
+
+        return false;
+    }
+
     bool get_helper_geometry (String& uuid, struct rectinfo& info) {
         HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
 
@@ -4308,6 +4325,12 @@ void InfoManager::focus_out (int client_id, uint32 context)
     m_impl->focus_out (client_id, context);
 }
 
+//ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT
+bool InfoManager::process_input_device_event(int client, uint32 type, const char *data, size_t len, _OUT_ uint32& result)
+{
+    return m_impl->process_input_device_event(client, type, data, len, result);
+}
+
 //ISM_TRANS_CMD_TURN_ON_LOG
 void InfoManager::socket_turn_on_log (uint32 isOn)
 {
index 30deb02..b90fc43 100644 (file)
@@ -740,6 +740,9 @@ public:
     //SCIM_TRANS_CMD_FOCUS_OUT
     void focus_out (int client_id, uint32 context);
 
+    //ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT
+    bool process_input_device_event(int client_id, uint32 type, const char *data, size_t len, _OUT_ uint32& result);
+
     //ISM_TRANS_CMD_TURN_ON_LOG
     void socket_turn_on_log (uint32 isOn);
 
index 1e6fa86..0976cea 100644 (file)
@@ -493,6 +493,11 @@ void PanelAgentBase::hide_helper_ise (int client, uint32 context)
     LOGW ("not implemented for %s", m_name.c_str ());
 }
 
+bool PanelAgentBase::process_input_device_event(int client, uint32 context, const String& uuid, uint32 type, const char *data, size_t len, _OUT_ uint32& result)
+{
+    LOGW("not implemented for %s", m_name.c_str());
+    return false;
+}
 
 } /* namespace scim */
 
index a6855a0..5d51a79 100644 (file)
@@ -780,6 +780,15 @@ public:
      * @return none.
      */
     virtual void hide_helper_ise (int client, uint32 context);
+
+    /**
+    * @brief process_input_device_event.
+    *
+    * @param
+    *
+    * @return none.
+    */
+    virtual bool process_input_device_event(int client, uint32 context, const String& uuid, uint32 type, const char *data, size_t len, _OUT_ uint32& result);
 };
 
 /**  @} */
index 22d25c7..7691542 100644 (file)
@@ -635,6 +635,15 @@ void PanelAgentManager::process_helper_event (int id, uint32 context_id, String
         _p->process_helper_event (id, context_id, target_uuid, active_uuid, nest_trans);
 }
 
+bool PanelAgentManager::process_input_device_event(int id, uint32 context_id, const String& uuid, uint32 type, const char *data, size_t len, _OUT_ uint32& result)
+{
+    PanelAgentPointer _p = m_impl->get_panel_agent_by_id(id);
+
+    if (!_p.null())
+        return _p->process_input_device_event(id, context_id, uuid, type, data, len, result);
+    return false;
+}
+
 void PanelAgentManager::socket_helper_key_event (int id, uint32 context_id, int cmd , KeyEvent& key)
 {
     PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
index b3ee1ea..40d32a0 100644 (file)
@@ -341,6 +341,7 @@ public:
     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);
+    bool process_input_device_event(int client, uint32 context, const String& uuid, uint32 type, const char *data, size_t len, _OUT_ uint32& result);
 };
 
 /**  @} */
index 760b20a..760812a 100644 (file)
@@ -125,6 +125,9 @@ typedef Signal2<void, const HelperAgent *, LookupTable &>
 typedef Signal3<void, const HelperAgent *, KeyEvent &, uint32 &>
         HelperAgentSignalKeyEventUint;
 
+typedef Signal5<void, const HelperAgent *, uint32 &, char *, size_t &, uint32 &>
+        HelperAgentSignalUintCharSizeUint;
+
 class HelperAgent::HelperAgentImpl
 {
 public:
@@ -207,6 +210,7 @@ public:
     HelperAgentSignalUintVoid           signal_update_bidi_direction;
     HelperAgentSignalVoid               signal_show_option_window;
     HelperAgentSignalUintVoid           signal_check_option_window;
+    HelperAgentSignalUintCharSizeUint   signal_process_input_device_event;
 
 public:
     HelperAgentImpl (HelperAgent* thiz) : focused_ic ((uint32) -1), thiz (thiz),
@@ -1344,6 +1348,24 @@ HelperAgent::filter_event ()
                 m_impl->send.write_to_socket (m_impl->socket);
                 break;
             }
+            case ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT:
+            {
+                uint32 ret = 0;
+                uint32 type;
+                char *data = NULL;
+                size_t len;
+                if (m_impl->recv.get_data(type) &&
+                    m_impl->recv.get_data(&data, len)) {
+                    m_impl->signal_process_input_device_event(this, type, data, len, ret);
+                }
+                else
+                    LOGW("wrong format of transaction\n");
+                m_impl->send.clear();
+                m_impl->send.put_command(SCIM_TRANS_CMD_REPLY);
+                m_impl->send.put_data(ret);
+                m_impl->send.write_to_socket(m_impl->socket);
+                break;
+            }
             default:
                 break;
         }
@@ -3316,6 +3338,20 @@ HelperAgent::signal_connect_check_option_window (HelperAgentSlotUintVoid *slot)
 
 } /* namespace scim */
 
+/**
+ * @brief Connect a slot to Helper process unconventional input device event signal.
+ *
+ * This signal is used to send unconventional input device event to Helper ISE.
+ *
+ * The prototype of the slot is:
+ * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
+ */
+Connection
+HelperAgent::signal_connect_process_input_device_event (HelperAgentSlotUintCharSizeUint *slot)
+{
+    return m_impl->signal_process_input_device_event.connect (slot);
+}
+
 /*
 vi:ts=4:nowrap:ai:expandtab
 */
index 268254a..334d3ba 100644 (file)
@@ -212,6 +212,9 @@ typedef Slot2<void, const HelperAgent *, LookupTable &>
 typedef Slot3<void, const HelperAgent *, KeyEvent &, uint32 &>
         HelperAgentSlotKeyEventUint;
 
+typedef Slot5<void, const HelperAgent *, uint32 &, char *, size_t &, uint32 &>
+        HelperAgentSlotUintCharSizeUint;
+
 /**
  * @brief The accessory class to write a Helper object.
  *
@@ -1284,6 +1287,14 @@ public:
      * void check_option_window (const HelperAgent *agent, uint32 &avail);
      */
     Connection signal_connect_check_option_window                   (HelperAgentSlotUintVoid            *slot);
+
+    /**
+    * @brief Connect a slot to Helper process unconventional input device event signal.
+    *
+    * The prototype of the slot is:
+    * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
+    */
+    Connection signal_connect_process_input_device_event            (HelperAgentSlotUintCharSizeUint *slot);
 };
 
 /**  @} */
old mode 100755 (executable)
new mode 100644 (file)
index d672250..9511166 100644 (file)
@@ -657,6 +657,7 @@ const int ISM_TRANS_CMD_SET_INPUT_MODE                    = 1122;
 const int ISM_TRANS_CMD_SET_INPUT_HINT                    = 1123;
 const int ISM_TRANS_CMD_UPDATE_BIDI_DIRECTION             = 1124;
 const int ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW            = 1125;
+const int ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT        = 1126;
 
 /* ISE/Panel to IMControl */
 const int ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT          = 1151;