From 32b556dccb4b6620e08acbce9d2813d19c17f873 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 29 Dec 2020 20:42:04 +0900 Subject: [PATCH] Add ime_event_set_input_hint_set_cb() API Change-Id: I8498de06c125484e8022c58b29580a296e481ccc Signed-off-by: Jihoon Kim --- inputmethod/include/inputmethod.h | 71 +++++++++++++++++++++++++++++++ inputmethod/src/inputmethod.cpp | 41 ++++++++++++++++++ 2 files changed, 112 insertions(+) diff --git a/inputmethod/include/inputmethod.h b/inputmethod/include/inputmethod.h index ecd3b36..3ae712a 100644 --- a/inputmethod/include/inputmethod.h +++ b/inputmethod/include/inputmethod.h @@ -486,6 +486,28 @@ typedef void (*ime_imdata_requested_cb)(void *user_data, void **data, unsigned i */ typedef void (*ime_layout_set_cb)(Ecore_IMF_Input_Panel_Layout layout, void *user_data); +/** + * @brief Called when an associated text input UI control requests the input panel to set input hint. + * + * @since_tizen 6.5 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks @a input_hint information is already set to the input panel when it is shown + * through #ime_context_h. This callback function will be only called when the client + * application changes the edit field's input hint attribute after the input panel is shown. + * + * @param[in] input_hint The input hint + * @param[in] user_data User data to be passed from the callback registration function + * + * @pre The callback can be registered using ime_event_set_input_hint_set_cb() function. + * + * @see ime_event_set_input_hint_set_cb() + */ +typedef void (*ime_input_hint_set_cb)(Ecore_IMF_Input_Hints input_hint, void *user_data); + /** * @brief Called when an associated text input UI control requests the input panel to set the @c Return key label. * The input panel can show text or image on the @c Return button according to the @c Return key action. @@ -2559,6 +2581,55 @@ int ime_update_input_panel_event(ime_event_type_e type, unsigned int value); */ int ime_set_candidate_visibility_state(bool visible); +/** + * @brief Sets @c input_hint_set event callback function. + * + * @since_tizen 6.5 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_input_hint_set_cb() callback function is called to set the input hint + * to deliver to the input panel. + * + * @param[in] callback_func @c input_hint_set 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_PERMISSION_DENIED The application does not have the privilege to call this function. + * @retval #IME_ERROR_INVALID_PARAMETER Invalid parameter + * @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_input_hint_set_cb() + * @see ime_run() + */ +int ime_event_set_input_hint_set_cb(ime_input_hint_set_cb callback_func, void *user_data); + +/** + * @brief Unsets @c input_hint_set event callback function. + * + * @since_tizen 6.5 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_input_hint_set_cb() callback function is called to set the input hint + * to deliver to the input panel. + * + * @return 0 on success, otherwise a negative error value + * @retval #IME_ERROR_NONE No error + * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function + * + * @see ime_input_hint_set_cb() + * @see ime_event_set_input_hint_set_cb() + */ +int ime_event_unset_input_hint_set_cb(void); + /** * @} */ diff --git a/inputmethod/src/inputmethod.cpp b/inputmethod/src/inputmethod.cpp index 77d0a53..e05d6be 100644 --- a/inputmethod/src/inputmethod.cpp +++ b/inputmethod/src/inputmethod.cpp @@ -86,6 +86,7 @@ class CCoreEventCallback : public ISCLCoreEventCallback void on_update_candidate_item_layout(const std::vector item); void on_update_displayed_candidate_number(sclu32 size); void on_longpress_candidate(sclu32 index); + void on_set_input_hint(sclu32 input_hint); }; typedef struct @@ -133,6 +134,7 @@ typedef struct ime_candidate_item_layout_set_cb candidate_item_layout_set; ime_displayed_candidate_number_chaned_cb displayed_candidate_number_chaned; ime_candidate_item_long_pressed_cb candidate_item_long_pressed; + ime_input_hint_set_cb input_hint_set; /**< Called when an edit field requests the input panel to set its input hint */ void *focus_in_user_data; void *focus_out_user_data; void *surrounding_text_updated_user_data; @@ -176,6 +178,7 @@ typedef struct void *candidate_item_layout_set_user_data; void *displayed_candidate_number_chaned_user_data; void *candidate_item_long_pressed_user_data; + void *input_hint_set_user_data; } ime_event_callback_s; typedef struct { @@ -355,6 +358,13 @@ void CCoreEventCallback::on_set_layout(sclu32 layout) } } +void CCoreEventCallback::on_set_input_hint(sclu32 input_hint) +{ + if (g_event_callback.input_hint_set) { + g_event_callback.input_hint_set(static_cast(input_hint), g_event_callback.input_hint_set_user_data); + } +} + void CCoreEventCallback::on_reset_input_context(sclint ic, const sclchar *uuid) { if (g_event_callback.input_context_reset) { @@ -1114,6 +1124,37 @@ EXPORT_API int ime_event_set_option_window_destroyed_cb(ime_option_window_destro return IME_ERROR_NONE; } +EXPORT_API int ime_event_set_input_hint_set_cb(ime_input_hint_set_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.input_hint_set = callback_func; + g_event_callback.input_hint_set_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_unset_input_hint_set_cb(void) +{ + ime_error_e retVal = IME_ERROR_NONE; + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.input_hint_set = NULL; + g_event_callback.input_hint_set_user_data = NULL; + + return IME_ERROR_NONE; +} + //LCOV_EXCL_START EXPORT_API int ime_event_set_caps_mode_changed_cb(ime_caps_mode_changed_cb callback_func, void *user_data) { -- 2.34.1