e_keyrouter_wl: refactor code
[platform/upstream/enlightenment.git] / src / bin / inputmgr / e_keyrouter_intern.h
1 #ifndef E_KEYROUTER_INTERN_H
2 #define E_KEYROUTER_INTERN_H
3
4 #include "e_intern.h"
5 #include "e_keyrouter.h"
6 #include "e_input_event_intern.h"
7 #include "e_device_intern.h"
8
9 #define CHECK_ERR(val) if (TIZEN_KEYROUTER_ERROR_NONE != val) return;
10 #define CHECK_ERR_VAL(val) if (TIZEN_KEYROUTER_ERROR_NONE != val) return val;
11 #define CHECK_NULL(val) if (!val) return;
12 #define CHECK_NULL_VAL(val) if (!val) return val;
13
14 #define KLERR(msg, ARG...) ERR(msg, ##ARG)
15 #define KLWRN(msg, ARG...) WRN(msg, ##ARG)
16 #define KLINF(msg, ARG...) INF(msg, ##ARG)
17 #define KLDBG(msg, ARG...) DBG(msg, ##ARG)
18
19 #define TIZEN_KEYROUTER_MODE_PRESSED        TIZEN_KEYROUTER_MODE_REGISTERED+1
20 #define TIZEN_KEYROUTER_MODE_PICTURE_OFF        TIZEN_KEYROUTER_MODE_REGISTERED+2
21
22 typedef unsigned long Time;
23
24 typedef struct _E_Keyrouter  E_Keyrouter;
25 typedef struct _E_Keyrouter* E_KeyrouterPtr;
26
27 typedef struct _E_Keyrouter_Conf_Edd    E_Keyrouter_Conf_Edd;
28 typedef struct _E_Keyrouter_Config_Data E_Keyrouter_Config_Data;
29
30 typedef struct _E_Keyrouter_Grab_Request   E_Keyrouter_Grab_Request;
31 typedef struct _E_Keyrouter_Ungrab_Request E_Keyrouter_Ungrab_Request;
32
33 typedef struct _E_Keyrouter_Tizen_HWKey E_Keyrouter_Tizen_HWKey;
34
35 typedef struct _E_Keyrouter_Registered_Window_Info E_Keyrouter_Registered_Window_Info;
36
37 typedef struct _E_Keyrouter_Event_Key_Long        E_Keyrouter_Event_Key_Long;
38 typedef struct _E_Keyrouter_Event_Key_Composition E_Keyrouter_Event_Key_Composition;
39
40 struct _E_Keyrouter_Conf_Edd
41 {
42    int num_keycode;                   // The numbers of keyrouted keycodes defined by xkb-tizen-data
43    int max_keycode;                   // The max value of keycodes
44    int pictureoff_disabled;           // To disable picture_off feature.
45    double composition_key_wait_time;  // The time of waiting to composition key's press events
46    Eina_List *KeyList;                // The list of routed key data: E_Keyrouter_Tizen_HWKey
47 };
48
49 struct _E_Keyrouter_Config_Data
50 {
51    E_Config_DD *conf_edd;
52    E_Config_DD *conf_hwkeys_edd;
53    E_Keyrouter_Conf_Edd *conf;
54 };
55
56 struct _E_Keyrouter
57 {
58    Ecore_Event_Filter *ef_handler;
59    Eina_List *handlers;
60    Eina_List *ignore_list;
61
62    E_Keyrouter_Config_Data *conf;
63
64    E_Keyrouter_Grabbed_Key *HardKeys;
65
66    Eina_Bool isWindowStackChanged;
67    int numTizenHWKeys;
68    int max_tizen_hwkeys;
69
70    int isPictureOffEnabled;
71    Eina_Bool pictureoff_disabled;
72
73    struct
74      {
75         gint waiting_timer;
76         double waiting_time;
77
78         int key[2];
79      } composition_key;
80    struct
81      {
82         gint timer;
83         int key;
84      } longkey;
85
86    E_Input_Event_Handler *_key_down_handler;
87    E_Input_Event_Handler *_key_up_handler;
88    EINA_DEPRECATED GMutex event_handler_mutex;
89    GRecMutex grab_key_mutex;
90 };
91
92 struct _E_Keyrouter_Grab_Request {
93    int key;
94    int mode;
95    int err;
96 };
97
98 struct _E_Keyrouter_Ungrab_Request {
99    int key;
100    int err;
101 };
102
103 struct _E_Keyrouter_Intercept_Hook
104 {
105    EINA_INLIST;
106    E_Keyrouter_Intercept_Hook_Point hookpoint;
107    E_Keyrouter_Intercept_Hook_Cb func;
108    void *data;
109    unsigned char delete_me : 1;
110 };
111
112 struct _E_Keyrouter_Registered_Window_Info
113 {
114    struct wl_resource *surface;
115    Eina_List *keys;
116 };
117
118 struct _E_Keyrouter_Tizen_HWKey
119 {
120    char *name;
121    int keycode;
122    int no_privcheck;
123    int repeat;
124 };
125
126 struct _E_Keyrouter_Event_Key_Long
127 {
128    int keycode;
129
130    void *data;
131 };
132
133 struct _E_Keyrouter_Event_Key_Composition
134 {
135    int keys[2];
136    unsigned int timestamp;
137
138    void *data;
139 };
140
141 extern E_API E_KeyrouterPtr krt;
142
143 extern EINTERN int E_KEYROUTER_EVENT_KEY_LONG;
144 extern EINTERN int E_KEYROUTER_EVENT_KEY_COMPOSITION_PRESS;
145 extern EINTERN int E_KEYROUTER_EVENT_KEY_COMPOSITION_RELEASE;
146
147 EINTERN int e_keyrouter_init(void);
148 EINTERN int e_keyrouter_shutdown(void);
149
150 EINTERN int  e_keyrouter_longkey_add(int keycode, double time);
151 EINTERN void e_keyrouter_longkey_del(int keycode);
152
153 EINTERN int  e_keyrouter_composition_key_add(int *keys, int count);
154 EINTERN void e_keyrouter_composition_key_del(int *keys, int count);
155
156 EINTERN void e_keyrouter_event_surface_send(E_Client *ec, int key);
157
158 EINTERN void e_keyrouter_input_handler_add(void);
159
160 EINTERN Eina_Bool e_keyrouter_query_tizen_key_table(void);
161
162 EINTERN int e_keyrouter_set_keygrab_in_list(struct wl_resource *surface, struct wl_client *client, uint32_t key, uint32_t mode);
163 EINTERN int e_keyrouter_prepend_to_keylist(struct wl_resource *surface, struct wl_client *wc, uint32_t key, uint32_t mode, Eina_Bool focused);
164 EINTERN void e_keyrouter_find_and_remove_client_from_list(struct wl_resource *surface, struct wl_client *wc, uint32_t key, uint32_t mode);
165 EINTERN void e_keyrouter_remove_client_from_list(struct wl_resource *surface, struct wl_client *wc);
166 EINTERN int e_keyrouter_find_key_in_list(struct wl_resource *surface, struct wl_client *wc, uint32_t key);
167 EINTERN Eina_Bool e_keyrouter_process_key_event(void *event, int type);
168
169 EINTERN struct wl_resource *e_keyrouter_util_get_surface_from_eclient(E_Client *client);
170 EINTERN int                 e_keyrouter_util_get_pid(struct wl_client *client, struct wl_resource *surface);
171 EINTERN char               *e_keyrouter_util_cmd_get_from_pid(int pid);
172 EINTERN char               *e_keyrouter_util_process_name_get_from_cmd(char *cmd);
173 EINTERN const char         *e_keyrouter_mode_to_string(uint32_t mode);
174
175 EINTERN void e_keyrouter_conf_init(E_Keyrouter_Config_Data *kconfig);
176 EINTERN void e_keyrouter_conf_deinit(E_Keyrouter_Config_Data *kconfig);
177
178 EINTERN int e_keyrouter_cb_picture_off(const int option, void *data);
179
180 EINTERN int e_keyrouter_keygrab_set(struct wl_client *client, struct wl_resource *surface, int key, int mode);
181 EINTERN void e_keyrouter_keygrab_unset(struct wl_client *client, struct wl_resource *surface, int key);
182
183 EINTERN Eina_Bool e_keyrouter_event_process(void *event, E_Device *dev, int type);
184
185 #endif