e_comp_wl: refactoring code of sending event_device 72/323972/2
authorduna.oh <duna.oh@samsung.com>
Fri, 9 May 2025 04:06:53 +0000 (13:06 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Mon, 12 May 2025 04:28:16 +0000 (04:28 +0000)
Sending event_device of tizen_input_device is unrelated to the list of
keyboard resources. Moving the code outside the 'for' loop simplifies
the code structure.

Change-Id: Ie3a5d9d37294e5d8d5e037c529a5cb849e8edcc2

src/bin/server/e_comp_wl.c

index 33a0a730b4eea1aae27ed8c1c3803402af14bb15..9dba2bc2669426985ac9bd3df1f3ceab3fd813fd 100644 (file)
@@ -4042,25 +4042,25 @@ _e_comp_wl_key_send(Ecore_Event_Key *ev, E_Device *dev, enum wl_keyboard_key_sta
         ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname);
      }
 
+   if (!e_input_thread_mode_get())
+     {
+        _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
+        device_name = ecore_device_name_get(ev->dev);
+     }
+   else
+     {
+        if (dev)
+          {
+             _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
+             device_name = e_device_name_get(dev);
+          }
+     }
+
    EINA_LIST_FOREACH(key_list, l, res)
      {
         if (wl_resource_get_client(res) != wc) continue;
 
         TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
-        if (!e_input_thread_mode_get())
-          {
-             _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
-             device_name = ecore_device_name_get(ev->dev);
-          }
-        else
-          {
-             if (dev)
-               {
-                  _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
-                  device_name = e_device_name_get(dev);
-               }
-          }
-
         if (comp_conf && comp_conf->input_log_enable)
           ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
 
@@ -4844,31 +4844,31 @@ e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint
         ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode);
      }
 
-   g_rec_mutex_lock(&e_comp_input_key->kbd.resources_mutex);
-   EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
+   if (!e_input_thread_mode_get())
      {
-        if (wl_resource_get_client(res) != wc) continue;
-        if (!e_input_thread_mode_get())
+        if (dev)
           {
-             if (dev)
-               {
-                  _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
-                  dev_name = ecore_device_name_get((Ecore_Device *)dev);
-               }
-             else
-               {
-                  _e_comp_wl_device_send_last_event_device(comp_wl, ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
-               }
+             _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
+             dev_name = ecore_device_name_get((Ecore_Device *)dev);
           }
         else
           {
-             if (dev)
-               {
-                  e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
-                  dev_name = e_device_name_get(dev);
-               }
+             _e_comp_wl_device_send_last_event_device(comp_wl, ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
           }
+     }
+   else
+     {
+        if (dev)
+          {
+             e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
+             dev_name = e_device_name_get(dev);
+          }
+     }
 
+   g_rec_mutex_lock(&e_comp_input_key->kbd.resources_mutex);
+   EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
+     {
+        if (wl_resource_get_client(res) != wc) continue;
         if (comp_conf && comp_conf->input_log_enable)
           ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
                 dev_name);
@@ -4929,13 +4929,13 @@ e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time
    e_input_thread_request_boost();
    e_keyrouter_wl_event_surface_send(surface, wl_keycode, TIZEN_KEYROUTER_MODE_NONE);
 
+   if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
+   else _e_comp_wl_device_send_last_event_device(comp_wl, ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
+
    g_rec_mutex_lock(&e_comp_input_key->kbd.resources_mutex);
    EINA_LIST_FOREACH(e_comp_input_key->kbd.resources, l, res)
      {
         if (wl_resource_get_client(res) != wc) continue;
-        if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
-        else _e_comp_wl_device_send_last_event_device(comp_wl, ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
-
         if (comp_conf && comp_conf->input_log_enable)
           ELOGF("Key", "Send Key Cancel (time: %d)", ec, time);
         wl_keyboard_send_key(res, serial, time,