keyrouter: add a check if focus client is changed while processing key events 51/323751/1
authorduna.oh <duna.oh@samsung.com>
Wed, 7 May 2025 05:56:06 +0000 (14:56 +0900)
committerduna.oh <duna.oh@samsung.com>
Wed, 7 May 2025 05:56:06 +0000 (14:56 +0900)
Change-Id: Ibd7b30fe9fe83d0263f8a864efc0dcb70a1bd9a7

src/bin/inputmgr/e_keyrouter.c
src/bin/inputmgr/e_keyrouter_events.c
src/bin/inputmgr/e_keyrouter_intern.h

index 95fe4a9f1cbdff13ace27a751525a8ba9d8e2db7..64135b4627f8094601c1b40752bea5ada51d9797 100644 (file)
@@ -187,7 +187,7 @@ _e_keyrouter_input_thread_keygrab_print(void *data)
    fprintf(log_fl, "    ----- Focus Window Info -----\n");
    if (ec_focus)
      {
-        surface_focus = e_keyrouter_util_get_surface_from_eclient(ec_focus);
+        surface_focus = e_comp_wl_client_surface_get(ec_focus);
         if (surface_focus)
           {
              wc_focus = wl_resource_get_client(surface_focus);
index c93adc9718972127be33fb7de3f06e1fe0f2a641..ceb0d71aeec3da24b4b1b351a881392928db8dcb 100644 (file)
@@ -667,7 +667,7 @@ _e_keyrouter_send_key_events_press(int type, Ecore_Event_Key *ev, E_Device *dev)
    Eina_List *shared_ptr_list = NULL;
 
    ec_focus = e_client_focused_get();
-   surface_focus = e_keyrouter_util_get_surface_from_eclient(ec_focus);
+   surface_focus = e_comp_wl_client_surface_get(ec_focus);
 
    if (!_e_keyrouter_is_key_grabbed(ev->keycode))
      {
@@ -782,6 +782,11 @@ _e_keyrouter_send_key_events_press(int type, Ecore_Event_Key *ev, E_Device *dev)
    if (shared_ptr_list)
      {
 need_shared:
+        if (ec_focus != e_client_focused_get())
+          {
+            KLWRN("focused ec is changed from (%p). no key events to focus client and shared", ec_focus);
+            surface_focus = NULL;
+          }
         res = _e_keyrouter_send_key_events_focus(type, surface_focus, ev, dev, &delivered_surface);
         if (delivered_surface)
           {
@@ -865,6 +870,8 @@ _e_keyrouter_send_key_events_focus(int type, struct wl_resource *surface_focus,
         return EINA_FALSE;
      }
 
+   if (!surface_focus) return res;
+
    pid = e_keyrouter_util_get_pid(NULL, surface_focus);
    cmd = e_keyrouter_util_cmd_get_from_pid(pid);
    pname = e_keyrouter_util_process_name_get_from_cmd(cmd);
@@ -970,14 +977,6 @@ _e_keyrouter_send_key_event(int type, struct wl_resource *surface, struct wl_cli
    return;
 }
 
-struct wl_resource *
-e_keyrouter_util_get_surface_from_eclient(E_Client *client)
-{
-   if (!client || !client->comp_data) return NULL;
-
-   return client->comp_data->wl_surface;
-}
-
 int
 e_keyrouter_util_get_pid(struct wl_client *client, struct wl_resource *surface)
 {
index 478b0adc91732b65f0b74ad4f6fe183eb8340447..2f0e05dc25f5c4e36599442f66c36a59840ef0b0 100644 (file)
@@ -163,7 +163,6 @@ EINTERN void e_keyrouter_remove_client_from_list(struct wl_resource *surface, st
 EINTERN int e_keyrouter_find_key_in_list(struct wl_resource *surface, struct wl_client *wc, uint32_t key);
 EINTERN Eina_Bool e_keyrouter_process_key_event(void *event, int type);
 
-EINTERN struct wl_resource *e_keyrouter_util_get_surface_from_eclient(E_Client *client);
 EINTERN int                 e_keyrouter_util_get_pid(struct wl_client *client, struct wl_resource *surface);
 EINTERN char               *e_keyrouter_util_cmd_get_from_pid(int pid);
 EINTERN char               *e_keyrouter_util_process_name_get_from_cmd(char *cmd);