Add ime_event_set_process_key_event_with_keycode_cb API 63/200763/5
authorInhong Han <inhong1.han@samsung.com>
Mon, 4 Mar 2019 01:13:07 +0000 (10:13 +0900)
committerInhong Han <inhong1.han@samsung.com>
Mon, 11 Mar 2019 10:04:36 +0000 (19:04 +0900)
Change-Id: I98184f634223e7f51a8cbbdab11de81e16b9a3a4

include/inputmethod.h
src/inputmethod.cpp

index 0710aff..afbd012 100644 (file)
@@ -552,7 +552,7 @@ typedef void (*ime_return_key_state_set_cb)(bool disabled, void *user_data);
 typedef void (*ime_geometry_requested_cb)(void *user_data, int *x, int *y, int *w, int *h);
 
 /**
- * @brief Called when the key event is received from the external devices or ime_send_key_event() function.
+ * @brief Called when a key event is received from external devices or ime_send_key_event().
  *
  * @details This function processes the key event before an associated text input UI control does.
  *
@@ -563,15 +563,16 @@ typedef void (*ime_geometry_requested_cb)(void *user_data, int *x, int *y, int *
  * @privilege %http://tizen.org/privilege/ime
  *
  * @remarks If the key event is from the external device, @a dev_info will have its name, class and subclass information.
+ * @a dev_info should not be released by the application. The platform manages the handle and will release it when ime_process_key_event_cb() exits.
  *
- * @param[in] keycode The key code to be sent
- * @param[in] keymask The modifier key mask
+ * @param[in] key_code The key code to be sent
+ * @param[in] key_mask The modifier key mask
  * @param[in] dev_info The device information handle
  * @param[in] user_data User data to be passed from the callback registration function
  *
- * @return @c true if the event is processed, otherwise the event is not processed and is forwarded to the client application.
+ * @return @c true if the event was processed, otherwise the event was not processed and was forwarded to the client application.
  *
- * @pre The callback can be registered using ime_event_set_process_key_event_cb() function.
+ * @pre The callback should be registered using ime_event_set_process_key_event_cb() function.
  *
  * @see ime_event_set_process_key_event_cb()
  * @see ime_device_info_get_name()
@@ -583,7 +584,44 @@ typedef void (*ime_geometry_requested_cb)(void *user_data, int *x, int *y, int *
  * @see ime_hide_preedit_string()
  * @see ime_update_preedit_string()
  */
-typedef bool (*ime_process_key_event_cb)(ime_key_code_e keycode, ime_key_mask_e keymask, ime_device_info_h dev_info, void *user_data);
+typedef bool (*ime_process_key_event_cb)(ime_key_code_e key_code, ime_key_mask_e key_mask, ime_device_info_h dev_info, void *user_data);
+
+/**
+ * @brief Called when a key event is received from external devices or ime_send_key_event().
+ * Provides the key code.
+ *
+ * @details This function processes the key event with keycode before an associated text input UI control does.
+ *
+ * @since_tizen 5.5
+ *
+ * @privlevel public
+ *
+ * @privilege %http://tizen.org/privilege/ime
+ *
+ * @remarks If the key event is from the external device, @a dev_info will have its name, class and subclass information.
+ * @a dev_info should not be released by the application. The platform manages the handle and will release it when ime_process_key_event_with_keycode_cb() exits.
+ *
+ * @param[in] key_code The X11 key code to be sent
+ * @param[in] key_sym The key symbol to be sent
+ * @param[in] key_mask The modifier key mask
+ * @param[in] dev_info The device information handle
+ * @param[in] user_data User data to be passed from the callback registration function
+ *
+ * @return @c true if the event was processed, otherwise the event was not processed and was forwarded to the client application.
+ *
+ * @pre The callback should be registered using ime_event_set_process_key_event_with_keycode_cb() function.
+ *
+ * @see ime_event_set_process_key_event_with_keycode_cb()
+ * @see ime_device_info_get_name()
+ * @see ime_device_info_get_class()
+ * @see ime_device_info_get_subclass()
+ * @see ime_send_key_event()
+ * @see ime_commit_string()
+ * @see ime_show_preedit_string()
+ * @see ime_hide_preedit_string()
+ * @see ime_update_preedit_string()
+ */
+typedef bool (*ime_process_key_event_with_keycode_cb)(unsigned int key_code, ime_key_code_e key_sym, ime_key_mask_e key_mask, ime_device_info_h dev_info, void *user_data);
 
 /**
  * @brief Called when the system display language is changed.
@@ -898,7 +936,7 @@ int ime_run(ime_callback_s *basic_cb, void *user_data);
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_focus_in_cb()
  * @see ime_run()
@@ -926,7 +964,7 @@ int ime_event_set_focus_in_cb(ime_focus_in_cb callback_func, void *user_data);
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_focus_out_cb()
  * @see ime_run()
@@ -954,7 +992,7 @@ int ime_event_set_focus_out_cb(ime_focus_out_cb callback_func, void *user_data);
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_surrounding_text_updated_cb()
  * @see ime_run()
@@ -982,7 +1020,7 @@ int ime_event_set_surrounding_text_updated_cb(ime_surrounding_text_updated_cb ca
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_input_context_reset_cb()
  * @see ime_run()
@@ -1010,7 +1048,7 @@ int ime_event_set_input_context_reset_cb(ime_input_context_reset_cb callback_fun
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_cursor_position_updated_cb()
  * @see ime_run()
@@ -1038,7 +1076,7 @@ int ime_event_set_cursor_position_updated_cb(ime_cursor_position_updated_cb call
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_language_requested_cb()
  * @see ime_run()
@@ -1066,7 +1104,7 @@ int ime_event_set_language_requested_cb(ime_language_requested_cb callback_func,
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_language_set_cb()
  * @see ime_run()
@@ -1094,7 +1132,7 @@ int ime_event_set_language_set_cb(ime_language_set_cb callback_func, void *user_
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_imdata_set_cb()
  * @see ime_event_set_imdata_requested_cb()
@@ -1123,7 +1161,7 @@ int ime_event_set_imdata_set_cb(ime_imdata_set_cb callback_func, void *user_data
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_imdata_requested_cb()
  * @see ime_event_set_imdata_set_cb()
@@ -1152,7 +1190,7 @@ int ime_event_set_imdata_requested_cb(ime_imdata_requested_cb callback_func, voi
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_layout_set_cb()
  * @see ime_run()
@@ -1180,7 +1218,7 @@ int ime_event_set_layout_set_cb(ime_layout_set_cb callback_func, void *user_data
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_return_key_type_set_cb()
  * @see ime_run()
@@ -1208,7 +1246,7 @@ int ime_event_set_return_key_type_set_cb(ime_return_key_type_set_cb callback_fun
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_return_key_state_set_cb()
  * @see ime_run()
@@ -1236,7 +1274,7 @@ int ime_event_set_return_key_state_set_cb(ime_return_key_state_set_cb callback_f
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_geometry_requested_cb()
  * @see ime_run()
@@ -1264,7 +1302,7 @@ int ime_event_set_geometry_requested_cb(ime_geometry_requested_cb callback_func,
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_process_key_event_cb()
  * @see ime_run()
@@ -1316,6 +1354,34 @@ int ime_event_set_geometry_requested_cb(ime_geometry_requested_cb callback_func,
 int ime_event_set_process_key_event_cb(ime_process_key_event_cb callback_func, void *user_data);
 
 /**
+ * @brief Sets @c process_key_event_whit_keycode event callback function.
+ *
+ * @since_tizen 5.5
+ *
+ * @privlevel public
+ *
+ * @privilege %http://tizen.org/privilege/ime
+ *
+ * @remarks The ime_process_key_event_with_keycode_cb() callback function is called when the key event
+ * is received from external keyboard devices or ime_send_key_event().
+ *
+ * @param[in] callback_func @c process_key_event_with_keycode() event callback function
+ * @param[in] user_data User data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #IME_ERROR_NONE No error
+ * @retval #IME_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
+ * @retval #IME_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @post The ime_run() function should be called to start the IME application's main loop.
+ *
+ * @see ime_process_key_event_with_keycode_cb()
+ * @see ime_run()
+ */
+int ime_event_set_process_key_event_with_keycode_cb(ime_process_key_event_with_keycode_cb callback_func, void *user_data);
+
+/**
  * @brief Sets @c display_language_changed event callback function.
  *
  * @since_tizen @if MOBILE 2.4 @else 3.0 @endif
@@ -1336,7 +1402,7 @@ int ime_event_set_process_key_event_cb(ime_process_key_event_cb callback_func, v
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_display_language_changed_cb()
  * @see ime_run()
@@ -1364,7 +1430,7 @@ int ime_event_set_display_language_changed_cb(ime_display_language_changed_cb ca
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_rotation_degree_changed_cb()
  * @see ime_run()
@@ -1392,7 +1458,7 @@ int ime_event_set_rotation_degree_changed_cb(ime_rotation_degree_changed_cb call
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_accessibility_state_changed_cb()
  * @see ime_run()
@@ -1419,7 +1485,7 @@ int ime_event_set_accessibility_state_changed_cb(ime_accessibility_state_changed
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_option_window_created_cb()
  * @see ime_run()
@@ -1446,7 +1512,7 @@ int ime_event_set_option_window_created_cb(ime_option_window_created_cb callback
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  * @retval #IME_ERROR_OPERATION_FAILED Operation failed
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_option_window_destroyed_cb()
  * @see ime_run()
@@ -2249,7 +2315,7 @@ int ime_device_info_get_subclass(ime_device_info_h dev_info, Ecore_IMF_Device_Su
  * @retval #IME_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_prediction_hint_set_cb()
  * @see ime_run()
@@ -2276,7 +2342,7 @@ int ime_event_set_prediction_hint_set_cb(ime_prediction_hint_set_cb callback_fun
  * @retval #IME_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_mime_type_set_request_cb()
  * @see ime_run()
@@ -2419,7 +2485,7 @@ int ime_set_floating_drag_end(void);
  * @retval #IME_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
  *
- * @post The ime_run() function should be called to start to run IME application's main loop.
+ * @post The ime_run() function should be called to start the IME application's main loop.
  *
  * @see ime_prediction_hint_data_set_cb()
  * @see ime_run()
index 4dd4e82..1b702d1 100644 (file)
@@ -55,7 +55,7 @@ class CCoreEventCallback : public ISCLCoreEventCallback
     void on_set_return_key_disable(sclu32 disabled);
     void on_set_layout(sclu32 layout);
     void on_reset_input_context(sclint ic, const sclchar *uuid);
-    void on_process_key_event(scim::KeyEvent &key, sclu32 *ret);
+    void on_process_key_event(scim::KeyEvent &key, sclu32 *ret, sclu32 keycode);
     void on_set_display_language(const sclchar *language);
     void on_set_rotation_degree(sclint degree);
     void on_set_accessibility_state(sclboolean state);
@@ -89,6 +89,7 @@ typedef struct
     ime_return_key_state_set_cb return_key_state_set;   /**< Called when an edit field requests the input panel to enable or disable the "return" key state */
     ime_geometry_requested_cb geometry_requested;       /**< Called when an edit field requests the position and size from the input panel */
     ime_process_key_event_cb process_key_event;         /**< Called when the key event is received from the external keyboard devices */
+    ime_process_key_event_with_keycode_cb process_key_event_with_keycode; /**< Called when the key event is received from the external keyboard devices */
     ime_display_language_changed_cb display_language_changed;   /**< Called when the system display language is changed */
     ime_rotation_degree_changed_cb rotation_degree_changed;     /**< Called when the device is rotated */
     ime_accessibility_state_changed_cb accessibility_state_changed; /**< Called when Accessibility in Settings application is on or off */
@@ -117,6 +118,7 @@ typedef struct
     void *return_key_state_set_user_data;
     void *geometry_requested_user_data;
     void *process_key_event_user_data;
+    void *process_key_event_with_keycode_user_data;
     void *display_language_changed_user_data;
     void *rotation_degree_changed_user_data;
     void *accessibility_state_changed_user_data;
@@ -314,19 +316,32 @@ void CCoreEventCallback::on_reset_input_context(sclint ic, const sclchar *uuid)
     }
 }
 
-void CCoreEventCallback::on_process_key_event(scim::KeyEvent &key, sclu32 *ret)
+void CCoreEventCallback::on_process_key_event(scim::KeyEvent &key, sclu32 *ret, sclu32 keycode)
 {
-    if (g_event_callback.process_key_event) {
+    if (g_event_callback.process_key_event_with_keycode || g_event_callback.process_key_event) {
         struct _ime_device_info dev_info = {key.dev_name.c_str(),
             static_cast<Ecore_IMF_Device_Class>(key.dev_class), static_cast<Ecore_IMF_Device_Subclass>(key.dev_subclass)};
-        bool processed = g_event_callback.process_key_event(static_cast<ime_key_code_e>(key.code), static_cast<ime_key_mask_e>(key.mask),
-            static_cast<ime_device_info_h>(&dev_info), g_event_callback.process_key_event_user_data);
 
-        if (ret) {
-            if (processed)
-                *ret = 1;
-            else
-                *ret = 0;
+        if (g_event_callback.process_key_event_with_keycode) {
+            bool processed = g_event_callback.process_key_event_with_keycode(keycode, static_cast<ime_key_code_e>(key.code), static_cast<ime_key_mask_e>(key.mask),
+                static_cast<ime_device_info_h>(&dev_info), g_event_callback.process_key_event_user_data);
+
+            if (ret) {
+                if (processed)
+                    *ret = 1;
+                else
+                    *ret = 0;
+            }
+        } else if (g_event_callback.process_key_event) {
+            bool processed = g_event_callback.process_key_event(static_cast<ime_key_code_e>(key.code), static_cast<ime_key_mask_e>(key.mask),
+                static_cast<ime_device_info_h>(&dev_info), g_event_callback.process_key_event_user_data);
+
+            if (ret) {
+                if (processed)
+                    *ret = 1;
+                else
+                    *ret = 0;
+            }
         }
     } else {
         if (ret) {
@@ -818,6 +833,24 @@ EXPORT_API int ime_event_set_process_key_event_cb(ime_process_key_event_cb callb
     return IME_ERROR_NONE;
 }
 
+EXPORT_API int ime_event_set_process_key_event_with_keycode_cb(ime_process_key_event_with_keycode_cb callback_func, void *user_data)
+{
+    ime_error_e retVal = IME_ERROR_NONE;
+
+    if (!callback_func) {
+        LOGW("IME_ERROR_INVALID_PARAMETER");
+        return IME_ERROR_INVALID_PARAMETER;
+    }
+
+    retVal = _check_privilege();
+    if (retVal != IME_ERROR_NONE) return retVal;
+
+    g_event_callback.process_key_event_with_keycode = callback_func;
+    g_event_callback.process_key_event_with_keycode_user_data = user_data;
+
+    return IME_ERROR_NONE;
+}
+
 EXPORT_API int ime_event_set_display_language_changed_cb(ime_display_language_changed_cb callback_func, void *user_data)
 {
     ime_error_e retVal = IME_ERROR_NONE;