Support to switch between H/W and S/W keyboard mode 79/68879/5
authorJihoon Kim <jihoon48.kim@samsung.com>
Tue, 10 May 2016 07:25:53 +0000 (16:25 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 23 May 2016 04:54:53 +0000 (21:54 -0700)
Change-Id: Iebfd0a1c2918267f23fe49534586cc08662cb48e

configure.ac
packaging/e-mod-tizen-wl-textinput.spec
src/Makefile.am
src/e_mod_main.c

index 34657b1d29d6681dcffdc3bdc56a490075fa34bd..4934f5a5b5ebd962244fc9db70968033ca31da36 100644 (file)
@@ -30,6 +30,7 @@ AC_PROG_LIBTOOL
 PKG_CHECK_MODULES(WAYLAND, [wayland-server, text-server, input-method-server])
 PKG_CHECK_MODULES(ENLIGHTENMENT, [enlightenment])
 PKG_CHECK_MODULES(EEZE, [eeze])
+PKG_CHECK_MODULES(VCONF, [vconf])
 
 AC_SUBST(ENLIGHTENMENT_CFLAGS)
 AC_SUBST(ENLIGHTENMENT_LIBS)
index 93c4232602ba664492ccef3b4db9caf3aaf6a093..38db413c74945f110b6c383d74941293e0f0c707 100644 (file)
@@ -11,6 +11,7 @@ BuildRequires: pkgconfig(text-server)
 BuildRequires: pkgconfig(input-method-server)
 BuildRequires: pkgconfig(enlightenment)
 BuildRequires: pkgconfig(eeze)
+BuildRequires: pkgconfig(vconf)
 %if !%{with wayland}
 ExclusiveArch:
 %endif
index 3415ad10ff7c530d8a020c50cdae2e3ca221bf32..8d8b5e8fd7a5423f0209348869467dae98a74543 100644 (file)
@@ -9,6 +9,6 @@ pkg_LTLIBRARIES        = module.la
 module_la_SOURCES      = e_mod_main.c \
                          e_mod_input_panel.c
 module_la_LIBADD       =
-module_la_CFLAGS       = @WAYLAND_CFLAGS@ @ENLIGHTENMENT_CFLAGS@ @EEZE_CFLAGS@ -DHAVE_WAYLAND_ONLY -DHAVE_WAYLAND
-module_la_LDFLAGS      = -module -avoid-version @WAYLAND_LIBS@ @ENLIGHTENMENT_LIBS@ @EEZE_LIBS@
+module_la_CFLAGS       = @WAYLAND_CFLAGS@ @ENLIGHTENMENT_CFLAGS@ @EEZE_CFLAGS@ @VCONF_CFLAGS@ -DHAVE_WAYLAND_ONLY -DHAVE_WAYLAND
+module_la_LDFLAGS      = -module -avoid-version @WAYLAND_LIBS@ @ENLIGHTENMENT_LIBS@ @EEZE_LIBS@ @VCONF_LIBS@
 module_la_DEPENDENCIES = $(top_builddir)/config.h
index 177faace5c8d81987b829b8c869026d2b09759a1..2abdccb0dbd8a06cbb935c441efcfd85bcae8ceb 100644 (file)
@@ -3,6 +3,8 @@
 #include "e_mod_main.h"
 #include <text-server-protocol.h>
 #include <input-method-server-protocol.h>
+#include <vconf.h>
+#include <vconf-keys.h>
 #include "Eeze.h"
 
 static Eina_Bool _e_text_input_method_context_cb_client_resize(void *data EINA_UNUSED, int type, void *event);
@@ -67,6 +69,7 @@ struct _E_Mod_Text_Input_Shutdown_Cb
 
 static E_Input_Method *g_input_method = NULL;
 static E_Text_Input *g_text_input = NULL;
+static struct wl_client *g_client = 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;
@@ -74,6 +77,58 @@ static Ecore_Event_Handler *ecore_key_down_handler = NULL;
 static Eina_List *handlers = NULL;
 static uint32_t g_text_input_count = 1;
 
+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
+_input_panel_hide(struct wl_client *client, struct wl_resource *resource)
+{
+   E_Text_Input *text_input = wl_resource_get_user_data(resource);
+   E_Input_Method *input_method = NULL;
+   Eina_Bool _context_created = EINA_FALSE;
+
+   if (!text_input)
+     {
+        wl_resource_post_error(resource,
+                               WL_DISPLAY_ERROR_INVALID_OBJECT,
+                               "No Text Input For Resource");
+        return;
+     }
+
+   text_input->input_panel_visibile = EINA_FALSE;
+
+   if (text_input->resource)
+     wl_text_input_send_input_panel_state(text_input->resource,
+                                          WL_TEXT_INPUT_INPUT_PANEL_STATE_HIDE);
+
+   e_input_panel_visibility_change(EINA_FALSE);
+
+   if (g_input_method && g_input_method->resource)
+     input_method = wl_resource_get_user_data(g_input_method->resource);
+
+   /*
+      If input_method->context is already deleted, create context struct again to send input_panel_hide event to Input Method(IME) correctly.
+      Because input_panel_hide event can be called after focus_out(deactivate) by application.
+      And Input Method(IME) should know the state of their own input_panel to manage their resource when the input_panel is hidden.
+    */
+   if (input_method && (!input_method->context || !input_method->context->resource))
+     _context_created = _e_text_input_method_create_context(client, input_method, text_input);
+
+   if (input_method && input_method->resource && input_method->context && input_method->context->resource)
+     wl_input_method_send_hide_input_panel(input_method->resource, input_method->context->resource);
+
+   if (_context_created)
+     _e_text_input_deactivate(text_input, input_method);
+}
+
+static void
+_keyboard_mode_changed_cb(keynode_t *key, void* data)
+{
+    int val = 0;
+    if (vconf_get_bool(VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, &val) == 0 && val == 0)
+      g_disable_show_panel = EINA_FALSE;
+}
+
 static void
 _e_text_input_method_context_keyboard_grab_keyboard_state_update(E_Input_Method_Context *context, uint32_t keycode, Eina_Bool pressed)
 {
@@ -402,6 +457,7 @@ _e_text_input_method_context_cb_keyboard_grab(struct wl_client *client, struct w
                                "No Input Method Context For Resource");
         return;
      }
+
    keyboard = wl_resource_create(client, &wl_keyboard_interface, 1, id);
    if (!keyboard)
      {
@@ -625,7 +681,7 @@ static Eina_Bool is_number_key(const char *str)
       }
     else
       return EINA_TRUE;
- }
+}
 
 static Eina_Bool
 _e_mod_ecore_key_down_cb(void *data, int type, void *event)
@@ -651,8 +707,10 @@ _e_mod_ecore_key_down_cb(void *data, int type, void *event)
        is_number_key(ev->string))
      return ECORE_CALLBACK_PASS_ON;
 
+   if (g_text_input && g_text_input->resource && g_client)
+     _input_panel_hide(g_client, g_text_input->resource);
+
    g_disable_show_panel = EINA_TRUE;
-   e_input_panel_visibility_change(EINA_FALSE);
 
    return ECORE_CALLBACK_PASS_ON;
 }
@@ -670,6 +728,7 @@ _e_text_input_deactivate(E_Text_Input *text_input, E_Input_Method *input_method)
              wl_input_method_send_deactivate(input_method->resource,
                                              input_method->context->resource);
           }
+
         if (ecore_key_down_handler)
           {
              ecore_event_handler_del(ecore_key_down_handler);
@@ -706,6 +765,7 @@ _e_text_input_cb_activate(struct wl_client *client, struct wl_resource *resource
 
    text_input = wl_resource_get_user_data(resource);
    g_text_input = text_input;
+   g_client = client;
 
    /* FIXME: should get input_method object from seat. */
    input_method = wl_resource_get_user_data(g_input_method->resource);
@@ -769,10 +829,12 @@ err:
                             WL_DISPLAY_ERROR_INVALID_OBJECT,
                             "No Comp Data For Seat");
 }
+
 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;
+   g_client = NULL;
    E_Text_Input *text_input = wl_resource_get_user_data(resource);
    E_Input_Method *input_method = NULL;
 
@@ -800,7 +862,7 @@ _e_text_input_cb_deactivate(struct wl_client *client EINA_UNUSED, struct wl_reso
 }
 
 static Eina_Bool
-_e_text_input_method_create_context(struct wl_client *client EINA_UNUSED, E_Input_Method *input_method, E_Text_Input *text_input)
+_e_text_input_method_create_context(struct wl_client *client, E_Input_Method *input_method, E_Text_Input *text_input)
 {
    E_Input_Method_Context *context = NULL;
 
@@ -809,6 +871,7 @@ _e_text_input_method_create_context(struct wl_client *client EINA_UNUSED, E_Inpu
    EINA_SAFETY_ON_NULL_RETURN_VAL(text_input, EINA_FALSE);
 
    g_text_input = text_input;
+   g_client = client;
    input_method->model = text_input;
    text_input->input_methods = eina_list_append(text_input->input_methods, input_method);
 
@@ -837,7 +900,7 @@ _e_text_input_method_create_context(struct wl_client *client EINA_UNUSED, E_Inpu
 }
 
 static void
-_e_text_input_cb_input_panel_show(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
+_e_text_input_cb_input_panel_show(struct wl_client *client, struct wl_resource *resource)
 {
    E_Text_Input *text_input = wl_resource_get_user_data(resource);
    E_Input_Method *input_method = NULL;
@@ -877,44 +940,9 @@ _e_text_input_cb_input_panel_show(struct wl_client *client EINA_UNUSED, struct w
 }
 
 static void
-_e_text_input_cb_input_panel_hide(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
+_e_text_input_cb_input_panel_hide(struct wl_client *client, struct wl_resource *resource)
 {
-   E_Text_Input *text_input = wl_resource_get_user_data(resource);
-   E_Input_Method *input_method = NULL;
-   Eina_Bool _context_created = EINA_FALSE;
-
-   if (!text_input)
-     {
-        wl_resource_post_error(resource,
-                               WL_DISPLAY_ERROR_INVALID_OBJECT,
-                               "No Text Input For Resource");
-        return;
-     }
-
-   text_input->input_panel_visibile = EINA_FALSE;
-
-   if (text_input->resource)
-     wl_text_input_send_input_panel_state(text_input->resource,
-                                          WL_TEXT_INPUT_INPUT_PANEL_STATE_HIDE);
-
-   e_input_panel_visibility_change(EINA_FALSE);
-
-   if (g_input_method && g_input_method->resource)
-     input_method = wl_resource_get_user_data(g_input_method->resource);
-
-    /*
-      If input_method->context is already deleted, create context struct again to send input_panel_hide event to Input Method(IME) correctly.
-      Because input_panel_hide event can be called after focus_out(deactivate) by application.
-      And Input Method(IME) should know the state of their own input_panel to manage their resource when the input_panel is hidden.
-    */
-   if (input_method && (!input_method->context || !input_method->context->resource))
-     _context_created = _e_text_input_method_create_context(client, input_method, text_input);
-
-   if (input_method && input_method->resource && input_method->context && input_method->context->resource)
-     wl_input_method_send_hide_input_panel(input_method->resource, input_method->context->resource);
-
-   if (_context_created)
-     _e_text_input_deactivate(text_input, input_method);
+   _input_panel_hide(client, resource);
 }
 
 static void
@@ -1482,6 +1510,8 @@ e_modapi_init(E_Module *m)
 
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_RESIZE, _e_text_input_method_context_cb_client_resize, NULL);
 
+   vconf_notify_key_changed(VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, _keyboard_mode_changed_cb, NULL);
+
    eeze_udev_watch_hander = eeze_udev_watch_add(EEZE_UDEV_TYPE_KEYBOARD,
                                                 EEZE_UDEV_EVENT_REMOVE,
                                                 _e_mod_eeze_udev_watch_cb,
@@ -1500,6 +1530,8 @@ e_modapi_shutdown(E_Module *m EINA_UNUSED)
 {
    E_FREE_LIST(handlers, ecore_event_handler_del);
 
+   vconf_ignore_key_changed(VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, _keyboard_mode_changed_cb);
+
    if (eeze_udev_watch_hander)
      {
         eeze_udev_watch_del(eeze_udev_watch_hander);