e_keyrouter: add keyrouter hook functions 10/125010/13 accepted/tizen/unified/20170605.151607 submit/tizen/20170605.022315 submit/tizen/20170605.040707 submit/tizen/20170605.072005
authorJengHyun Kang <jhyuni.kang@samsung.com>
Thu, 13 Apr 2017 09:35:22 +0000 (18:35 +0900)
committerJeongHyun Kang <jhyuni.kang@samsung.com>
Fri, 2 Jun 2017 04:14:44 +0000 (04:14 +0000)
Change-Id: I1f304082b6e5040fc934915736c0b42066491e6a

src/bin/Makefile.mk
src/bin/e_includes.h
src/bin/e_keyrouter.c [new file with mode: 0644]
src/bin/e_keyrouter.h [new file with mode: 0644]

index 10e2b8f91a813863a66e514f3d3b3b517113d5f6..1ceddfde0e38c5cb7ee7841c2a16921b7abcc52b 100644 (file)
@@ -111,7 +111,8 @@ src/bin/e_policy_wl.h \
 src/bin/e_policy_wl_display.h \
 src/bin/e_process.h \
 src/bin/e_privilege.h \
-src/bin/e_security.h
+src/bin/e_security.h \
+src/bin/e_keyrouter.h
 
 enlightenment_src = \
 src/bin/e_actions.c \
@@ -204,7 +205,8 @@ src/bin/e_policy_wl.c \
 src/bin/e_policy_wl_display.c \
 src/bin/e_process.c \
 src/bin/e_privilege.c \
-src/bin/e_security.c
+src/bin/e_security.c \
+src/bin/e_keyrouter.c
 
 src_bin_enlightenment_CPPFLAGS = $(E_CPPFLAGS) -DEFL_BETA_API_SUPPORT -DEFL_EO_API_SUPPORT -DE_LOGGING=1 @WAYLAND_CFLAGS@ $(TTRACE_CFLAGS) $(DLOG_CFLAGS) $(POLICY_CFLAGS) @TIZEN_REMOTE_SURFACE_CFLAGS@
 if HAVE_LIBGOMP
index d9f4f4e7f186031ad0e6af0c4f41e1ba7a80134d..52ba40e4395713cdce7edeb2b3bee8b85be8f970 100644 (file)
@@ -66,3 +66,4 @@
 #include "e_privilege.h"
 #include "e_security.h"
 #include "e_main.h"
+#include "e_keyrouter.h"
diff --git a/src/bin/e_keyrouter.c b/src/bin/e_keyrouter.c
new file mode 100644 (file)
index 0000000..9deb5bf
--- /dev/null
@@ -0,0 +1,77 @@
+#include "e.h"
+#include "e_keyrouter.h"
+
+static int _e_keyrouter_intercept_hooks_delete = 0;
+static int _e_keyrouter_intercept_hooks_walking = 0;
+
+static Eina_Inlist *_e_keyrouter_intercept_hooks[] =
+{
+   [E_KEYROUTER_INTERCEPT_HOOK_BEFORE_KEYROUTING] = NULL,
+   [E_KEYROUTER_INTERCEPT_HOOK_DELIVER_FOCUS] = NULL,
+};
+
+E_API E_Keyrouter_Info e_keyrouter;
+
+E_API E_Keyrouter_Intercept_Hook *
+e_keyrouter_intercept_hook_add(E_Keyrouter_Intercept_Hook_Point hookpoint, E_Keyrouter_Intercept_Hook_Cb func, const void *data)
+{
+   E_Keyrouter_Intercept_Hook *ch;
+
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_KEYROUTER_INTERCEPT_HOOK_LAST, NULL);
+   ch = E_NEW(E_Keyrouter_Intercept_Hook, 1);
+   if (!ch) return NULL;
+   ch->hookpoint = hookpoint;
+   ch->func = func;
+   ch->data = (void*)data;
+   _e_keyrouter_intercept_hooks[hookpoint] = eina_inlist_append(_e_keyrouter_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
+   return ch;
+}
+
+E_API void
+e_keyrouter_intercept_hook_del(E_Keyrouter_Intercept_Hook *ch)
+{
+   EINA_SAFETY_ON_NULL_RETURN(ch);
+
+   ch->delete_me = 1;
+   if (_e_keyrouter_intercept_hooks_walking == 0)
+     {
+        _e_keyrouter_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_keyrouter_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
+        free(ch);
+     }
+   else
+     _e_keyrouter_intercept_hooks_delete++;
+}
+
+static void
+_e_keyrouter_intercept_hooks_clean(void)
+{
+   Eina_Inlist *l;
+   E_Keyrouter_Intercept_Hook *ch;
+   unsigned int x;
+   for (x = 0; x < E_KEYROUTER_INTERCEPT_HOOK_LAST; x++)
+     EINA_INLIST_FOREACH_SAFE(_e_keyrouter_intercept_hooks[x], l, ch)
+       {
+          if (!ch->delete_me) continue;
+          _e_keyrouter_intercept_hooks[x] = eina_inlist_remove(_e_keyrouter_intercept_hooks[x], EINA_INLIST_GET(ch));
+         free(ch);
+       }
+}
+
+E_API Eina_Bool
+e_keyrouter_intercept_hook_call(E_Keyrouter_Intercept_Hook_Point hookpoint, int type, Ecore_Event_Key *event)
+{
+   E_Keyrouter_Intercept_Hook *ch;
+   Eina_Bool res = EINA_TRUE;
+
+   _e_keyrouter_intercept_hooks_walking++;
+   EINA_INLIST_FOREACH(_e_keyrouter_intercept_hooks[hookpoint], ch)
+     {
+        if (ch->delete_me) continue;
+        res = ch->func(ch->data, type, event);
+     }
+   _e_keyrouter_intercept_hooks_walking--;
+   if ((_e_keyrouter_intercept_hooks_walking == 0) && (_e_keyrouter_intercept_hooks_delete > 0))
+     _e_keyrouter_intercept_hooks_clean();
+
+   return res;
+}
diff --git a/src/bin/e_keyrouter.h b/src/bin/e_keyrouter.h
new file mode 100644 (file)
index 0000000..66cecb3
--- /dev/null
@@ -0,0 +1,92 @@
+#ifdef E_TYPEDEFS
+
+typedef struct _E_Keyrouter_Intercept_Hook E_Keyrouter_Intercept_Hook;
+typedef struct _E_Keyrouter_Info E_Keyrouter_Info;
+typedef struct _E_Keyrouter_Key_List_Node E_Keyrouter_Key_List_Node;
+typedef struct _E_Keyrouter_Key_List_Node* E_Keyrouter_Key_List_NodePtr;
+typedef struct _E_Keyrouter_Tizen_HWKey E_Keyrouter_Tizen_HWKey;
+typedef struct _E_Keyrouter_Grabbed_Key E_Keyrouter_Grabbed_Key;
+typedef struct _E_Keyrouter_Registered_Window_Info E_Keyrouter_Registered_Window_Info;
+
+typedef enum _E_Keyrouter_Intercept_Hook_Point
+{
+   E_KEYROUTER_INTERCEPT_HOOK_BEFORE_KEYROUTING,
+   E_KEYROUTER_INTERCEPT_HOOK_DELIVER_FOCUS,
+   E_KEYROUTER_INTERCEPT_HOOK_LAST
+} E_Keyrouter_Intercept_Hook_Point;
+
+typedef enum _E_Keyrouter_Client_Status
+{
+   E_KRT_CSTAT_DEAD = 0,
+   E_KRT_CSTAT_ALIVE,
+   E_KRT_CSTAT_UNGRAB
+} E_Keyrouter_Client_Status;
+
+typedef Eina_Bool (*E_Keyrouter_Intercept_Hook_Cb) (void *data, int type, Ecore_Event_Key *event);
+
+#else
+#ifndef E_KEYROUTER_H
+#define E_KEYROUTER_H
+
+extern E_API E_Keyrouter_Info e_keyrouter;
+
+struct _E_Keyrouter_Intercept_Hook
+{
+   EINA_INLIST;
+   E_Keyrouter_Intercept_Hook_Point hookpoint;
+   E_Keyrouter_Intercept_Hook_Cb func;
+   void *data;
+   unsigned char delete_me : 1;
+};
+
+struct _E_Keyrouter_Info
+{
+   void *(*keygrab_list_get)(void);
+   int (*max_keycode_get)(void);
+};
+
+struct _E_Keyrouter_Registered_Window_Info
+{
+   struct wl_resource *surface;
+   Eina_List *keys;
+};
+
+struct _E_Keyrouter_Key_List_Node
+{
+   struct wl_resource *surface;
+   struct wl_client *wc;
+   Eina_Bool focused;
+   E_Keyrouter_Client_Status status;
+};
+
+struct _E_Keyrouter_Tizen_HWKey
+{
+   char *name;
+   int keycode;
+   int no_privcheck;
+   int repeat;
+};
+
+struct _E_Keyrouter_Grabbed_Key
+{
+   int keycode;
+   char* keyname;
+   Eina_Bool no_privcheck;
+   Eina_Bool repeat;
+
+   Eina_List *excl_ptr;
+   Eina_List *or_excl_ptr;
+   Eina_List *top_ptr;
+   Eina_List *shared_ptr;
+   Eina_List *press_ptr;
+   E_Keyrouter_Key_List_Node *registered_ptr;
+   Eina_List *pic_off_ptr;
+};
+
+E_API E_Keyrouter_Intercept_Hook *e_keyrouter_intercept_hook_add(E_Keyrouter_Intercept_Hook_Point hookpoint, E_Keyrouter_Intercept_Hook_Cb func, const void *data);
+E_API void e_keyrouter_intercept_hook_del(E_Keyrouter_Intercept_Hook *ch);
+E_API Eina_Bool e_keyrouter_intercept_hook_call(E_Keyrouter_Intercept_Hook_Point hookpoint, int type, Ecore_Event_Key *event);
+
+#endif
+#endif
+