From: Inhong Han Date: Wed, 8 May 2024 08:15:14 +0000 (+0900) Subject: Add new APIs to move and resize the floating input panel X-Git-Tag: accepted/tizen/unified/20240603.032323~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0908221436151a4c47e1bffe02446e7099efa6d9;p=platform%2Fcore%2Fapi%2Finputmethod.git Add new APIs to move and resize the floating input panel Change-Id: Ia72b0998e80d93cd74de1e674c686376ca3efa87 --- diff --git a/inputmethod/include/inputmethod.h b/inputmethod/include/inputmethod.h index ec3c64d..535ac92 100644 --- a/inputmethod/include/inputmethod.h +++ b/inputmethod/include/inputmethod.h @@ -814,6 +814,27 @@ typedef void (*ime_mime_type_set_request_cb)(const char *mime_type, void *user_d */ typedef void (*ime_prediction_hint_data_set_cb)(const char *key, const char *value, void *user_data); +/** + * @brief Called when an associated text input UI control sets the position align of the input panel. + * + * @since_tizen 9.0 + * + * @privlevel public + * + * @remarks Regardless of the rotation degree, the @a x, @a y values of the top-left corner on the screen are based on 0, 0. + * This function is used to adjust the position of the input panel when its size changes in floating mode. + * + * @param[in] x The x coordinate of the @a align + * @param[in] y The y coordinate of the @a align + * @param[in] align The position alignment that the client application wants + * @param[in] user_data User data to be passed to the callback function + * + * @pre The callback can be registered using ime_event_set_position_align_set_cb() function. + * + * @see ime_event_set_position_align_set_cb() + */ +typedef void (*ime_position_align_set_cb)(int x, int y, Ecore_IMF_Input_Panel_Align align, void *user_data); + /** * @brief The structure type to contain the set of the essential callback functions for IME application lifecycle and appearance. * @@ -2683,6 +2704,85 @@ int ime_event_set_input_hint_set_cb(ime_input_hint_set_cb callback_func, void *u */ int ime_event_unset_input_hint_set_cb(void); +/** + * @brief Sets ime_position_align_set_cb() event callback function. + * + * @since_tizen 9.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_position_align_set_cb() callback function is called when an associated text input + * UI control sets the position align of the input panel. + * + * @param[in] callback_func ime_position_align_set_cb() 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 + * + * @post The ime_run() function should be called to start the IME application's main loop. + * + * @see ime_position_align_set_cb() + * @see ime_run() + */ +int ime_event_set_position_align_set_cb(ime_position_align_set_cb callback_func, void *user_data); + +/** + * @brief Unsets ime_position_align_set_cb() event callback function. + * + * @since_tizen 9.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks The ime_position_align_set_cb() callback function is called when an associated text input + * UI control sets the position align of 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_position_align_set_cb() + * @see ime_event_set_position_align_set_cb() + */ +int ime_event_unset_position_align_set_cb(void); + +/** + * @brief Moves and resizes the floating input panel window. + * + * @details This function must be called after the ime_focus_in_cb() callback is called. Otherwise the call will be ignored. + * + * @since_tizen 9.0 + * + * @privlevel public + * + * @privilege %http://tizen.org/privilege/ime + * + * @remarks Regardless of the rotation degree, the @a x, @a y values of the top-left corner on the screen are based on 0, 0. + * This function can be used in floating mode. If the floating mode is deactivated, calling this function has no effect. + * + * @param[in] x The top-left x coordinate of the input panel + * @param[in] y The top-left y coordinate of the input panel + * @param[in] w The new width of the input panel + * @param[in] h The new height of 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. + * @retval #IME_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #IME_ERROR_NOT_RUNNING IME main loop is not started yet + * + * @pre The floating mode was turned on with ime_set_floating_mode(). + * + * @see ime_set_floating_mode() + */ +int ime_move_resize_floating_window(int x, int y, int w, int h); + /** * @} */ diff --git a/inputmethod/src/inputmethod.cpp b/inputmethod/src/inputmethod.cpp index 0e69126..f7bada9 100644 --- a/inputmethod/src/inputmethod.cpp +++ b/inputmethod/src/inputmethod.cpp @@ -87,6 +87,7 @@ class CCoreEventCallback : public ISCLCoreEventCallback void on_update_displayed_candidate_number(sclu32 size); void on_longpress_candidate(sclu32 index); void on_set_input_hint(sclu32 input_hint); + void on_set_position_align(sclu32 x, sclu32 y, sclu32 align); }; typedef struct @@ -135,6 +136,7 @@ typedef struct 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 */ + ime_position_align_set_cb position_align_set; /**< Called when an edit field sets the position align of the input panel */ void *focus_in_user_data; void *focus_out_user_data; void *surrounding_text_updated_user_data; @@ -179,6 +181,7 @@ typedef struct void *displayed_candidate_number_chaned_user_data; void *candidate_item_long_pressed_user_data; void *input_hint_set_user_data; + void *position_align_set_user_data; } ime_event_callback_s; typedef struct { @@ -657,6 +660,13 @@ void CCoreEventCallback::on_longpress_candidate(sclu32 index) } } +void CCoreEventCallback::on_set_position_align(sclu32 x, sclu32 y, sclu32 align) +{ + if (g_event_callback.position_align_set) { + g_event_callback.position_align_set(x, y, static_cast(align), g_event_callback.position_align_set_user_data); + } +} + void ime_privilege_cache_init() { g_permission_allowed = false; @@ -1155,6 +1165,37 @@ EXPORT_API int ime_event_unset_input_hint_set_cb(void) return IME_ERROR_NONE; } +EXPORT_API int ime_event_set_position_align_set_cb(ime_position_align_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.position_align_set = callback_func; + g_event_callback.position_align_set_user_data = user_data; + + return IME_ERROR_NONE; +} + +EXPORT_API int ime_event_unset_position_align_set_cb(void) +{ + ime_error_e retVal = IME_ERROR_NONE; + + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_event_callback.position_align_set = NULL; + g_event_callback.position_align_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) { @@ -3055,3 +3096,27 @@ EXPORT_API int ime_set_candidate_visibility_state(bool visible) return IME_ERROR_NONE; //LCOV_EXCL_STOP } + +EXPORT_API int ime_move_resize_floating_window(int x, int y, int w, int h) +{ + ime_error_e retVal = IME_ERROR_NONE; + + if (x < 0 || y < 0 || w < 0 || h < 0) { + LOGW("IME_ERROR_INVALID_PARAMETER"); + return IME_ERROR_INVALID_PARAMETER; + } + + if (!g_running) { + LOGW("IME_ERROR_NOT_RUNNING"); + return IME_ERROR_NOT_RUNNING; + } + + //LCOV_EXCL_START + retVal = _check_privilege(); + if (retVal != IME_ERROR_NONE) return retVal; + + g_core.move_resize_floating_window(x, y, w, h); + + return IME_ERROR_NONE; + //LCOV_EXCL_STOP +}