990b055b76bce14af5f3dae22b5ea94193e617c4
[platform/core/uifw/e-mod-tizen-keyrouter.git] / src / e_mod_main_wl.h
1 #ifndef E_MOD_MAIN_H
2 #define E_MOD_MAIN_H
3
4 #include "e.h"
5 #include <tizen-extension-server-protocol.h>
6 #ifdef ENABLE_CYNARA
7 #include <cynara-session.h>
8 #include <cynara-client.h>
9 #include <cynara-creds-socket.h>
10 #endif
11 #include <string.h>
12
13 #ifdef TRACE_INPUT_BEGIN
14 #undef TRACE_INPUT_BEGIN
15 #endif
16 #ifdef TRACE_INPUT_END
17 #undef TRACE_INPUT_END
18 #endif
19
20 #ifdef ENABLE_TTRACE
21 #include <ttrace.h>
22
23 #define TRACE_INPUT_BEGIN(NAME, ...) traceBegin(TTRACE_TAG_INPUT, "INPUT:KRT:"#NAME, ##__VA_ARGS__)
24 #define TRACE_INPUT_END() traceEnd(TTRACE_TAG_INPUT)
25 #else
26 #define TRACE_INPUT_BEGIN(NAME)
27 #define TRACE_INPUT_END()
28 #endif
29
30 /* Temporary value of maximum number of HWKeys */
31
32 #define CHECK_ERR(val) if (TIZEN_KEYROUTER_ERROR_NONE != val) return;
33 #define CHECK_ERR_VAL(val) if (TIZEN_KEYROUTER_ERROR_NONE != val) return val;
34 #define CHECK_NULL(val) if (!val) return;
35 #define CHECK_NULL_VAL(val) if (!val) return val;
36
37 extern int _keyrouter_log_dom;
38
39 #undef ERR
40 #undef WRN
41 #undef INF
42 #undef DBG
43 #define ERR(...) EINA_LOG_DOM_ERR(_keyrouter_log_dom, __VA_ARGS__)
44 #define WRN(...) EINA_LOG_DOM_WARN(_keyrouter_log_dom, __VA_ARGS__)
45 #define INF(...) EINA_LOG_DOM_INFO(_keyrouter_log_dom, __VA_ARGS__)
46 #define DBG(...) EINA_LOG_DOM_DBG(_keyrouter_log_dom, __VA_ARGS__)
47
48 #define KLERR(msg, ARG...) ERR(msg, ##ARG)
49 #define KLWRN(msg, ARG...) WRN(msg, ##ARG)
50 #define KLINF(msg, ARG...) INF(msg, ##ARG)
51 #define KLDBG(msg, ARG...) DBG(msg, ##ARG)
52
53 typedef struct _E_Keyrouter E_Keyrouter;
54 typedef struct _E_Keyrouter* E_KeyrouterPtr;
55 typedef struct _E_Keyrouter_Key_List_Node E_Keyrouter_Key_List_Node;
56 typedef struct _E_Keyrouter_Key_List_Node* E_Keyrouter_Key_List_NodePtr;
57 typedef struct _E_Keyrouter_Tizen_HWKey E_Keyrouter_Tizen_HWKey;
58 typedef struct _E_Keyrouter_Grabbed_Key E_Keyrouter_Grabbed_Key;
59 typedef struct _E_Keyrouter_Grab_Request E_Keyrouter_Grab_Request;
60 typedef struct _E_Keyrouter_Ungrab_Request E_Keyrouter_Ungrab_Request;
61 typedef struct _E_Keyrouter_Registered_Window_Info E_Keyrouter_Registered_Window_Info;
62
63 typedef struct _E_Keyrouter_Conf_Edd E_Keyrouter_Conf_Edd;
64 typedef struct _E_Keyrouter_Config_Data E_Keyrouter_Config_Data;
65
66 #define TIZEN_KEYROUTER_MODE_PRESSED        TIZEN_KEYROUTER_MODE_REGISTERED+1
67 #define TIZEN_KEYROUTER_MODE_PICTURE_OFF        TIZEN_KEYROUTER_MODE_REGISTERED+2
68
69 typedef enum _E_Keyrouter_Client_Status
70 {
71    E_KRT_CSTAT_DEAD = 0,
72    E_KRT_CSTAT_ALIVE,
73    E_KRT_CSTAT_UNGRAB
74 } E_Keyrouter_Client_Status;
75
76 typedef unsigned long Time;
77
78 extern E_KeyrouterPtr krt;
79
80 struct _E_Keyrouter_Conf_Edd
81 {
82    int num_keycode;
83    int max_keycode;
84    int pictureoff_disabled;
85    Eina_List *KeyList;
86 };
87
88 struct _E_Keyrouter_Config_Data
89 {
90    E_Module *module;
91    E_Config_DD *conf_edd;
92    E_Config_DD *conf_hwkeys_edd;
93    E_Keyrouter_Conf_Edd *conf;
94 };
95
96 struct _E_Keyrouter_Registered_Window_Info
97 {
98    struct wl_resource *surface;
99    Eina_List *keys;
100 };
101
102 struct _E_Keyrouter_Key_List_Node
103 {
104    struct wl_resource *surface;
105    struct wl_client *wc;
106    Eina_Bool focused;
107    E_Keyrouter_Client_Status status;
108 };
109
110 struct _E_Keyrouter_Tizen_HWKey
111 {
112    char *name;
113    int keycode;
114    int no_privcheck;
115    int repeat;
116 };
117
118 struct _E_Keyrouter_Grabbed_Key
119 {
120    int keycode;
121    char* keyname;
122    Eina_Bool no_privcheck;
123    Eina_Bool repeat;
124
125    Eina_List *excl_ptr;
126    Eina_List *or_excl_ptr;
127    Eina_List *top_ptr;
128    Eina_List *shared_ptr;
129    Eina_List *press_ptr;
130    E_Keyrouter_Key_List_Node *registered_ptr;
131    Eina_List *pic_off_ptr;
132 };
133
134 struct _E_Keyrouter
135 {
136    struct wl_global *global;
137    Ecore_Event_Filter *ef_handler;
138    Eina_List *handlers;
139    Eina_List *resources;
140
141    E_Keyrouter_Config_Data *conf;
142
143    E_Keyrouter_Grabbed_Key *HardKeys;
144    Eina_List *grab_surface_list;
145    Eina_List *grab_client_list;
146
147    Eina_List *registered_window_list;
148
149    Eina_Bool isWindowStackChanged;
150    int numTizenHWKeys;
151    int max_tizen_hwkeys;
152    int register_none_key;
153    Eina_List *registered_none_key_window_list;
154    Eina_List *invisible_set_window_list;
155    Eina_List *invisible_get_window_list;
156    struct wl_resource * playback_daemon_surface;
157 #ifdef ENABLE_CYNARA
158    cynara *p_cynara;
159 #endif
160    int isPictureOffEnabled;
161    Eina_Bool pictureoff_disabled;
162 };
163
164 struct _E_Keyrouter_Grab_Request {
165    int key;
166    int mode;
167    int err;
168 };
169
170 struct _E_Keyrouter_Ungrab_Request {
171    int key;
172    int err;
173 };
174
175
176 /* E Module */
177 E_API extern E_Module_Api e_modapi;
178 E_API void *e_modapi_init(E_Module *m);
179 E_API int   e_modapi_shutdown(E_Module *m);
180 E_API int   e_modapi_save(E_Module *m);
181
182 int e_keyrouter_set_keygrab_in_list(struct wl_resource *surface, struct wl_client *client, uint32_t key, uint32_t mode);
183 int e_keyrouter_prepend_to_keylist(struct wl_resource *surface, struct wl_client *wc, uint32_t key, uint32_t mode, Eina_Bool focused);
184 void e_keyrouter_find_and_remove_client_from_list(struct wl_resource *surface, struct wl_client *wc, uint32_t key, uint32_t mode);
185 void e_keyrouter_remove_client_from_list(struct wl_resource *surface, struct wl_client *wc);
186 int e_keyrouter_find_key_in_list(struct wl_resource *surface, struct wl_client *wc, uint32_t key);
187 Eina_Bool e_keyrouter_find_key_in_register_list(uint32_t key);
188
189 int e_keyrouter_add_client_destroy_listener(struct wl_client *client);
190 int e_keyrouter_add_surface_destroy_listener(struct wl_resource *surface);
191
192 Eina_Bool e_keyrouter_process_key_event(void *event, int type);
193
194 int e_keyrouter_set_keyregister(struct wl_client *client, struct wl_resource *surface, uint32_t key);
195 int e_keyrouter_unset_keyregister(struct wl_resource *surface, struct wl_client *client, uint32_t key);
196 Eina_Bool e_keyrouter_is_registered_window(struct wl_resource *surface);
197 void e_keyrouter_clear_registered_window(void);
198 Eina_List* _e_keyrouter_registered_window_key_list(struct wl_resource *surface);
199 Eina_Bool IsNoneKeyRegisterWindow(struct wl_resource *surface);
200 Eina_Bool IsInvisibleSetWindow(struct wl_resource *surface);
201 Eina_Bool IsInvisibleGetWindow(struct wl_resource *surface);
202
203
204 struct wl_resource *e_keyrouter_util_get_surface_from_eclient(E_Client *client);
205 int e_keyrouter_util_get_pid(struct wl_client *client, struct wl_resource *surface);
206 char *e_keyrouter_util_cmd_get_from_pid(int pid);
207 int e_keyrouter_util_keycode_get_from_string(char *name);
208 char *e_keyrouter_util_keyname_get_from_keycode(int keycode);
209 char *e_keyrouter_util_process_name_get_from_cmd(char *cmd);
210 const char *e_keyrouter_mode_to_string(uint32_t mode);
211
212 void e_keyrouter_conf_init(E_Keyrouter_Config_Data *kconfig);
213 void e_keyrouter_conf_deinit(E_Keyrouter_Config_Data *kconfig);
214 int e_keyrouter_cb_picture_off(const int option, void *data);
215
216 #endif