Support recent IME geometry 23/103923/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Sat, 10 Dec 2016 13:53:53 +0000 (22:53 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Sat, 10 Dec 2016 13:54:13 +0000 (22:54 +0900)
Change-Id: I111473f6fcabf3e0e8bfe83c37d4ea85856ce0af
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/e_mod_input_panel.c
src/e_mod_main.c

index ebdd237..5b5ec98 100644 (file)
@@ -2,6 +2,12 @@
 #include "e.h"
 #include "e_mod_main.h"
 #include <input-method-server-protocol.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "WL_TEXTINPUT"
 
 typedef struct _E_Input_Panel E_Input_Panel;
 typedef struct _E_Input_Panel_Surface E_Input_Panel_Surface;
@@ -642,6 +648,7 @@ e_input_panel_client_geometry_get(E_Client *ec, int *x, int *y, int *w, int *h)
 {
     E_Input_Panel_Surface *ips;
     Eina_List *l;
+    int angle = 0;
 
     if (!g_input_panel) return EINA_FALSE;
     if (!x || !y || !w || !h) return EINA_FALSE;
@@ -649,11 +656,29 @@ e_input_panel_client_geometry_get(E_Client *ec, int *x, int *y, int *w, int *h)
     EINA_LIST_FOREACH(g_input_panel->surfaces, l, ips)
     {
         if (!ips->ec) continue;
-        if (ips->ec == ec || !ec) {
-            *x = ips->ec->x;
-            *y = ips->ec->y;
-            *w = ips->ec->w;
-            *h = ips->ec->h;
+        if (ips->ec == ec || !ec)
+          {
+            angle = ips->ec->e.state.rot.ang.next < 0 ?
+                    ips->ec->e.state.rot.ang.curr :
+                    ips->ec->e.state.rot.ang.next;
+
+            switch (angle)
+              {
+               case 90:
+               case 270:
+                  *x = ips->ec->y;
+                  *y = ips->ec->x;
+                  *w = ips->ec->h;
+                  *h = ips->ec->w;
+                  break;
+               default:
+                  *x = ips->ec->x;
+                  *y = ips->ec->y;
+                  *w = ips->ec->w;
+                  *h = ips->ec->h;
+                  break;
+              }
+
             return EINA_TRUE;
         }
     }
index 87caa07..a8a70e1 100644 (file)
@@ -131,6 +131,40 @@ static struct _E_Input_Method_Keymap_Info g_keymap_info[] = {
 static void _e_text_input_deactivate(E_Text_Input *text_input, E_Input_Method *input_method);
 static Eina_Bool _e_text_input_method_create_context(struct wl_client *client, E_Input_Method *input_method, E_Text_Input *text_input);
 
+static void
+_e_text_input_send_input_panel_geometry(struct wl_resource *resource, int x, int y, int w, int h)
+{
+   int angle = 0;
+   char geometry[128];
+
+   if (client_surface_ec)
+     {
+        angle = client_surface_ec->e.state.rot.ang.next < 0 ?
+                client_surface_ec->e.state.rot.ang.curr :
+                client_surface_ec->e.state.rot.ang.next;
+
+        LOGD("curr : %d, next : %d, angle : %d\n", client_surface_ec->e.state.rot.ang.curr,
+           client_surface_ec->e.state.rot.ang.next, angle);
+     }
+
+   snprintf(geometry, sizeof(geometry), "%d,%d,%d,%d", x, y, w, h);
+
+   switch(angle)
+     {
+      case 90:
+      case 270:
+         vconf_set_str(VCONFKEY_ISF_IME_RECENT_LAND_GEOMETRY, geometry);
+         break;
+      default:
+         vconf_set_str(VCONFKEY_ISF_IME_RECENT_PORT_GEOMETRY, geometry);
+         break;
+     }
+
+   LOGD("angle : %d, x : %d, y : %d, w : %d, h : %d\n", angle, x, y, w, h);
+
+   wl_text_input_send_input_panel_geometry(resource, x, y, w, h);
+}
+
 static Eina_Bool
 _will_hide_timer_handler(void *data)
 {
@@ -1213,7 +1247,7 @@ _e_text_input_cb_input_panel_show(struct wl_client *client, struct wl_resource *
      {
         int x = 0, y = 0, w = 0, h = 0;
         if (e_input_panel_client_geometry_get(NULL, &x, &y, &w, &h))
-          wl_text_input_send_input_panel_geometry(text_input->resource, x, y, w, h);
+          _e_text_input_send_input_panel_geometry(text_input->resource, x, y, w, h);
 
         wl_text_input_send_input_panel_state(text_input->resource, WL_TEXT_INPUT_INPUT_PANEL_STATE_SHOW);
      }
@@ -1908,6 +1942,7 @@ _e_text_input_method_context_cb_client_resize(void *data EINA_UNUSED, int type E
    E_Event_Client *ev;
    E_Client *ec;
    Eina_Bool found;
+   int x = 0, y = 0, w = 0, h = 0;
 
    ev = (E_Event_Client *)event;
    EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON);
@@ -1920,7 +1955,10 @@ _e_text_input_method_context_cb_client_resize(void *data EINA_UNUSED, int type E
    if ((ec->w < 1) && (ec->h < 1)) return ECORE_CALLBACK_PASS_ON;
 
    if (g_text_input && g_text_input->resource)
-     wl_text_input_send_input_panel_geometry(g_text_input->resource, ec->x, ec->y, ec->w, ec->h);
+     {
+        if (e_input_panel_client_geometry_get(NULL, &x, &y, &w, &h))
+          _e_text_input_send_input_panel_geometry(g_text_input->resource, x, y, w, h);
+     }
 
    return ECORE_CALLBACK_PASS_ON;
 }