static Eina_Bool _e_keyrouter_send_key_event(int type, struct wl_resource *surface, struct wl_client *wc, Ecore_Event_Key *ev, Eina_Bool focused, unsigned int mode);
static Eina_Bool _e_keyrouter_send_key_events_focus(int type, struct wl_resource *surface, Ecore_Event_Key *ev, struct wl_resource **delivered_surface);
-static void _e_keyrouter_event_generate_key(Ecore_Event_Key *ev, int type, struct wl_client *send_surface);
+static void _e_keyrouter_event_generate_key(Ecore_Event_Key *ev, int type, struct wl_client *wc, struct wl_resource *surface, int mode);
static Eina_Bool _e_keyrouter_is_key_grabbed(int key);
static Eina_Bool _e_keyrouter_check_top_visible_window(E_Client *ec_focus, int arr_idx);
}
static void
-_e_keyrouter_event_generate_key(Ecore_Event_Key *ev, int type, struct wl_client *send_surface)
+_e_keyrouter_event_generate_keyrouter_key(Ecore_Event_Key *ev, int type, struct wl_client *wc, struct wl_resource *surface, int mode)
+{
+ E_Keyrouter_Event_Key *e;
+
+ KLDBG("Generate new routed key event! send to client: %p, surface: %p (pid: %d)", wc, surface, e_keyrouter_util_get_pid(wc, surface));
+
+ e = E_NEW(E_Keyrouter_Event_Key, 1);
+ EINA_SAFETY_ON_NULL_RETURN(e);
+
+ e->pressed = (type==ECORE_EVENT_KEY_DOWN)?EINA_TRUE:EINA_FALSE;
+ e->keycode = ev->keycode;
+ e->window = ev->window;
+ e->timestamp = ev->timestamp;
+ e->modifiers = ev->modifiers;
+ e->dev = ev->dev;
+
+ e->routed.client = wc;
+ e->routed.surface = surface;
+ e->routed.mode = mode;
+
+ ecore_event_add(E_KEYROUTER_EVENT_KEY, e, NULL, NULL);
+}
+
+static void
+_e_keyrouter_event_generate_key(Ecore_Event_Key *ev, int type, struct wl_client *wc, struct wl_resource *surface, int mode)
{
Ecore_Event_Key *ev_cpy = NULL;
ev_cpy = E_NEW(Ecore_Event_Key, 1);
EINA_SAFETY_ON_NULL_RETURN(ev_cpy);
- KLDBG("Generate new key event! send to wl_surface: %p (pid: %d)", send_surface, e_keyrouter_util_get_pid(send_surface, NULL));
+ KLDBG("Generate new key event! send to wl_surface: %p (pid: %d)", surface, e_keyrouter_util_get_pid(wc, surface));
ev_cpy->keyname = (char *)eina_stringshare_add(ev->keyname);
ev_cpy->key = (char *)eina_stringshare_add(ev->key);
ev_cpy->same_screen = ev->same_screen;
ev_cpy->keycode = ev->keycode;
- ev_cpy->data = send_surface;
+ ev_cpy->data = wc;
ev_cpy->dev = ev->dev;
if (ECORE_EVENT_KEY_DOWN == type)
ecore_event_add(ECORE_EVENT_KEY_DOWN, ev_cpy, _e_keyrouter_event_key_free, NULL);
else
ecore_event_add(ECORE_EVENT_KEY_UP, ev_cpy, _e_keyrouter_event_key_free, NULL);
+
+ _e_keyrouter_event_generate_keyrouter_key(ev, type, wc, surface, mode);
}
/* Function for checking the existing grab for a key and sending key event(s) */
if (ev->data)
{
- KLDBG("data is exist send to compositor: %p", ev->data);
+ KLDBG("data is exist send to compositor");
goto finish;
}
wc = wl_resource_get_client(krt->playback_daemon_surface);
if (wc)
{
- _e_keyrouter_event_generate_key(ev, type, wc);
+ _e_keyrouter_event_generate_key(ev, type, wc, krt->playback_daemon_surface, 0);
KLDBG("Sent key to playback-daemon");
}
}
//KLDBG("The key(%d) is going to be sent to the proper wl client(s) !", ev->keycode);
KLDBG("[%s] keyname: %s, key: %s, keycode: %d", (type == ECORE_EVENT_KEY_DOWN) ? "KEY_PRESS" : "KEY_RELEASE", ev->keyname, ev->key, ev->keycode);
if (_e_keyrouter_send_key_events(type, ev))
- res = EINA_FALSE;
+ res = EINA_TRUE;
finish:
return res;
if (ev->data)
{
*delivered_surface = ev->data;
- ev->data = wl_resource_get_client(ev->data);
}
return res;
}
}
else
{
- if (focused == EINA_TRUE) ev->data = wc_send;
+ if (focused == EINA_TRUE)
+ {
+ ev->data = wc_send;
+ }
+ }
+ if (focused == EINA_TRUE)
+ {
+ _e_keyrouter_event_generate_keyrouter_key(ev, type, wc_send, surface, mode);
+ }
+ else
+ {
+ _e_keyrouter_event_generate_key(ev, type, wc_send, surface, mode);
}
-
- if (focused == EINA_TRUE) return EINA_FALSE;
-
- _e_keyrouter_event_generate_key(ev, type, wc_send);
return EINA_TRUE;
}
return krt->max_tizen_hwkeys;
}
+static void
+_e_keyrouter_event_surface_send(struct wl_resource *surface, int key, int mode)
+{
+ Eina_List *l;
+ struct wl_resource *res_data;
+ struct wl_client *wc;
+
+ EINA_SAFETY_ON_NULL_RETURN(krt);
+ EINA_SAFETY_ON_NULL_RETURN(surface);
+
+ wc = wl_resource_get_client(surface);
+ EINA_SAFETY_ON_NULL_RETURN(wc);
+
+ EINA_LIST_FOREACH(krt->resources, l, res_data)
+ {
+ if (wl_resource_get_client(res_data) != wc) continue;
+
+ tizen_keyrouter_send_event_surface(res_data, surface, key, mode);
+ }
+}
+
static E_Keyrouter_Config_Data *
_e_keyrouter_init(E_Module *m)
{
ecore_idle_enterer_add(_e_keyrouter_cb_idler, NULL);
_e_keyrouter_init_handlers();
- krt->global = wl_global_create(e_comp_wl->wl.disp, &tizen_keyrouter_interface, 1, krt, _e_keyrouter_cb_bind);
+ krt->global = wl_global_create(e_comp_wl->wl.disp, &tizen_keyrouter_interface, 2, krt, _e_keyrouter_cb_bind);
if (!krt->global)
{
KLERR("Failed to create global !");
e_keyrouter.keygrab_list_get = _e_keyrouter_keygrab_list_get;
e_keyrouter.max_keycode_get = _e_keyrouter_max_keycode_get;
+ e_keyrouter.event_surface_send = _e_keyrouter_event_surface_send;
#ifdef ENABLE_CYNARA
ret = cynara_initialize(&krt->p_cynara, NULL);