e_seat: Set zone info in associated seat 37/318337/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Fri, 10 Jan 2025 08:40:06 +0000 (17:40 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 16 Jan 2025 00:31:41 +0000 (09:31 +0900)
Change-Id: Ic406603a1d9b81faca4b705465cfa9f2f73a8d83
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/bin/Makefile.mk
src/bin/e_comp_screen.c
src/bin/inputmgr/e_input_backend.c
src/bin/inputmgr/e_input_seat.c
src/bin/inputmgr/e_input_seat_intern.h
src/bin/inputmgr/e_seat.c [new file with mode: 0644]
src/bin/inputmgr/e_seat_intern.h [new file with mode: 0644]
src/include/e_comp_wl.h

index 3e60e46c12d3a2cc56ee25705e54c6f124084c9e..a9ed6748967b6b06d828c06449d7ba0b71f41e44 100644 (file)
@@ -261,6 +261,7 @@ src/bin/inputmgr/e_keyrouter.c \
 src/bin/inputmgr/e_keyrouter_hardkeys.c \
 src/bin/inputmgr/e_grabinput.c \
 src/bin/inputmgr/e_gesture.c \
+src/bin/inputmgr/e_seat.c \
 src/bin/compmgr/e_comp.c \
 src/bin/compmgr/e_comp_canvas.c \
 src/bin/compmgr/e_comp_object.c \
index fd5567e3406e5f09388247228f7b5af8a4dc33c8..bc5fd51be65cbfeaf16bb7ab41d2d9c18a9cde77 100644 (file)
@@ -28,6 +28,7 @@
 #include "e_policy_desk_area_intern.h"
 #include "e_zone_intern.h"
 #include "e_tizen_screen_manager_intern.h"
+#include "e_seat_intern.h"
 
 #include <tizen-extension-server-protocol.h>
 #include <tbm_bufmgr_internal.h>
@@ -1005,6 +1006,10 @@ e_comp_screen_init()
      }
    e_main_ts_end("\tE_Input Init Done");
 
+   e_main_ts_begin("\tE_Seat Init");
+   e_seat_init();
+   e_main_ts_end("\tE_Seat Init Done");
+
    e_main_ts_begin("\tE_Server Init");
    if (!e_server_init())
      {
@@ -1118,6 +1123,7 @@ e_comp_screen_shutdown()
    e_policy_desk_shutdown();
    e_server_shutdown();
    e_input_shutdown();
+   e_seat_shutdown();
 
    /* delete e_comp_sreen */
    _e_comp_screen_del(comp_screen);
index 15a9f99fd90f4a74318d22c99ad6db612995e61c..1e2755ec27aaa09b5e0b912bc2027cf6357e27fc 100644 (file)
@@ -13,6 +13,7 @@
 #include "e_comp_input_intern.h"
 #include "e_utils_intern.h"
 #include "e_input_seat_intern.h"
+#include "e_seat_intern.h"
 
 #include <libudev.h>
 #include <glib.h>
@@ -166,11 +167,28 @@ _e_input_ecore_device_event(Ecore_Device *dev, const char* seat_name, Eina_Bool
      ecore_event_add(ECORE_EVENT_DEVICE_DEL, e, _e_input_ecore_device_info_free, NULL);
 }
 
+static void
+_e_input_seat_info_free(void *data EINA_UNUSED, void *ev)
+{
+   E_Seat_Event_Info *seat_info = ev;
+   EINA_SAFETY_ON_NULL_RETURN(seat_info);
+
+   free(seat_info->seat_name);
+   seat_info->seat_name = NULL;
+   free(seat_info->output_name);
+   seat_info->output_name = NULL;
+
+   E_FREE(seat_info);
+}
+
 static void
 _e_input_seat_ecore_device_create_async_cb(void *data)
 {
    E_Input_Seat *s = data;
    Ecore_Device *ecore_dev = NULL;
+   const char *output_name = NULL;
+   E_Seat_Event_Info *seat_info = NULL;
+   const char *seat_name = NULL;
 
    /* create an evas device of a seat */
    ecore_dev = ecore_device_add();
@@ -187,13 +205,22 @@ _e_input_seat_ecore_device_create_async_cb(void *data)
 
    e_input_seat_ecore_device_set(s, ecore_dev);
 
-   ecore_event_add(E_INPUT_EVENT_SEAT_ADD, NULL, NULL, NULL);
+   seat_info = E_NEW(E_Seat_Event_Info, 1);
+   if (seat_info)
+     {
+        seat_name = e_input_seat_name_get(s);
+        seat_info->seat_name = seat_name ? strdup(seat_name) : NULL;
+        output_name = e_input_seat_output_name_get(s);
+        seat_info->output_name = output_name ? strdup(output_name) : NULL;
+     }
 
    _e_input_ecore_device_event(ecore_dev, e_input_seat_name_get(s), EINA_TRUE);
+
+   ecore_event_add(E_INPUT_EVENT_SEAT_ADD, seat_info, _e_input_seat_info_free, NULL);
 }
 
 static E_Input_Seat *
-_seat_create(E_Input_Backend *input, const char *seat)
+_seat_create(E_Input_Backend *input, const char *seat, const char *output_name)
 {
    E_Input_Seat *s = NULL;
    E_Device *e_dev = NULL;
@@ -206,6 +233,8 @@ _seat_create(E_Input_Backend *input, const char *seat)
         return NULL;
      }
 
+   INF("seatname(%s), output name(%s)", seat, output_name);
+
    e_device_name_set(e_dev, seat);
    e_device_identifier_set(e_dev, "Enlightenment seat");
    e_device_seatname_set(e_dev, seat);
@@ -213,7 +242,7 @@ _seat_create(E_Input_Backend *input, const char *seat)
    e_device_subclass_set(e_dev, ECORE_DEVICE_SUBCLASS_NONE);
 
    /* try to allocate space for new seat */
-   if (!(s = e_input_seat_create(input, seat, e_dev, input->dev)))
+   if (!(s = e_input_seat_create(input, seat, output_name, e_dev, input->dev)))
      {
         return NULL;
      }
@@ -227,17 +256,20 @@ _seat_create(E_Input_Backend *input, const char *seat)
 }
 
 static E_Input_Seat *
-_seat_get(E_Input_Backend *input, const char *seat)
+_seat_get(E_Input_Backend *input, const char *seat, const char *output_name)
 {
    E_Input_Seat *s;
    Eina_List *l;
 
    /* search for this name in existing seats */
    EINA_LIST_FOREACH(input->dev->seats, l, s)
-     if (!strcmp(e_input_seat_name_get(s), seat))
-       return s;
+     {
+        const char *seat_name = e_input_seat_name_get(s);
+        if (seat_name && !strcmp(seat_name, seat))
+          return s;
+     }
 
-   return _seat_create(input, seat);
+   return _seat_create(input, seat, output_name);
 }
 
 static void
@@ -660,14 +692,16 @@ _device_added(E_Input_Backend *input, struct libinput_device *device)
 {
    struct libinput_seat *libinput_seat;
    const char *seat_name;
+   const char *output_name = NULL;
    E_Input_Seat *seat;
    E_Input_Evdev *evdev;
 
    libinput_seat = libinput_device_get_seat(device);
+   output_name = libinput_device_get_output_name(device);
    seat_name = libinput_seat_get_logical_name(libinput_seat);
 
    /* try to get a seat */
-   if (!(seat = _seat_get(input, seat_name)))
+   if (!(seat = _seat_get(input, seat_name, output_name)))
      {
         ERR("Could not get matching seat: %s", seat_name);
         return;
index 06761d512d75b3a2bbb06c13e2c396bd7fff2d1a..8d7dcf6502e755433a6f9e2c9a238c175aa6f875 100644 (file)
@@ -4,6 +4,7 @@
 struct _E_Input_Seat
 {
    const char *name;
+   const char *output_name;
    E_Input_Backend *input;
    E_Input_Device *dev;
    Eina_List *devices;
@@ -22,7 +23,7 @@ struct _E_Input_Seat
 };
 
 EINTERN E_Input_Seat *
-e_input_seat_create(E_Input_Backend *input, const char *seatname, E_Device *edev, E_Input_Device *dev)
+e_input_seat_create(E_Input_Backend *input, const char *seatname, const char *output_name, E_Device *edev, E_Input_Device *dev)
 {
    E_Input_Seat *seat = NULL;
    seat = calloc(1, sizeof(E_Input_Seat));
@@ -30,6 +31,7 @@ e_input_seat_create(E_Input_Backend *input, const char *seatname, E_Device *edev
 
    seat->input = input;
    seat->name = eina_stringshare_add(seatname);
+   seat->output_name = eina_stringshare_add(output_name);
    seat->e_dev = edev;
    seat->dev = dev;
 
@@ -50,6 +52,9 @@ e_input_seat_destroy(E_Input_Seat *seat)
    if (seat->name)
      eina_stringshare_del(seat->name);
 
+   if (seat->output_name)
+     eina_stringshare_del(seat->output_name);
+
    free(seat);
 }
 
@@ -69,6 +74,14 @@ e_input_seat_name_get(E_Input_Seat *seat)
   return seat->name;
 }
 
+EINTERN const char *
+e_input_seat_output_name_get(E_Input_Seat *seat)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(seat, NULL);
+
+   return seat->output_name;
+}
+
 EINTERN E_Input_Device *
 e_input_seat_dev_get(E_Input_Seat *seat)
 {
index 72ec17abc620c8b36ad7647c5ff02d2daaa13e0e..45ad36fa57bae8c754500aaa80e7daecfadd1bef 100644 (file)
@@ -7,7 +7,7 @@
 
 typedef struct _E_Input_Seat  E_Input_Seat;
 
-EINTERN E_Input_Seat    *e_input_seat_create(E_Input_Backend *input, const char *seatname, E_Device *edev, E_Input_Device *dev);
+EINTERN E_Input_Seat    *e_input_seat_create(E_Input_Backend *input, const char *seatname, const char *output_name, E_Device *edev, E_Input_Device *dev);
 EINTERN void             e_input_seat_destroy(E_Input_Seat *seat);
 
 EINTERN void             e_input_seat_ecore_device_set(E_Input_Seat *seat, Ecore_Device *dev);
@@ -15,6 +15,8 @@ EINTERN void             e_input_seat_ecore_device_set(E_Input_Seat *seat, Ecore
 EINTERN const char      *e_input_seat_name_get(E_Input_Seat *seat);
 EINTERN void             e_input_seat_name_unset(E_Input_Seat *seat);
 
+EINTERN const char      *e_input_seat_output_name_get(E_Input_Seat *seat);
+
 EINTERN E_Input_Device  *e_input_seat_dev_get(E_Input_Seat *seat);
 
 EINTERN E_Input_Backend *e_input_seat_input_get(E_Input_Seat *seat);
diff --git a/src/bin/inputmgr/e_seat.c b/src/bin/inputmgr/e_seat.c
new file mode 100644 (file)
index 0000000..0f99c2b
--- /dev/null
@@ -0,0 +1,52 @@
+#include "e_seat_intern.h"
+#include "e_input_seat_intern.h"
+#include "e_comp_intern.h"
+#include "e_comp_wl_input_intern.h"
+
+static Eina_List *_ecore_event_handlers = NULL;
+
+static Eina_Bool
+_e_seat_cb_seat_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
+{
+   E_Seat_Event_Info *ei = event;
+   E_Seat *seat = NULL;
+   E_Zone *zone = NULL;
+
+   seat = e_comp_wl_input_seat_get(ei->seat_name);
+   if (!seat) return ECORE_CALLBACK_PASS_ON;
+
+   if (ei->output_name)
+     zone = e_comp_zone_find(ei->output_name);
+   else
+     zone = e_comp_default_zone_get(e_comp_get());
+
+   if (seat)
+     seat->zone = zone;
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+EINTERN void
+e_seat_init()
+{
+   E_LIST_HANDLER_APPEND(_ecore_event_handlers, E_INPUT_EVENT_SEAT_ADD, _e_seat_cb_seat_add, NULL);
+}
+
+EINTERN void
+e_seat_shutdown()
+{
+   Ecore_Event_Handler *h = NULL;
+
+   EINA_LIST_FREE(_ecore_event_handlers, h)
+      ecore_event_handler_del(h);
+
+   _ecore_event_handlers = NULL;
+}
+
+EINTERN E_Zone *
+e_seat_zone_get(E_Seat *seat)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(seat, NULL);
+
+   return seat->zone;
+}
diff --git a/src/bin/inputmgr/e_seat_intern.h b/src/bin/inputmgr/e_seat_intern.h
new file mode 100644 (file)
index 0000000..7d2323d
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef E_SEAT_INTERN_H
+#define E_SEAT_INTERN_H
+
+#include "e_intern.h"
+
+typedef struct _E_Seat_Event_Info E_Seat_Event_Info;
+
+struct _E_Seat_Event_Info
+{
+    char *seat_name;
+    char *output_name;
+};
+
+EINTERN void        e_seat_init();
+EINTERN void        e_seat_shutdown();
+EINTERN E_Zone     *e_seat_zone_get(E_Seat *seat);
+
+#endif // E_SEAT_INTERN_H
index e9d4ca79197578e190d9a5efea15722fffa5e1a6..33c398c06034eda0747fab7b7661b5bff5341426 100644 (file)
@@ -553,6 +553,8 @@ struct _E_Seat
         Eina_Bool enabled : 1;
         unsigned int num_devices;
      } touch;
+
+   E_Zone *zone;
 };
 
 struct _E_Comp_Wl_Hook