e_seat: Encapsulate E_Seat structure 47/318447/2 accepted/tizen/unified/20250120.004729 accepted/tizen/unified/x/20250120.014721
authorJihoon Kim <jihoon48.kim@samsung.com>
Sat, 11 Jan 2025 08:20:04 +0000 (17:20 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Fri, 17 Jan 2025 06:09:36 +0000 (06:09 +0000)
Change-Id: I49aa56d0ed80cbd4b591fa405605657b4664fd0a
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/bin/e_comp_screen.c
src/bin/inputmgr/e_seat.c
src/bin/inputmgr/e_seat_intern.h
src/bin/server/e_comp_wl_input.c
src/bin/server/e_comp_wl_input_intern.h
src/bin/server/e_comp_wl_intern.h
src/bin/server/e_devicemgr_wl.c
src/bin/windowmgr/services/e_service_volume.c
src/include/e_comp_wl.h

index fccbcbb5ec0e936f8ddd8c136936e8801fb4c349..762cb7eaae77ffb54980e464b0564602b3884d0e 100644 (file)
@@ -314,12 +314,13 @@ _e_comp_screen_cb_input_device_add(void *data, int type, void *event)
 
    if (e->clas == ECORE_DEVICE_CLASS_MOUSE)
      {
-        if (seat->ptr.num_devices == 0)
+        if (e_seat_pointer_device_count(seat) == 0)
           {
              e_pointer_view_set(comp->pointer, NULL, 0, 0);
              e_seat_pointer_enabled_set(seat, EINA_TRUE);
           }
-        seat->ptr.num_devices++;
+
+        e_seat_pointer_device_count_increase(seat);
      }
    else if (e->clas == ECORE_DEVICE_CLASS_KEYBOARD)
      {
@@ -335,7 +336,7 @@ _e_comp_screen_cb_input_device_add(void *data, int type, void *event)
         e_seat_touch_enabled_set(seat, EINA_TRUE);
         if (comp_screen)
           _e_comp_screen_input_rotation_set(comp_screen->rotation);
-        seat->touch.num_devices++;
+        e_seat_touch_device_count_increase(seat);
      }
 
 end:
@@ -348,7 +349,7 @@ _e_comp_screen_pointer_renew(E_Seat *seat)
    E_Comp_Wl_Data *comp_wl;
 
    comp_wl = e_comp_wl_get();
-   if ((seat->ptr.num_devices == 0) && comp_wl->ptr.ec && comp_wl->ptr.ec->pointer_enter_sent)
+   if ((e_seat_pointer_device_count(seat) == 0) && comp_wl->ptr.ec && comp_wl->ptr.ec->pointer_enter_sent)
      {
         if (e_devicemgr->last_device_ptr)
           {
@@ -393,8 +394,8 @@ _e_comp_screen_cb_input_device_del(void *data, int type, void *event)
 
    if (e->clas == ECORE_DEVICE_CLASS_MOUSE)
      {
-        seat->ptr.num_devices--;
-        if (seat->ptr.num_devices == 0)
+        e_seat_pointer_device_count_decrease(seat);
+        if (e_seat_pointer_device_count(seat) == 0)
           {
              e_seat_pointer_enabled_set(seat, EINA_FALSE);
              e_pointer_view_set(comp->pointer, NULL, 0, 0);
@@ -405,8 +406,8 @@ _e_comp_screen_cb_input_device_del(void *data, int type, void *event)
      }
    else if (e->clas == ECORE_DEVICE_CLASS_TOUCH)
      {
-        seat->touch.num_devices--;
-        if (seat->touch.num_devices == 0)
+        e_seat_touch_device_count_decrease(seat);
+        if (e_seat_touch_device_count(seat) == 0)
           {
              e_seat_touch_enabled_set(seat, EINA_FALSE);
           }
index 0857ad4e43321f7abf2454068d402b7126b6c38e..21ad046e024de0a71e65e09d124e75c84a15deb2 100644 (file)
 #include "e_policy_intern.h"
 #include "e_utils_intern.h"
 
+struct _E_Seat
+{
+   struct wl_global *global;
+   Eina_List *resources;
+   uint32_t version;
+   char *name;
+   struct
+     {
+        Eina_List *resources;
+        Eina_Bool enabled : 1;
+        unsigned int num_devices;
+     } ptr;
+
+   struct
+     {
+        Eina_List *resources;
+        Eina_Bool enabled : 1;
+        unsigned int num_devices;
+     } touch;
+
+   E_Zone *zone;
+};
+
 static Eina_List *_ecore_event_handlers = NULL;
 static Eina_List *_seats = NULL;
 
@@ -607,6 +630,8 @@ e_seat_update_seat_caps(E_Seat *seat, struct wl_client *wc)
    if (!seat)
      seat = e_seat_find("default");
 
+   EINA_SAFETY_ON_NULL_RETURN(seat);
+
    if (seat->ptr.enabled)
      caps |= WL_SEAT_CAPABILITY_POINTER;
    if (e_comp_input_key->kbd.enabled)
@@ -813,6 +838,30 @@ e_seat_touch_check(struct wl_resource *res)
                                   &_e_touch_interface);
 }
 
+EINTERN unsigned int
+e_seat_touch_device_count(E_Seat *seat)
+{
+   return seat->touch.num_devices;
+}
+
+EINTERN void
+e_seat_touch_device_count_increase(E_Seat *seat)
+{
+   seat->touch.num_devices++;
+}
+
+EINTERN void
+e_seat_touch_device_count_decrease(E_Seat *seat)
+{
+   seat->touch.num_devices--;
+}
+
+EINTERN Eina_List *
+e_seat_touch_resources_get(E_Seat *seat)
+{
+   return seat->touch.resources;
+}
+
 EINTERN void
 e_seat_pointer_send_motion(E_Seat *seat, struct wl_client *wc,
                            int x, int y, uint32_t timestamp)
@@ -1063,6 +1112,24 @@ e_seat_pointer_check(struct wl_resource *res)
                                   &_e_pointer_interface);
 }
 
+EINTERN unsigned int
+e_seat_pointer_device_count(E_Seat *seat)
+{
+   return seat->ptr.num_devices;
+}
+
+EINTERN void
+e_seat_pointer_device_count_increase(E_Seat *seat)
+{
+   seat->ptr.num_devices++;
+}
+
+EINTERN void
+e_seat_pointer_device_count_decrease(E_Seat *seat)
+{
+   seat->ptr.num_devices--;
+}
+
 EINTERN Eina_Bool
 e_seat_keyboard_check(struct wl_resource *res)
 {
@@ -1079,3 +1146,9 @@ e_seat_destroy_all()
        e_seat_destroy(seat);
     }
 }
+
+EINTERN Eina_List *
+e_seat_resources_get(E_Seat *seat)
+{
+   return seat->resources;
+}
index 897fd309c5da978143a3f7315aea71a674023248..98ea12d1fad18790ef0de4162755bf903c3496ca 100644 (file)
@@ -4,6 +4,7 @@
 #include "e_intern.h"
 
 typedef struct _E_Seat_Event_Info E_Seat_Event_Info;
+typedef struct _E_Seat E_Seat;
 
 struct _E_Seat_Event_Info
 {
@@ -34,6 +35,10 @@ EINTERN void        e_seat_touch_send_frame(E_Seat *seat, struct wl_client *wc);
 EINTERN void        e_seat_touch_enabled_set(E_Seat *seat, Eina_Bool enabled);
 EINTERN Eina_Bool   e_seat_touch_is_empty(E_Seat *seat);
 EINTERN Eina_Bool   e_seat_touch_check(struct wl_resource *res);
+EINTERN unsigned int e_seat_touch_device_count(E_Seat *seat);
+EINTERN void        e_seat_touch_device_count_increase(E_Seat *seat);
+EINTERN void        e_seat_touch_device_count_decrease(E_Seat *seat);
+EINTERN Eina_List  *e_seat_touch_resources_get(E_Seat *seat);
 
 EINTERN void        e_seat_pointer_send_motion(E_Seat *seat, struct wl_client *wc,
                                                int x, int y, unsigned int timestamp);
@@ -49,7 +54,12 @@ EINTERN void        e_seat_pointer_enabled_set(E_Seat *seat, Eina_Bool enabled);
 EINTERN Eina_Bool   e_seat_pointer_enabled_get(E_Seat *seat);
 EINTERN Eina_Bool   e_seat_pointer_is_empty(E_Seat *seat);
 EINTERN Eina_Bool   e_seat_pointer_check(struct wl_resource *res);
+EINTERN unsigned int e_seat_pointer_device_count(E_Seat *seat);
+EINTERN void        e_seat_pointer_device_count_increase(E_Seat *seat);
+EINTERN void        e_seat_pointer_device_count_decrease(E_Seat *seat);
 
 EINTERN Eina_Bool   e_seat_keyboard_check(struct wl_resource *res);
 
+EINTERN Eina_List  *e_seat_resources_get(E_Seat *seat);
+
 #endif // E_SEAT_INTERN_H
index 56682279075a9e0e0d1d5033ef75e332feab4e68..ee9a49bf08d228f26204e675a4ef132e61ef0695 100644 (file)
@@ -1632,11 +1632,19 @@ e_comp_wl_input_seat_caps_set(unsigned int caps)
    seat = e_seat_find("default");
 
    if (caps & E_INPUT_SEAT_POINTER)
-     seat->ptr.enabled = need_update = EINA_TRUE;
+     {
+        need_update = EINA_TRUE;
+        e_seat_pointer_enabled_set(seat, need_update);
+     }
+
    if (caps & E_INPUT_SEAT_KEYBOARD)
      e_comp_input_key->kbd.enabled = need_update = EINA_TRUE;
+
    if (caps & E_INPUT_SEAT_TOUCH)
-     seat->touch.enabled = need_update = EINA_TRUE;
+     {
+        need_update = EINA_TRUE;
+        e_seat_touch_enabled_set(seat, need_update);
+     }
 
    if (need_update)
      e_seat_update_seat_caps(seat, NULL);
index 27ae512145145e89c9c8957a73eb2b273ab563de..fc3c4c27220f48a8af8048b75768e5675f7bbde3 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "e_intern.h"
 #include "e_comp_wl_input.h"
+#include "e_seat_intern.h"
 
 EINTERN Eina_Bool e_comp_wl_input_init(void);
 EINTERN void      e_comp_wl_input_shutdown(void);
index cf90ac027fa54ce745298f8f0d7c906c85d11ff1..984af5883e7f449e0c2e545a6094dd7074311d9f 100644 (file)
@@ -6,6 +6,7 @@
 #include "e_policy_wl.h"
 #include "e_device_intern.h"
 #include "e_compositor_intern.h"
+#include "e_seat_intern.h"
 
 #include <pixman.h>
 
index 5cdea5c109d3303632a82b479c7bbfc12d7cedea..c598bb8c3a4ce33e45693994716df8af0bd988b6 100644 (file)
@@ -191,7 +191,7 @@ e_devicemgr_wl_device_add(E_Devicemgr_Input_Device *dev)
    serial = wl_display_next_serial(comp_wl->wl.disp);
    wl_array_init(&axes);
 
-   EINA_LIST_FOREACH(seat->resources, l, seat_res)
+   EINA_LIST_FOREACH(e_seat_resources_get(seat), l, seat_res)
      {
         wc = wl_resource_get_client(seat_res);
 
@@ -341,7 +341,7 @@ e_devicemgr_wl_touch_max_count_send(int slot, struct wl_resource *res, struct wl
         Eina_List *lll;
         EINA_LIST_FOREACH(e_seat_list_get(), lll, seat)
           {
-             EINA_LIST_FOREACH(seat->resources, l, seat_resource)
+             EINA_LIST_FOREACH(e_seat_resources_get(seat), l, seat_resource)
                {
                   wc = wl_resource_get_client(seat_resource);
 
@@ -754,7 +754,7 @@ _e_devicemgr_wl_cb_bind(struct wl_client *client, void *data, uint32_t version,
    Eina_List *lll;
    EINA_LIST_FOREACH(e_seat_list_get(), lll, seat)
      {
-        EINA_LIST_FOREACH(seat->resources, l, seat_res)
+        EINA_LIST_FOREACH(e_seat_resources_get(seat), l, seat_res)
           {
              if (wl_resource_get_client(seat_res) != client) continue;
 
index fdbcdca059dd6b6ea61b6bd81edd0491100cb550..7e03275543377da872cbc924808d63594553b20a 100644 (file)
@@ -459,7 +459,7 @@ _volume_wl_touch_resource_get(void)
    wc = wl_resource_get_client(volume_cdata->surface);
    EINA_LIST_FOREACH(e_seat_list_get(), l, seat)
      {
-        EINA_LIST_FOREACH(seat->touch.resources, ll, res)
+        EINA_LIST_FOREACH(e_seat_touch_resources_get(seat), ll, res)
           {
              if (wl_resource_get_client(res) != wc) continue;
 
index 920ae9ba3f9263c62c2c72825ecf5969343ab252..7dcd615e2575191903b5eb70a4b8a5fd23c78f97 100644 (file)
@@ -59,7 +59,6 @@ typedef struct _E_Comp_Wl_Data E_Comp_Wl_Data;
 typedef struct _E_Comp_Wl_Output E_Comp_Wl_Output;
 typedef struct _E_Comp_Wl_Intercept_Hook E_Comp_Wl_Intercept_Hook;
 typedef struct _E_Comp_Wl_Pointer_Constraint E_Comp_Wl_Pointer_Constraint;
-typedef struct _E_Seat E_Seat;
 
 typedef enum _E_Comp_Wl_Buffer_Type
 {
@@ -534,29 +533,6 @@ struct _E_Comp_Wl_Output
    void *data;
 };
 
-struct _E_Seat
-{
-   struct wl_global *global;
-   Eina_List *resources;
-   uint32_t version;
-   char *name;
-   struct
-     {
-        Eina_List *resources;
-        Eina_Bool enabled : 1;
-        unsigned int num_devices;
-     } ptr;
-
-   struct
-     {
-        Eina_List *resources;
-        Eina_Bool enabled : 1;
-        unsigned int num_devices;
-     } touch;
-
-   E_Zone *zone;
-};
-
 struct _E_Comp_Wl_Hook
 {
    EINA_INLIST;