Add new APIs to move and resize the floating input panel 70/310870/1
authorInhong Han <inhong1.han@samsung.com>
Wed, 8 May 2024 08:15:14 +0000 (17:15 +0900)
committerInhong Han <inhong1.han@samsung.com>
Thu, 9 May 2024 06:54:02 +0000 (15:54 +0900)
Change-Id: Ia72b0998e80d93cd74de1e674c686376ca3efa87

inputmethod/include/inputmethod_internal.h
inputmethod/src/inputmethod.cpp

index 4a6b007..8f23d0e 100644 (file)
@@ -270,6 +270,29 @@ typedef void (*ime_displayed_candidate_number_chaned_cb)(uint32_t page_num, void
 typedef void (*ime_candidate_item_long_pressed_cb)(uint32_t index, void *user_data);
 
 /**
+ * @brief Called when an associated text input UI control sets the position align of the input panel.
+ *
+ * @since_tizen 8.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 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 Sets @c ime_caps_mode_changed_cb() event callback function.
  *
  * @since_tizen 3.0
@@ -1131,6 +1154,85 @@ int ime_send_key_event_processing_result(scim::KeyEvent &key, uint32_t serial, b
  */
 int ime_set_native_window_size(Ecore_Wl2_Window *window, int portrait_width, int portrait_height, int landscape_width, int landscape_height);
 
+/**
+ * @brief Sets @c position_align_set event callback function.
+ *
+ * @since_tizen 8.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 @c position_align_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
+ *
+ * @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 @c position_align_set event callback function.
+ *
+ * @since_tizen 8.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 8.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);
+
 #ifdef __cplusplus
 }
 #endif
index ef4ac26..1d16013 100644 (file)
@@ -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<Ecore_IMF_Input_Panel_Align>(align), g_event_callback.position_align_set_user_data);
+    }
+}
+
 void ime_privilege_cache_init()
 {
     g_permission_allowed = false;
@@ -1156,6 +1166,37 @@ EXPORT_API int ime_event_unset_input_hint_set_cb(void)
 }
 
 //LCOV_EXCL_START
+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;
+}
+
 EXPORT_API int ime_event_set_caps_mode_changed_cb(ime_caps_mode_changed_cb callback_func, void *user_data)
 {
     ime_error_e retVal = IME_ERROR_NONE;
@@ -3057,3 +3098,27 @@ EXPORT_API int ime_set_candidate_visibility_state(bool visible)
     return IME_ERROR_NONE;
     //LCOV_EXCL_STOP
 }
+
+//LCOV_EXCL_START
+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;
+    }
+
+    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
\ No newline at end of file