support a event_surface event 15/155515/1 accepted/tizen/4.0/unified/20171108.063702 submit/tizen_4.0/20171107.093340
authorJengHyun Kang <jhyuni.kang@samsung.com>
Wed, 27 Sep 2017 10:24:06 +0000 (19:24 +0900)
committerJengHyun Kang <jhyuni.kang@samsung.com>
Fri, 13 Oct 2017 10:20:54 +0000 (19:20 +0900)
Change-Id: Iad0021c614cfaa22368ec57c6fd99179637a3c83

src/e_mod_keyrouter_events.c
src/e_mod_keyrouter_list.c
src/e_mod_main_wl.c

index a4ca5c7..064a958 100644 (file)
@@ -7,7 +7,7 @@ static Eina_Bool _e_keyrouter_send_key_events_release(int type, Ecore_Event_Key
 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);
@@ -44,14 +44,38 @@ _e_keyrouter_event_key_free(void *data EINA_UNUSED, void *ev)
 }
 
 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);
@@ -68,13 +92,15 @@ _e_keyrouter_event_generate_key(Ecore_Event_Key *ev, int type, struct wl_client
    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) */
@@ -91,7 +117,7 @@ e_keyrouter_process_key_event(void *event, int type)
 
    if (ev->data)
      {
-        KLDBG("data is exist send to compositor: %p", ev->data);
+        KLDBG("data is exist send to compositor");
         goto finish;
      }
 
@@ -106,7 +132,7 @@ e_keyrouter_process_key_event(void *event, int type)
        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");
          }
      }
@@ -134,7 +160,7 @@ e_keyrouter_process_key_event(void *event, int type)
    //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;
@@ -405,7 +431,6 @@ _e_keyrouter_send_key_events_focus(int type, struct wl_resource *surface_focus,
         if (ev->data)
           {
              *delivered_surface = ev->data;
-             ev->data = wl_resource_get_client(ev->data);
           }
         return res;
      }
@@ -654,12 +679,19 @@ _e_keyrouter_send_key_event(int type, struct wl_resource *surface, struct wl_cli
      }
    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;
 }
index 0e97f4d..2aec876 100644 (file)
@@ -181,7 +181,7 @@ e_keyrouter_prepend_to_keylist(struct wl_resource *surface, struct wl_client *wc
          break;
 
       case TIZEN_KEYROUTER_MODE_PRESSED:
-         krt->HardKeys[key].press_ptr = eina_list_prepend(krt->HardKeys[key].press_ptr, new_keyptr);
+         krt->HardKeys[key].press_ptr = eina_list_append(krt->HardKeys[key].press_ptr, new_keyptr);
          break;
      case TIZEN_KEYROUTER_MODE_PICTURE_OFF:
          krt->HardKeys[key].pic_off_ptr = eina_list_prepend(krt->HardKeys[key].pic_off_ptr, new_keyptr);
index 90a58e8..5235aae 100644 (file)
@@ -1141,6 +1141,27 @@ _e_keyrouter_max_keycode_get(void)
    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)
 {
@@ -1193,7 +1214,7 @@ _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 !");
@@ -1202,6 +1223,7 @@ _e_keyrouter_init(E_Module *m)
 
    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);