Use ISF-defined values when processing input device events 47/155747/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Wed, 11 Oct 2017 02:33:33 +0000 (11:33 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Mon, 16 Oct 2017 05:19:09 +0000 (05:19 +0000)
Since the ECORE_EVENT_* values are not constants, they can't be
guaranteed to be the same over processes. For this reason, the
existing method to send ECORE_EVENT_* value directly to a different
process causes malfunction.
Thus, we define input device type enum at ISF side to ensure
the values at sender side and receiver side is consistent.

Change-Id: Ia93b7dc2a5b7d26d3236ff5bf5bb7d2b02a51afc
(cherry picked from commit 382345f650ef7e4089644cfd49f8f280376a78e2)

configure.ac
ism/extras/wayland_immodule/wayland_imcontext.c
ism/src/Makefile.am
ism/src/isf_device_event.h [new file with mode: 0644]
ism/src/scim_helper.cpp

index f716985..a1ba87b 100644 (file)
@@ -218,6 +218,9 @@ PKG_CHECK_MODULES(ECORE_IPC, [ecore-ipc])
 # Check ECORE FILE library
 PKG_CHECK_MODULES(ECORE_FILE, [ecore-file])
 
+# Check ECORE FILE library
+PKG_CHECK_MODULES(ECORE_INPUT, [ecore-input])
+
 # Check ECORE EVAS library
 PKG_CHECK_MODULES(ECORE_EVAS, [ecore-evas])
 
index 03aa2da..4b289fa 100644 (file)
@@ -35,6 +35,7 @@
 #include "isf_debug.h"
 #include "wayland_imcontext.h"
 #include "tizen_profile.h"
+#include "isf_device_event.h"
 
 #ifdef LOG_TAG
 # undef LOG_TAG
@@ -806,8 +807,9 @@ rotary_event_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
 
     WaylandIMContext *imcontext = (WaylandIMContext *)ecore_imf_context_data_get(active_ctx);
     if (imcontext && imcontext->input && imcontext->text_input) {
+        isf_device_type_e type = find_device_type_from_ecore_event(ECORE_EVENT_DETENT_ROTATE);
         wl_text_input_process_input_device_event(imcontext->text_input,
-            (unsigned int)ECORE_EVENT_DETENT_ROTATE, (char*)event, sizeof(Ecore_Event_Detent_Rotate));
+            (unsigned int)type, (char*)event, sizeof(Ecore_Event_Detent_Rotate));
     }
 
     return EINA_FALSE;
index 6a439a1..3356d47 100644 (file)
@@ -173,6 +173,7 @@ libscim@SCIM_EPOCH@_la_SOURCES = \
 libscim@SCIM_EPOCH@_la_CXXFLAGS = @EVAS_CFLAGS@ \
                          @EINA_CFLAGS@ \
                          @ECORE_IMF_CFLAGS@ \
+                         @ECORE_INPUT_CFLAGS@ \
                          @DLOG_CFLAGS@ \
                          @DB_UTIL_CFLAGS@ \
                          @TZPLATFORM_CONFIG_CFLAGS@ \
@@ -187,6 +188,7 @@ libscim@SCIM_EPOCH@_la_LDFLAGS  = -version-info $(SCIM_CURRENT):$(SCIM_REVISION)
                          @LIBTOOL_EXPORT_OPTIONS@ \
                          @LIBICONV@ \
                          @LTLIBINTL@ \
+                         @ECORE_INPUT_LIBS@ \
                          @EINA_LIBS@ \
                          @DLOG_LIBS@ \
                          @DB_UTIL_LIBS@ \
diff --git a/ism/src/isf_device_event.h b/ism/src/isf_device_event.h
new file mode 100644 (file)
index 0000000..c92f530
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * ISF(Input Service Framework)
+ *
+ * ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable.
+ * Copyright (c) 2012-2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jihoon Kim <jihoon48.kim@samsung.com>, Ji-hoon Lee <dalton.lee@samsung.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef __ISF_DEVICE_EVENT_H
+#define __ISF_DEVICE_EVENT_H
+
+#include <Ecore_Input.h>
+#include <Eina.h>
+
+/**
+ * @brief Enumeration of unconventional input devices
+ *
+ */
+typedef enum {
+    ISF_DEVICE_TYPE_CONVENTIONAL, /**< Conventional input device */
+    ISF_DEVICE_TYPE_UNKNOWN, /**< Undefined unconventional input device */
+    ISF_DEVICE_TYPE_ROTARY, /**< A rotary input device such as bezel that can be found on a wearable device */
+
+    ISF_DEVICE_TYPE_MAX /**< Note that this MAX variable is fixed at compile time */
+} isf_device_type_e;
+
+typedef struct {
+    int ecore_event_id;
+    isf_device_type_e device_type;
+} isf_device_type_conv_table;
+
+static isf_device_type_conv_table g_conv_table[ISF_DEVICE_TYPE_MAX] = {
+    { -1, ISF_DEVICE_TYPE_CONVENTIONAL },
+    { -1, ISF_DEVICE_TYPE_UNKNOWN },
+    { -1, ISF_DEVICE_TYPE_ROTARY },
+};
+static Eina_Bool g_conv_table_initalized = EINA_FALSE;
+
+static void initialize_conv_table()
+{
+    if (!g_conv_table_initalized) {
+        g_conv_table[ISF_DEVICE_TYPE_ROTARY].ecore_event_id = ECORE_EVENT_DETENT_ROTATE;
+        g_conv_table_initalized = EINA_TRUE;
+    }
+}
+
+static inline isf_device_type_e find_device_type_from_ecore_event(int ecore_event_id)
+{
+    initialize_conv_table();
+
+    isf_device_type_e device_type = ISF_DEVICE_TYPE_UNKNOWN;
+    for (unsigned int loop = 0; loop < sizeof(g_conv_table) / sizeof(isf_device_type_conv_table); loop++) {
+        if (g_conv_table[loop].ecore_event_id == ecore_event_id) {
+            device_type = g_conv_table[loop].device_type;
+        }
+    }
+    return device_type;
+}
+
+static inline int find_ecore_event_from_device_type(isf_device_type_e device_type)
+{
+    initialize_conv_table();
+
+    int ecore_event = -1;
+    for (unsigned int loop = 0; loop < sizeof(g_conv_table) / sizeof(isf_device_type_conv_table); loop++) {
+        if (g_conv_table[loop].device_type == device_type) {
+            ecore_event = g_conv_table[loop].ecore_event_id;
+        }
+    }
+    return ecore_event;
+}
+
+#endif  /* __ISF_DEVICE_EVENT_H */
+
+/*
+vi:ts=4:expandtab:nowrap
+*/
index dc9ce05..4e53df4 100644 (file)
@@ -61,6 +61,7 @@
 #ifdef HAVE_PKGMGR_INFO
 #include <pkgmgr-info.h>
 #endif // HAVE_PKGMGR_INFO
+#include "isf_device_event.h"
 
 #ifdef LOG_TAG
 # undef LOG_TAG
@@ -1399,8 +1400,9 @@ HelperAgent::handle_message (MessageItem *message)
         {
             MessageItemProcessInputDeviceEvent *subclass = static_cast<MessageItemProcessInputDeviceEvent*>(message);
             uint32 ret = 0;
+            unsigned int ecore_event_id = find_ecore_event_from_device_type((isf_device_type_e)(subclass->get_type_ref()));
             m_impl->signal_process_input_device_event(this,
-                subclass->get_type_ref(), *(subclass->get_data_ptr()), subclass->get_len_ref(), ret);
+                ecore_event_id, *(subclass->get_data_ptr()), subclass->get_len_ref(), ret);
             break;
         }
         case SCIM_TRANS_CMD_SET_AUTOCAPITAL_TYPE: