Add isf_control_get_recent_ime_geometry_with_rotation_angle () API 58/50958/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 2 Nov 2015 14:00:25 +0000 (23:00 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 4 Nov 2015 02:48:28 +0000 (11:48 +0900)
isf_control_get_recent_ime_geometry () returns wrong value when it is called in rotation callback
due to the wrong window rotation angle of window property.

Change-Id: I71808a4e7aa246f49a242e0841ea2f8f53070c4d

ism/demos/isf_imcontrol_efl.cpp
ism/extras/efl_panel/isf_panel_efl.cpp
ism/src/isf_control.cpp
ism/src/isf_control.h
ism/src/isf_imcontrol_client.cpp
ism/src/isf_imcontrol_client.h
ism/src/scim_panel_agent.cpp
ism/src/scim_panel_agent.h

index ebe2838..7fc44c5 100644 (file)
@@ -27,6 +27,7 @@
 
 static Ecore_IMF_Context *imf_context = NULL;
 static Elm_Genlist_Item_Class itci;
+static Evas_Object *win = NULL;
 
 static void test_input_panel_geometry_get (void *data, Evas_Object *obj, void *event_info);
 static void test_input_panel_show (void *data, Evas_Object *obj, void *event_info);
@@ -297,11 +298,20 @@ static void test_get_recent_ise_geometry_get (void *data, Evas_Object *obj, void
 {
     int x, y, w, h;
     if (isf_control_get_recent_ime_geometry (&x, &y, &w, &h) == 0) {
-        LOGD ("x=%d, y=%d, width=%d, height=%d\n", x, y, w, h);
+        LOGD ("x : %d, y : %d, width : %d, height : %d\n", x, y, w, h);
     }
     else {
         LOGW ("Failed to get recent ime geometry\n");
     }
+
+    int angle = elm_win_rotation_get (win);
+
+    if (isf_control_get_recent_ime_geometry_with_rotation_angle (angle, &x, &y, &w, &h) == 0) {
+        LOGD ("angle : %d, x : %d, y : %d, width : %d, height : %d\n", angle, x, y, w, h);
+    }
+    else {
+        LOGW ("Failed to get recent ime geometry with rotation angle\n");
+    }
 }
 
 static char *gli_label_get (void *data, Evas_Object *obj, const char *part)
@@ -310,7 +320,7 @@ static char *gli_label_get (void *data, Evas_Object *obj, const char *part)
     return strdup (imcontrol_menu_its[j].name);
 }
 
-static void test_api (void *data, Evas_Object *obj, void *event_info)
+static void _selected_cb (void *data, Evas_Object *obj, void *event_info)
 {
     int j = (int)(reinterpret_cast<long>(data));
     Elm_Object_Item *it = (Elm_Object_Item *)event_info;
@@ -347,14 +357,41 @@ static Evas_Object *_create_imcontrolapi_list (Evas_Object *parent)
 
     while (imcontrol_menu_its[i].name != NULL) {
         elm_genlist_item_append (gl, &itci,
-                                 (void *)i/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, test_api/* func */,
-                                 (void *)i/* func data */);
+                                 (void *)i/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, _selected_cb /* func */,
+                                 (void *)i /* func data */);
         i++;
     }
 
     return gl;
 }
 
+static void
+win_rotation_changed_cb (void *data, Evas_Object *obj, void *event_info)
+{
+    struct appdata *ad = (struct appdata *)data;
+    int x, y, w, h;
+    if (ad == NULL || ad->win_main == NULL)
+        return;
+
+    int angle = elm_win_rotation_get (ad->win_main);
+
+    LOGD ("rotate. angle : %d\n", angle);
+
+    if (isf_control_get_recent_ime_geometry (&x, &y, &w, &h) == 0) {
+        LOGD ("x : %d, y : %d, width : %d, height : %d\n", x, y, w, h);
+    }
+    else {
+        LOGW ("Failed to get recent ime geometry\n");
+    }
+
+    if (isf_control_get_recent_ime_geometry_with_rotation_angle (angle, &x, &y, &w, &h) == 0) {
+        LOGD ("angle : %d, x : %d, y : %d, width : %d, height : %d\n", angle, x, y, w, h);
+    }
+    else {
+        LOGW ("Failed to get recent ime geometry with rotation angle\n");
+    }
+}
+
 void imcontrolapi_bt (void *data, Evas_Object *obj, void *event_info)
 {
     ecore_imf_init ();
@@ -373,9 +410,14 @@ void imcontrolapi_bt (void *data, Evas_Object *obj, void *event_info)
 
     gl = _create_imcontrolapi_list (ad->naviframe);
 
+    win = ad->win_main;
+
     Evas_Object *back_btn = create_naviframe_back_button (ad);
     Elm_Object_Item *navi_it = elm_naviframe_item_push (ad->naviframe, _("IM Control"), back_btn, NULL, gl, NULL);
     elm_naviframe_item_pop_cb_set (navi_it, _nf_back_event_cb, ad);
+
+    evas_object_smart_callback_add (ad->win_main, "rotation,changed", win_rotation_changed_cb, ad);
+    evas_object_smart_callback_add (ad->win_main, "wm,rotation,changed", win_rotation_changed_cb, ad);
 }
 
 /*
index 3be25d6..e2c8dfe 100644 (file)
@@ -226,7 +226,7 @@ static void       slot_get_ise_language                (char *name, std::vector<
 static bool       slot_get_ise_info                    (const String &uuid, ISE_INFO &info);
 static void       slot_get_candidate_geometry          (struct rectinfo &info);
 static void       slot_get_input_panel_geometry        (struct rectinfo &info);
-static void       slot_get_recent_ise_geometry         (struct rectinfo &info);
+static void       slot_get_recent_ise_geometry         (int angle, struct rectinfo &info);
 static void       slot_set_keyboard_ise                (const String &uuid);
 static void       slot_get_keyboard_ise                (String &ise_name, String &ise_uuid);
 static void       slot_accept_connection               (int fd);
@@ -5106,14 +5106,18 @@ static void slot_get_input_panel_geometry (struct rectinfo &info)
 /**
  * @brief Get the recent input panel geometry slot function for PanelAgent.
  *
+ * @param angle the rotation angle of application window.
  * @param info The data is used to store input panel position and size.
  */
-static void slot_get_recent_ise_geometry (struct rectinfo &info)
+static void slot_get_recent_ise_geometry (int angle, struct rectinfo &info)
 {
     LOGD ("slot_get_recent_ise_geometry\n");
 
     /* If we have geometry reported by ISE, use the geometry information */
-    int angle = efl_get_app_window_angle ();
+    if (angle < 0) {
+        angle = efl_get_app_window_angle ();
+    }
+
     if (angle == 0 || angle == 180) {
         if (_portrait_recent_ise_geometry.valid) {
             info = _portrait_recent_ise_geometry.geometry;
index 5221b8f..769bb3b 100644 (file)
@@ -457,16 +457,24 @@ EXAPI int isf_control_is_ime_enabled (const char *appid, bool *enabled)
 
 EXAPI int isf_control_get_recent_ime_geometry (int *x, int *y, int *w, int *h)
 {
+    return isf_control_get_recent_ime_geometry_with_rotation_angle (-1, x, y, w, h);
+}
+
+EXAPI int isf_control_get_recent_ime_geometry_with_rotation_angle (int angle, int * x,int * y,int * w,int * h)
+{
     int ime_x = -1, ime_y = -1, ime_w = -1, ime_h = -1;
 
     IMControlClient imcontrol_client;
     int ret = 0;
 
+    if ((angle != -1) && (angle % 90 != 0))
+        return -1;
+
     if (!imcontrol_client.open_connection ())
         return -1;
 
     imcontrol_client.prepare ();
-    if (!imcontrol_client.get_recent_ime_geometry (&ime_x, &ime_y, &ime_w, &ime_h))
+    if (!imcontrol_client.get_recent_ime_geometry (&ime_x, &ime_y, &ime_w, &ime_h, angle))
         ret = -1;
 
     imcontrol_client.close_connection ();
index a9835c6..988efab 100644 (file)
@@ -302,6 +302,21 @@ EXAPI int isf_control_is_ime_enabled (const char *appid, bool *enabled);
  */
 EXAPI int isf_control_get_recent_ime_geometry (int *x, int *y, int *w, int *h);
 
+/**
+ * @brief Get the recent geometry of S/W keyboard with the rotation mode
+ *
+ * @remarks If the keyboard has never been shown, this function will return -1 since the framework can't know its size.
+ * The caller application needs to assume the default height.
+ *
+ * @param[in] angle the rotation angle of application window.
+ * @param[out] x Pointer to an integer in which to store the X coordinate of the IME that appeared recently.
+ * @param[out] y Pointer to an integer in which to store the Y coordinate of the IME that appeared recently.
+ * @param[out] w Pointer to an integer in which to store the width of the IME that appeared recently.
+ * @param[out] h Pointer to an integer in which to store the height of the IME that appeared recently.
+ *
+ * @return 0 if successfully, otherwise return -1;
+ */
+EXAPI int isf_control_get_recent_ime_geometry_with_rotation_angle (int angle, int *x, int *y, int *w, int *h);
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index f10eabc..ab59827 100644 (file)
@@ -524,12 +524,13 @@ public:
         }
     }
 
-    bool get_recent_ime_geometry (int *x, int *y, int *w, int *h)
+    bool get_recent_ime_geometry (int *x, int *y, int *w, int *h, int angle)
     {
         int    cmd;
         uint32 tmp_x, tmp_y, tmp_w, tmp_h;
 
         m_trans.put_command (ISM_TRANS_CMD_GET_RECENT_ISE_GEOMETRY);
+        m_trans.put_data (angle);
         m_trans.write_to_socket (m_socket_imclient2panel);
         if (!m_trans.read_from_socket (m_socket_imclient2panel, m_socket_timeout)) {
             std::cerr << __func__ << " read_from_socket() may be timeout \n";
@@ -677,9 +678,9 @@ bool IMControlClient::is_helper_ise_enabled (const char* appid, int &enabled)
     return m_impl->is_helper_ise_enabled (appid, enabled);
 }
 
-bool IMControlClient::get_recent_ime_geometry (int *x, int *y, int *w, int *h)
+bool IMControlClient::get_recent_ime_geometry (int *x, int *y, int *w, int *h, int angle)
 {
-    return m_impl->get_recent_ime_geometry (x, y, w, h);
+    return m_impl->get_recent_ime_geometry (x, y, w, h, angle);
 }
 };
 
index 92b2c2b..75fe187 100644 (file)
@@ -62,7 +62,7 @@ public:
     bool show_helper_ise_list (void);
     bool show_helper_ise_selector (void);
     bool is_helper_ise_enabled (const char* appid, int &enabled);
-    bool get_recent_ime_geometry (int *x, int *y, int *w, int *h);
+    bool get_recent_ime_geometry (int *x, int *y, int *w, int *h, int angle = -1);
 };
 
 }
index bf77157..73df242 100644 (file)
@@ -171,6 +171,9 @@ typedef Signal1<void, struct rectinfo &>
 typedef Signal6<bool, String, String &, String &, int &, int &, String &>
         PanelAgentSignalBoolString4int2;
 
+typedef Signal2<void, int, struct rectinfo &>
+        PanelAgentSignalIntRect;
+
 enum ClientType {
     UNKNOWN_CLIENT,
     FRONTEND_CLIENT,
@@ -392,7 +395,7 @@ class PanelAgent::PanelAgentImpl
     PanelAgentSignalVoid                m_signal_candidate_will_hide_ack;
     PanelAgentSignalInt2                m_signal_get_ise_state;
 
-    PanelAgentSignalRect                m_signal_get_recent_ise_geometry;
+    PanelAgentSignalIntRect             m_signal_get_recent_ise_geometry;
 public:
     PanelAgentImpl ()
         : m_should_exit (false),
@@ -3114,19 +3117,28 @@ public:
     {
         SCIM_DEBUG_MAIN(4) << __func__ << "\n";
 
-        struct rectinfo info = {0, 0, 0, 0};
-        m_signal_get_recent_ise_geometry (info);
+        uint32 angle;
 
         Transaction trans;
         Socket client_socket (client_id);
 
         trans.clear ();
         trans.put_command (SCIM_TRANS_CMD_REPLY);
-        trans.put_command (SCIM_TRANS_CMD_OK);
-        trans.put_data (info.pos_x);
-        trans.put_data (info.pos_y);
-        trans.put_data (info.width);
-        trans.put_data (info.height);
+
+        if (m_recv_trans.get_data (angle)) {
+            struct rectinfo info = {0, 0, 0, 0};
+            m_signal_get_recent_ise_geometry (angle, info);
+
+            trans.put_command (SCIM_TRANS_CMD_OK);
+            trans.put_data (info.pos_x);
+            trans.put_data (info.pos_y);
+            trans.put_data (info.width);
+            trans.put_data (info.height);
+        }
+        else {
+            trans.put_command (SCIM_TRANS_CMD_FAIL);
+        }
+
         trans.write_to_socket (client_socket);
     }
 
@@ -3485,7 +3497,7 @@ public:
         return m_signal_will_hide_ack.connect (slot);
     }
 
-    Connection signal_connect_set_keyboard_mode (PanelAgentSlotInt                *slot)
+    Connection signal_connect_set_keyboard_mode          (PanelAgentSlotInt                *slot)
     {
         return m_signal_set_keyboard_mode.connect (slot);
     }
@@ -3500,7 +3512,7 @@ public:
         return m_signal_get_ise_state.connect (slot);
     }
 
-    Connection signal_connect_get_recent_ise_geometry    (PanelAgentSlotRect                *slot)
+    Connection signal_connect_get_recent_ise_geometry    (PanelAgentSlotIntRect                *slot)
     {
         return m_signal_get_recent_ise_geometry.connect (slot);
     }
@@ -6704,7 +6716,7 @@ PanelAgent::signal_connect_remove_helper              (PanelAgentSlotInt
 }
 
 Connection
-PanelAgent::signal_connect_set_active_ise_by_uuid     (PanelAgentSlotStringBool              *slot)
+PanelAgent::signal_connect_set_active_ise_by_uuid     (PanelAgentSlotStringBool          *slot)
 {
     return m_impl->signal_connect_set_active_ise_by_uuid (slot);
 }
@@ -6746,19 +6758,19 @@ PanelAgent::signal_connect_get_ise_list               (PanelAgentSlotBoolStringV
 }
 
 Connection
-PanelAgent::signal_connect_get_all_helper_ise_info    (PanelAgentSlotBoolHelperInfo    *slot)
+PanelAgent::signal_connect_get_all_helper_ise_info    (PanelAgentSlotBoolHelperInfo      *slot)
 {
     return m_impl->signal_connect_get_all_helper_ise_info (slot);
 }
 
 Connection
-PanelAgent::signal_connect_set_has_option_helper_ise_info (PanelAgentSlotStringBool    *slot)
+PanelAgent::signal_connect_set_has_option_helper_ise_info (PanelAgentSlotStringBool      *slot)
 {
     return m_impl->signal_connect_set_has_option_helper_ise_info (slot);
 }
 
 Connection
-PanelAgent::signal_connect_set_enable_helper_ise_info      (PanelAgentSlotStringBool    *slot)
+PanelAgent::signal_connect_set_enable_helper_ise_info      (PanelAgentSlotStringBool     *slot)
 {
     return m_impl->signal_connect_set_enable_helper_ise_info (slot);
 }
@@ -6902,7 +6914,7 @@ PanelAgent::signal_connect_will_hide_ack              (PanelAgentSlotVoid
 }
 
 Connection
-PanelAgent::signal_connect_set_keyboard_mode (PanelAgentSlotInt                *slot)
+PanelAgent::signal_connect_set_keyboard_mode          (PanelAgentSlotInt                 *slot)
 {
     return m_impl->signal_connect_set_keyboard_mode (slot);
 }
@@ -6920,7 +6932,7 @@ PanelAgent::signal_connect_get_ise_state              (PanelAgentSlotInt2
 }
 
 Connection
-PanelAgent::signal_connect_get_recent_ise_geometry    (PanelAgentSlotRect                *slot)
+PanelAgent::signal_connect_get_recent_ise_geometry    (PanelAgentSlotIntRect             *slot)
 {
     return m_impl->signal_connect_get_recent_ise_geometry (slot);
 }
index ed765b4..517011a 100644 (file)
@@ -175,6 +175,9 @@ typedef Slot2<void, const String &, bool>
 typedef Slot6<bool, String, String &, String &, int &, int &, String &>
         PanelAgentSlotBoolString4int2;
 
+typedef Slot2<void, int, struct rectinfo &>
+        PanelAgentSlotIntRect;
+
 typedef struct DefaultIse
 {
     TOOLBAR_MODE_T type;
@@ -1205,7 +1208,7 @@ public:
      *
      * slot prototype: void set_keyboard_mode (void);
      */
-    Connection signal_connect_set_keyboard_mode (PanelAgentSlotInt                *slot);
+    Connection signal_connect_set_keyboard_mode          (PanelAgentSlotInt                 *slot);
 
     /**
      * @brief Signal: Notifies the client finished handling WILL_HIDE event for candidate
@@ -1224,9 +1227,9 @@ public:
     /**
      * @brief Signal: Get the recent input panel geometry information.
      *
-     * slot prototype: void get_recent_ise_geometry (rectinfo &info);
+     * slot prototype: void get_recent_ise_geometry (int angle, rectinfo &info);
      */
-    Connection signal_connect_get_recent_ise_geometry    (PanelAgentSlotRect                *slot);
+    Connection signal_connect_get_recent_ise_geometry    (PanelAgentSlotIntRect             *slot);
 };
 
 /**  @} */