add proper event handlers for detecting input panel window show/hide 66/54866/3
authorGwanglim Lee <gl77.lee@samsung.com>
Fri, 18 Dec 2015 09:18:31 +0000 (18:18 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 7 Jan 2016 03:03:52 +0000 (12:03 +0900)
Change-Id: I164b0566f707b49c43c285d10f056e84aa450c20

src/e_mod_input_panel.c
src/e_mod_main.c [changed mode: 0644->0755]
src/e_mod_main.h

index fb0d3e4..7b22a61 100644 (file)
@@ -460,6 +460,25 @@ e_input_panel_visibility_change(Eina_Bool visible)
 }
 
 Eina_Bool
+e_input_panel_client_find(E_Client *ec)
+{
+   E_Input_Panel_Surface *ips;
+   Eina_List *l;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
+
+   if (!g_input_panel) return EINA_FALSE;
+
+   EINA_LIST_FOREACH(g_input_panel->surfaces, l, ips)
+     {
+        if (!ips->ec) continue;
+        if (ips->ec == ec) return EINA_TRUE;
+     }
+
+   return EINA_FALSE;
+}
+
+Eina_Bool
 e_input_panel_init(E_Comp_Data *cdata)
 {
    if (!cdata) return EINA_FALSE;
old mode 100644 (file)
new mode 100755 (executable)
index 8a9ea2e..6642593
@@ -5,6 +5,8 @@
 #include <input-method-server-protocol.h>
 #include "Eeze.h"
 
+static Eina_Bool _e_text_input_method_context_cb_client_resize(void *data EINA_UNUSED, int type, void *event);
+
 typedef struct _E_Text_Input E_Text_Input;
 typedef struct _E_Text_Input_Mgr E_Text_Input_Mgr;
 typedef struct _E_Input_Method E_Input_Method;
@@ -66,10 +68,12 @@ struct _E_Mod_Text_Input_Shutdown_Cb
 };
 
 static E_Input_Method *g_input_method = NULL;
+static E_Text_Input *g_text_input = NULL;
 static Eina_List *shutdown_list = NULL;
 static Eina_Bool g_disable_show_panel = EINA_FALSE;
 static Eeze_Udev_Watch *eeze_udev_watch_hander = NULL;
 static Ecore_Event_Handler *ecore_key_down_handler = NULL;
+static Eina_List *handlers = NULL;
 
 static void
 _e_text_input_method_context_keyboard_grab_keyboard_state_update(E_Input_Method_Context *context, uint32_t keycode, Eina_Bool pressed)
@@ -660,6 +664,7 @@ _e_text_input_cb_activate(struct wl_client *client, struct wl_resource *resource
    EINA_SAFETY_ON_NULL_GOTO(g_input_method->resource, err);
 
    text_input = wl_resource_get_user_data(resource);
+   g_text_input = text_input;
 
    // FIXME: should get input_method object from seat.
    input_method = wl_resource_get_user_data(g_input_method->resource);
@@ -729,6 +734,7 @@ err:
 static void
 _e_text_input_cb_deactivate(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *seat)
 {
+   g_text_input = NULL;
    E_Text_Input *text_input = wl_resource_get_user_data(resource);
    E_Comp_Data *cdata = wl_resource_get_user_data(seat);
    E_Input_Method *input_method = NULL;
@@ -1293,6 +1299,29 @@ _e_mod_eeze_udev_watch_cb(const char *text, Eeze_Udev_Event event, void *data, E
      g_disable_show_panel = EINA_FALSE;
 }
 
+static Eina_Bool
+_e_text_input_method_context_cb_client_resize(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
+{
+   E_Event_Client *ev;
+   E_Client *ec;
+   Eina_Bool found;
+
+   ev = (E_Event_Client *)event;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON);
+
+   ec = ev->ec;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_PASS_ON);
+
+   found = e_input_panel_client_find(ec);
+   if (!found) return ECORE_CALLBACK_PASS_ON;
+   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);
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
 EAPI void *
 e_modapi_init(E_Module *m)
 {
@@ -1312,6 +1341,8 @@ e_modapi_init(E_Module *m)
    if (!_e_text_input_manager_create(cdata))
      goto err;
 
+   E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_RESIZE, _e_text_input_method_context_cb_client_resize, NULL);
+
    eeze_udev_watch_hander = eeze_udev_watch_add(EEZE_UDEV_TYPE_KEYBOARD,
                                                 EEZE_UDEV_EVENT_REMOVE,
                                                 _e_mod_eeze_udev_watch_cb,
@@ -1328,6 +1359,8 @@ err:
 EAPI int
 e_modapi_shutdown(E_Module *m EINA_UNUSED)
 {
+   E_FREE_LIST(handlers, ecore_event_handler_del);
+
    if (eeze_udev_watch_hander)
      {
         eeze_udev_watch_del(eeze_udev_watch_hander);
index e8e963f..ad7eaaa 100644 (file)
@@ -4,5 +4,6 @@
 Eina_Bool   e_input_panel_init(E_Comp_Data *cdata);
 void        e_input_panel_shutdown(E_Comp_Data *cdata);
 void        e_input_panel_visibility_change(Eina_Bool visible);
+Eina_Bool   e_input_panel_client_find(E_Client *ec);
 
 #endif