From: duna.oh Date: Mon, 17 Mar 2025 05:32:15 +0000 (+0900) Subject: e_comp_wl: find the focused ec of seat's zone where key events comes from X-Git-Tag: accepted/tizen/unified/20250320.120248~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F36%2F321336%2F1;p=platform%2Fupstream%2Fenlightenment.git e_comp_wl: find the focused ec of seat's zone where key events comes from Change-Id: Ibfe1e6f9627e97afb90d8b48e6b7445a63caadd9 --- diff --git a/src/bin/inputmgr/e_keyrouter_events.c b/src/bin/inputmgr/e_keyrouter_events.c index c8e54e351f..2635bc9504 100644 --- a/src/bin/inputmgr/e_keyrouter_events.c +++ b/src/bin/inputmgr/e_keyrouter_events.c @@ -9,6 +9,7 @@ #include "e_client_intern.h" #include "e_keyrouter_wl_intern.h" #include "e_keyrouter_hardkeys_intern.h" +#include "e_zone_intern.h" #include @@ -356,11 +357,21 @@ _e_keyrouter_send_key_events_press(int type, Ecore_Event_Key *ev, E_Device *dev) Eina_Bool res; int ret = 0; int key_event_log_type; + const char *seat_name = NULL; + E_Seat *seat; + E_Zone *zone = NULL; E_Keyrouter_Key_List_NodePtr key_node_data; Eina_List *l = NULL, *shared_ptr_list = NULL; - ec_focus = e_client_focused_get(); + seat_name = e_device_seatname_get(dev); + if ((seat_name) && (seat = e_seat_find(seat_name))) + zone = e_seat_zone_get(seat); + if (!zone) + zone = e_comp_default_zone_get(e_comp_get()); + + ec_focus = e_zone_focused_client_get(zone); + ELOGF("KRT", "Key Process. seat:%s zone_id:%d", ec_focus, seat_name, e_zone_id_get(zone)); surface_focus = e_comp_wl_client_surface_get(ec_focus); g_rec_mutex_lock(&krt->grab_key_mutex); diff --git a/src/bin/server/e_comp_wl.c b/src/bin/server/e_comp_wl.c index bcac8cfe6e..aa08f08ae5 100644 --- a/src/bin/server/e_comp_wl.c +++ b/src/bin/server/e_comp_wl.c @@ -48,6 +48,7 @@ #include "e_comp_wl_input_thread_intern.h" #include "e_seat_intern.h" #include "e_surface_view_intern.h" +#include "e_zone_intern.h" #include #include @@ -77,6 +78,7 @@ */ typedef struct _E_Comp_Data E_Comp_Data; +typedef struct _E_Comp_Wl_Focus_Private_Client E_Comp_Wl_Focus_Private_Client; struct _E_Comp_Data { @@ -93,6 +95,15 @@ typedef struct _E_Comp_Wl_Key_Data Ecore_Device *dev; } E_Comp_Wl_Key_Data; +struct _E_Comp_Wl_Focus_Private_Client +{ + E_Client *ec; + + struct wl_listener client_destroy; + struct wl_listener focus_set; + struct wl_listener focus_unset; +}; + static Eina_List *handlers = NULL; static E_Client *cursor_timer_ec = NULL; static Eina_Bool need_send_released = EINA_FALSE; @@ -348,6 +359,7 @@ e_comp_wl_focused_client_flush() e_input_thread_boost_unlock(&connection_mutex); } + static void _e_comp_wl_cb_prepare(void *data EINA_UNUSED, Ecore_Fd_Handler *hdlr EINA_UNUSED) { @@ -2118,12 +2130,6 @@ e_comp_wl_feed_focus_in(E_Client *ec) /* raise client priority */ _e_comp_wl_client_priority_raise(ec); - struct wl_resource *surface = e_comp_wl_client_surface_get(ec); - if (!surface) return; - - INF("send focus in request to input thread. surface(%p)\n", surface); - _e_comp_wl_input_thread_focus_in(&surface); - ec->comp_data->on_focus_timer = ecore_timer_add(((e_config->xkb.delay_held_key_input_to_focus)/1000.0), (Ecore_Task_Cb)_e_comp_wl_evas_cb_focus_in_timer, ec); @@ -2201,10 +2207,6 @@ _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *ob /* lower client priority */ if (!e_object_is_del(data)) _e_comp_wl_client_priority_normal(ec); - - struct wl_resource *surface = e_comp_wl_client_surface_get(ec); - INF("send focus out request to input thread. surface(%p)\n", surface); - _e_comp_wl_input_thread_focus_out(&surface); } static void @@ -2306,6 +2308,88 @@ _e_comp_wl_cb_randr_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *e return ECORE_CALLBACK_RENEW; } +static void +_e_comp_wl_focus_client_del(E_Comp_Wl_Focus_Private_Client *kbd_focus_client) +{ + wl_list_remove(&kbd_focus_client->client_destroy.link); + wl_list_remove(&kbd_focus_client->focus_set.link); + wl_list_remove(&kbd_focus_client->focus_unset.link); + + E_FREE(kbd_focus_client); +} + + +static void +_e_comp_wl_focus_client_cb_client_destroy(struct wl_listener *listener, void *data) +{ + E_Comp_Wl_Focus_Private_Client *kbd_focus_client; + + kbd_focus_client = wl_container_of(listener, kbd_focus_client, client_destroy); + _e_comp_wl_focus_client_del(kbd_focus_client); +} + +static void +_e_comp_wl_focus_client_cb_client_focus_set(struct wl_listener *listener, void *data) +{ + E_Client *ec; + E_Comp_Wl_Focus_Private_Client *kbd_focus_client; + + kbd_focus_client = wl_container_of(listener, kbd_focus_client, focus_set); + EINA_SAFETY_ON_NULL_RETURN(kbd_focus_client); + ec = kbd_focus_client->ec; + EINA_SAFETY_ON_NULL_RETURN(ec); + + struct wl_resource *surface = e_comp_wl_client_surface_get(ec); + if (!surface) return; + + ELOGF("COMP_WL", "send focus in request to input thread. surface(%p)\n", ec, surface); + _e_comp_wl_input_thread_focus_in(&surface); + + return; +} + +static void +_e_comp_wl_focus_client_cb_client_focus_unset(struct wl_listener *listener, void *data) +{ + E_Client *ec; + E_Comp_Wl_Focus_Private_Client *kbd_focus_client; + + kbd_focus_client = wl_container_of(listener, kbd_focus_client, focus_unset); + EINA_SAFETY_ON_NULL_RETURN(kbd_focus_client); + ec = kbd_focus_client->ec; + EINA_SAFETY_ON_NULL_RETURN(ec); + + struct wl_resource *surface = e_comp_wl_client_surface_get(ec); + if (!surface) return; + + ELOGF("COMP_WL", "send focus out request to input thread. surface(%p)\n", ec, surface); + _e_comp_wl_input_thread_focus_out(&surface); + + return; +} + +static void +_e_comp_wl_focus_client_add(E_Client *ec) +{ + E_Comp_Wl_Focus_Private_Client *kbd_focus_client; + + kbd_focus_client = E_NEW(E_Comp_Wl_Focus_Private_Client, 1); + EINA_SAFETY_ON_NULL_RETURN(kbd_focus_client); + + kbd_focus_client->ec = ec; + + kbd_focus_client->focus_set.notify = _e_comp_wl_focus_client_cb_client_focus_set; + e_client_focus_set_listener_add(ec, &kbd_focus_client->focus_set); + + kbd_focus_client->focus_unset.notify = _e_comp_wl_focus_client_cb_client_focus_unset; + e_client_focus_unset_listener_add(ec, &kbd_focus_client->focus_unset); + + kbd_focus_client->client_destroy.notify = _e_comp_wl_focus_client_cb_client_destroy; + e_client_destroy_listener_add(ec, &kbd_focus_client->client_destroy); + + return; +} + static Eina_Bool _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Comp_Object *ev) { @@ -2325,6 +2409,8 @@ _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Ev /* if we have not setup evas callbacks for this client, do it */ if (!ec->comp_data->evas_init) _e_comp_wl_client_evas_init(ec); + _e_comp_wl_focus_client_add(ec); + return ECORE_CALLBACK_RENEW; } @@ -3808,6 +3894,9 @@ e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev) E_Client *ec = NULL; uint32_t keycode; E_Comp_Wl_Key_Data *end, *k; + const char *seat_name = NULL; + E_Seat *seat; + E_Zone *zone = NULL; if (ev->window != e_comp_ee_win_get()) { @@ -3841,7 +3930,15 @@ e_comp_wl_key_down(Ecore_Event_Key *ev, E_Device *dev) comp = e_comp_get(); if ((!e_client_action_get()) && (!comp->input_key_grabs)) { - ec = e_client_focused_get(); + seat_name = e_device_seatname_get(dev); + if ((seat_name) && (seat = e_seat_find(seat_name))) + zone = e_seat_zone_get(seat); + if (!zone) + zone = e_comp_default_zone_get(comp); + + ec = e_zone_focused_client_get(zone); + ELOGF("INPUT", "Key Down. seat:%s zone_id:%d", ec, seat_name, e_zone_id_get(zone)); + struct wl_resource *surface = e_comp_wl_client_surface_get(ec); if (ec && ec->comp_data && surface) { @@ -3879,6 +3976,9 @@ e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev) uint32_t keycode, delivered_key; E_Comp_Wl_Key_Data *end, *k; E_Comp *comp; + const char *seat_name = NULL; + E_Seat *seat; + E_Zone *zone = NULL; if (ev->window != e_comp_ee_win_get()) { @@ -3907,7 +4007,14 @@ e_comp_wl_key_up(Ecore_Event_Key *ev, E_Device *dev) if ((delivered_key) || ((!e_client_action_get()) && (!comp->input_key_grabs))) { - ec = e_client_focused_get(); + seat_name = e_device_seatname_get(dev); + if ((seat_name) && (seat = e_seat_find(seat_name))) + zone = e_seat_zone_get(seat); + if (!zone) + zone = e_comp_default_zone_get(comp); + + ec = e_zone_focused_client_get(zone); + ELOGF("INPUT", "Key Up. seat:%s zone_id:%d", ec, seat_name, e_zone_id_get(zone)); g_rec_mutex_lock(&e_comp_input_key->kbd.focused_mutex); if (e_comp_input_key->kbd.focused) diff --git a/src/bin/server/e_keyrouter_wl.c b/src/bin/server/e_keyrouter_wl.c index 555c8e32f7..3888032d40 100644 --- a/src/bin/server/e_keyrouter_wl.c +++ b/src/bin/server/e_keyrouter_wl.c @@ -11,6 +11,7 @@ #include "e_security.h" #include "e_keyrouter_intern.h" #include "e_keyrouter_hardkeys_intern.h" +#include "e_zone_intern.h" #include @@ -130,6 +131,9 @@ e_keyrouter_wl_key_send(Ecore_Event_Key *ev, E_Device *dev, Eina_Bool pressed, s struct wl_client *wc = NULL; uint32_t keycode; enum wl_keyboard_key_state state; + const char *seat_name = NULL; + E_Seat *seat; + E_Zone *zone = NULL; if (ev->window != e_comp_ee_win_get()) { @@ -163,7 +167,14 @@ e_keyrouter_wl_key_send(Ecore_Event_Key *ev, E_Device *dev, Eina_Bool pressed, s comp = e_comp_get(); if ((!e_client_action_get()) && (comp && !comp->input_key_grabs)) { - ec = e_client_focused_get(); + seat_name = e_device_seatname_get(dev); + if ((seat_name) && (seat = e_seat_find(seat_name))) + zone = e_seat_zone_get(seat); + if (!zone) + zone = e_comp_default_zone_get(comp); + + ec = e_zone_focused_client_get(zone); + ELOGF("KRT", "Key Send. seat:%s zone_id:%d", ec, seat_name, e_zone_id_get(zone)); if (ec && ec->comp_data) {