From 58df2ec2efbb53ae8e803525c09ee973bb9dd228 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Sat, 11 Jan 2025 17:20:04 +0900 Subject: [PATCH] e_seat: Encapsulate E_Seat structure Change-Id: I49aa56d0ed80cbd4b591fa405605657b4664fd0a Signed-off-by: Jihoon Kim --- src/bin/e_comp_screen.c | 17 +++-- src/bin/inputmgr/e_seat.c | 73 +++++++++++++++++++ src/bin/inputmgr/e_seat_intern.h | 10 +++ src/bin/server/e_comp_wl_input.c | 12 ++- src/bin/server/e_comp_wl_input_intern.h | 1 + src/bin/server/e_comp_wl_intern.h | 1 + src/bin/server/e_devicemgr_wl.c | 6 +- src/bin/windowmgr/services/e_service_volume.c | 2 +- src/include/e_comp_wl.h | 24 ------ 9 files changed, 108 insertions(+), 38 deletions(-) diff --git a/src/bin/e_comp_screen.c b/src/bin/e_comp_screen.c index fccbcbb5ec..762cb7eaae 100644 --- a/src/bin/e_comp_screen.c +++ b/src/bin/e_comp_screen.c @@ -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); } diff --git a/src/bin/inputmgr/e_seat.c b/src/bin/inputmgr/e_seat.c index 0857ad4e43..21ad046e02 100644 --- a/src/bin/inputmgr/e_seat.c +++ b/src/bin/inputmgr/e_seat.c @@ -10,6 +10,29 @@ #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; +} diff --git a/src/bin/inputmgr/e_seat_intern.h b/src/bin/inputmgr/e_seat_intern.h index 897fd309c5..98ea12d1fa 100644 --- a/src/bin/inputmgr/e_seat_intern.h +++ b/src/bin/inputmgr/e_seat_intern.h @@ -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 diff --git a/src/bin/server/e_comp_wl_input.c b/src/bin/server/e_comp_wl_input.c index 5668227907..ee9a49bf08 100644 --- a/src/bin/server/e_comp_wl_input.c +++ b/src/bin/server/e_comp_wl_input.c @@ -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); diff --git a/src/bin/server/e_comp_wl_input_intern.h b/src/bin/server/e_comp_wl_input_intern.h index 27ae512145..fc3c4c2722 100644 --- a/src/bin/server/e_comp_wl_input_intern.h +++ b/src/bin/server/e_comp_wl_input_intern.h @@ -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); diff --git a/src/bin/server/e_comp_wl_intern.h b/src/bin/server/e_comp_wl_intern.h index cf90ac027f..984af5883e 100644 --- a/src/bin/server/e_comp_wl_intern.h +++ b/src/bin/server/e_comp_wl_intern.h @@ -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 diff --git a/src/bin/server/e_devicemgr_wl.c b/src/bin/server/e_devicemgr_wl.c index 5cdea5c109..c598bb8c3a 100644 --- a/src/bin/server/e_devicemgr_wl.c +++ b/src/bin/server/e_devicemgr_wl.c @@ -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; diff --git a/src/bin/windowmgr/services/e_service_volume.c b/src/bin/windowmgr/services/e_service_volume.c index fdbcdca059..7e03275543 100644 --- a/src/bin/windowmgr/services/e_service_volume.c +++ b/src/bin/windowmgr/services/e_service_volume.c @@ -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; diff --git a/src/include/e_comp_wl.h b/src/include/e_comp_wl.h index 920ae9ba3f..7dcd615e25 100644 --- a/src/include/e_comp_wl.h +++ b/src/include/e_comp_wl.h @@ -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; -- 2.34.1