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 \
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
#include "e_privilege.h"
#include "e_security.h"
#include "e_main.h"
+#include "e_keyrouter.h"
--- /dev/null
+#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;
+}
--- /dev/null
+#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
+