e_comp_wl_data: add seat variable in E_Comp_Wl_Data_Source struct 43/322343/1
authorduna.oh <duna.oh@samsung.com>
Mon, 7 Apr 2025 09:56:22 +0000 (18:56 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Tue, 8 Apr 2025 01:25:17 +0000 (10:25 +0900)
Change-Id: Ib7c50615eae8bc4d090213ccfa935df20c13ef94

src/bin/inputmgr/e_comp_input_intern.h
src/bin/server/e_comp_wl.c
src/bin/server/e_comp_wl_data.c
src/bin/server/e_comp_wl_data_intern.h
src/bin/server/e_seat.c
src/bin/server/e_seat_intern.h

index 8126603517903e613dee52d0001445831cf00198..666a187139010069ebfac6d9285f9c78440af261 100644 (file)
@@ -39,7 +39,6 @@ struct _E_Comp_Input_Key_Data
         xkb_mod_mask_t mod_depressed, mod_latched, mod_locked;
         xkb_layout_index_t mod_group;
         struct wl_array keys;
-        struct wl_resource *focus;
         int mod_changed;
         atomic_int repeat_delay;
         atomic_int repeat_rate;
index 6fcad7da0f91a59ae93531d4783a9d2431f053f5..82caf44d2a23e22f80b56409c82a3261591e8b77 100644 (file)
@@ -2084,11 +2084,15 @@ _e_comp_wl_client_focus_in(E_Client *ec)
    struct wl_resource *res, *surface;
    struct wl_client *wc;
    Eina_List *l;
+   E_Seat *seat = NULL;
 
    if (!ec) return;
    surface = e_comp_wl_client_surface_get(ec);
    EINA_SAFETY_ON_NULL_RETURN(surface);
 
+   seat = e_seat_find_by_zone(e_comp_zone_find_by_ec(ec));
+   if (!seat) return;
+
    wc = wl_resource_get_client(surface);
 
    g_rec_mutex_lock(&e_comp_input_key->kbd.resources_mutex);
@@ -2113,9 +2117,9 @@ _e_comp_wl_client_focus_in(E_Client *ec)
      }
    g_rec_mutex_unlock(&e_comp_input_key->kbd.focused_mutex);
 
-   e_comp_input_key->kbd.focus = surface;
+   e_seat_keyboard_focus_surface_set(seat, surface);
    e_comp_wl_input_keyboard_enter_send(surface);
-   e_comp_wl_data_device_keyboard_focus_set();
+   e_comp_wl_data_device_keyboard_focus_set(seat);
 }
 
 /* It is called in the following cases:
@@ -2161,12 +2165,16 @@ _e_comp_wl_client_focus_out(E_Client *ec)
    E_Comp_Wl_Key_Data *k;
    Eina_List *l, *ll;
    double t;
+   E_Seat *seat = NULL;
 
    struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
    if (!surface) return;
 
    EINA_SAFETY_ON_NULL_RETURN(surface);
 
+   seat = e_seat_find_by_zone(e_comp_zone_find_by_ec(ec));
+   if (!seat) return;
+
    /* update keyboard modifier state */
    wl_array_for_each(k, &e_comp_input_key->kbd.keys)
       e_comp_wl_input_keyboard_state_update(k->key, EINA_FALSE);
@@ -2200,6 +2208,8 @@ _e_comp_wl_client_focus_out(E_Client *ec)
           }
      }
    g_rec_mutex_unlock(&e_comp_input_key->kbd.focused_mutex);
+
+   e_seat_keyboard_focus_surface_set(seat, NULL);
 }
 
 static void
@@ -3435,19 +3445,6 @@ _e_comp_wl_connected_client_create(struct wl_client *client, char *name, pid_t p
    _e_comp_wl_pid_hook_call(E_COMP_WL_PID_HOOK_CONNECTED_CLIENT_CREATE, pid);
 }
 
-static void
-_e_input_thread_client_cb_focus_set(void *data)
-{
-   struct wl_resource *surface = NULL;
-
-   EINA_SAFETY_ON_NULL_RETURN(data);
-   surface = *(struct wl_resource **)data;
-
-   ICINF("[input thread|%s] surface(%p)", __func__, surface);
-
-   e_comp_input_key->kbd.focus = surface;
-}
-
 static void
 _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
 {
@@ -3459,23 +3456,6 @@ _e_comp_wl_client_cb_focus_set(void *data EINA_UNUSED, E_Client *ec)
         if (ec->comp_data->shell.surface)
           _e_comp_wl_configure_send(ec, 0, 0);
      }
-
-   ICINF("[%s] surface(%p)", __func__, ec->comp_data->surface);
-   e_input_backend_thread_safe_call(_e_input_thread_client_cb_focus_set, (void *)&ec->comp_data->surface, sizeof(struct wl_resource *));
-}
-
-static void
-_e_input_thread_client_cb_focus_unset(void *data)
-{
-   struct wl_resource *surface = NULL;
-
-   EINA_SAFETY_ON_NULL_RETURN(data);
-   surface = *(struct wl_resource **)data;
-
-   ICINF("[input thread|%s] surface(%p)", __func__, surface);
-
-   if (e_comp_input_key->kbd.focus == surface)
-     e_comp_input_key->kbd.focus = NULL;
 }
 
 static void
@@ -3491,9 +3471,6 @@ _e_comp_wl_client_cb_focus_unset(void *data EINA_UNUSED, E_Client *ec)
      }
 
    _e_comp_wl_focus_check();
-
-   ICINF("[%s] surface(%p)", __func__, ec->comp_data->surface);
-   e_input_backend_thread_safe_call(_e_input_thread_client_cb_focus_unset, (void *)&ec->comp_data->surface, sizeof(struct wl_resource *));
 }
 
 static void
index 8dc997e5796bbbe82abb771fab77e89da49434c9..d5b8b0b22bddb5279494ca7c9957945e7d0e7c08 100644 (file)
@@ -21,7 +21,7 @@ typedef struct {
 } E_Comp_Wl_Thread_Data;
 
 static void _e_comp_wl_data_source_cancelled_send(E_Comp_Wl_Data_Source *source);
-static void _e_comp_wl_data_device_selection_unset(void);
+static void _e_comp_wl_data_device_selection_unset(E_Comp_Wl_Data_Source *source);
 
 static void
 _mime_types_free(E_Comp_Wl_Data_Source *source)
@@ -561,10 +561,11 @@ _e_comp_wl_data_source_cb_resource_destroy(struct wl_resource *resource)
    if (comp_wl->selection.data_source == source)
      {
         comp_wl->selection.data_source = NULL;
-        _e_comp_wl_data_device_selection_unset();
+        _e_comp_wl_data_device_selection_unset(source);
      }
 
    _mime_types_free(source);
+   source->seat = NULL;
    free(source);
 }
 
@@ -627,17 +628,19 @@ static const struct wl_data_source_interface _e_data_source_interface =
 };
 
 static void
-_e_comp_wl_data_device_selection_unset(void)
+_e_comp_wl_data_device_selection_unset(E_Comp_Wl_Data_Source *source)
 {
    struct wl_resource *data_device_res = NULL, *focus = NULL;
    struct wl_resource *data_only;
    E_Comp_Wl_Data *comp_wl;
    Eina_List *l;
+   E_Seat *seat = NULL;
 
    comp_wl = e_comp_wl_get();
 
-   if (e_seat_keyboard_enabled_get(NULL))
-     focus = e_comp_input_key->kbd.focus;
+   seat = source->seat;
+   if (seat && e_seat_keyboard_enabled_get(seat))
+     focus = e_seat_keyboard_focus_surface_get(seat);
 
    if (focus)
      {
@@ -685,7 +688,7 @@ _e_comp_wl_data_device_destroy_selection_data_source(struct wl_listener *listene
         return;
      }
 
-   _e_comp_wl_data_device_selection_unset();
+   _e_comp_wl_data_device_selection_unset(source);
 
    wl_signal_emit(&comp_wl->selection.signal, comp_wl);
 }
@@ -804,6 +807,7 @@ _e_comp_wl_data_device_selection_set(E_Comp_Wl_Data *comp_wl, E_Comp_Wl_Data_Sou
    E_Comp_Wl_Data_Source *sel_source;
    struct wl_resource *offer_res, *data_device_res, *focus = NULL;
    struct wl_client *source_client = NULL, *sel_client = NULL, *cbhm_client = NULL;
+   E_Seat *seat = NULL;
 
    sel_source = (E_Comp_Wl_Data_Source*)comp_wl->selection.data_source;
 
@@ -842,8 +846,8 @@ _e_comp_wl_data_device_selection_set(E_Comp_Wl_Data *comp_wl, E_Comp_Wl_Data_Sou
    comp_wl->clipboard.xwl_owner = NULL;
    comp_wl->selection.serial = serial;
 
-   if (e_seat_keyboard_enabled_get(NULL))
-     focus = e_comp_input_key->kbd.focus;
+   if ((source) && (seat = source->seat) && e_seat_keyboard_enabled_get(seat))
+     focus = e_seat_keyboard_focus_surface_get(seat);
 
    //if source is from cbhm_client do not create data offer for cbhm
    if ((cbhm_client) && (source_client != cbhm_client))
@@ -1032,7 +1036,7 @@ _e_comp_wl_data_device_cb_drag_start(struct wl_client *client EINA_UNUSED, struc
      {
         wc = wl_resource_get_client(origin_resource);
         //TODO: consider multi-seat
-        e_seat_pointer_send_leave(NULL, wc, ec, e_comp_wl_client_surface_get(ec));
+        e_seat_pointer_send_leave(seat, wc, ec, e_comp_wl_client_surface_get(ec));
      }
 
    evas_pointer_canvas_xy_get(e_comp_evas_get(), &x, &y);
@@ -1054,6 +1058,7 @@ _e_comp_wl_data_device_cb_drag_start(struct wl_client *client EINA_UNUSED, struc
    e_comp_canvas_feed_mouse_up(0);
 
    e_comp_wl_data_current_device_id_set(-1);
+   source->seat = seat;
 }
 
 static void
@@ -1066,8 +1071,10 @@ _e_comp_wl_data_device_cb_selection_set(struct wl_client *client EINA_UNUSED, st
    DBG("Data Device Selection Set");
    if (!source_resource) return;
    if (!(source = wl_resource_get_user_data(source_resource))) return;
+
    seat = wl_resource_get_user_data(resource);
    if (!seat) return;
+   source->seat = seat;
 
    _e_comp_wl_data_device_selection_set(comp_wl, source, serial);
 }
@@ -1567,19 +1574,19 @@ _e_comp_wl_data_secondary_list_resource_check(struct wl_resource *data_device_re
 }
 
 EINTERN void
-e_comp_wl_data_device_keyboard_focus_set(void)
+e_comp_wl_data_device_keyboard_focus_set(E_Seat *seat)
 {
    struct wl_resource *data_device_res, *offer_res = NULL, *focus;
    E_Comp_Wl_Data_Source *source;
    E_Comp_Wl_Data *comp_wl;
 
-   if (e_seat_keyboard_enabled_get(NULL))
+   if (e_seat_keyboard_enabled_get(seat))
      {
         ERR("Keyboard not enabled");
         return;
      }
 
-   if (!(focus = e_comp_input_key->kbd.focus))
+   if (!(focus = e_seat_keyboard_focus_surface_get(seat)))
      {
         ERR("No focused resource");
         return;
@@ -1670,6 +1677,7 @@ e_comp_wl_data_manager_source_create(struct wl_client *client, struct wl_resourc
    source->target = _e_comp_wl_data_source_target_send;
    source->send = _e_comp_wl_data_source_send_send;
    source->cancelled = _e_comp_wl_data_source_cancelled_send;
+   source->seat = NULL;
 
    source->resource =
        wl_resource_create(client, &wl_data_source_interface, 3, id);
@@ -1782,8 +1790,10 @@ e_comp_wl_data_device_only_set(struct wl_resource *data_device_res, Eina_Bool se
    struct wl_resource *offer_res = NULL, *focus;
    E_Comp_Wl_Data_Source *source;
    E_Comp_Wl_Data *comp_wl;
+   E_Seat *seat;
 
    EINA_SAFETY_ON_NULL_RETURN(data_device_res);
+   seat = wl_resource_get_user_data(data_device_res);
 
    comp_wl = e_comp_wl_get();
    if (set)
@@ -1807,7 +1817,7 @@ e_comp_wl_data_device_only_set(struct wl_resource *data_device_res, Eina_Bool se
         comp_wl->selection.data_only_list =
            eina_list_remove(comp_wl->selection.data_only_list, data_device_res);
 
-        focus = e_comp_input_key->kbd.focus;
+        focus = e_seat_keyboard_focus_surface_get(seat);
         if ((!focus) ||
             (wl_resource_get_client(focus) != wl_resource_get_client(data_device_res)))
           {
index 4ea9ec6a53e83a9ffdf4d94fcfc00ac35db86258..43914ccfc9e056bea92e9d080d59ed687482ed4a 100644 (file)
@@ -2,6 +2,7 @@
 #define E_COMP_WL_DATA_INTERN_H
 
 #include "e_intern.h"
+#include "e_seat_intern.h"
 
 #  ifdef PIPE_BUF
 #   define CLIPBOARD_CHUNK PIPE_BUF
@@ -33,6 +34,7 @@ struct _E_Comp_Wl_Data_Source
    Eina_Bool actions_set;
    enum wl_data_device_manager_dnd_action current_dnd_action;
    enum wl_data_device_manager_dnd_action compositor_action;
+   E_Seat *seat;
 };
 
 struct _E_Comp_Wl_Data_Offer
@@ -92,7 +94,7 @@ EINTERN int                         e_comp_wl_clipboard_source_ref(E_Comp_Wl_Cli
 EINTERN int                         e_comp_wl_clipboard_source_unref(E_Comp_Wl_Clipboard_Source *source);
 
 EINTERN void      e_comp_wl_data_device_only_set(struct wl_resource *data_device_res, Eina_Bool set);
-EINTERN void      e_comp_wl_data_device_keyboard_focus_set(void);
+EINTERN void      e_comp_wl_data_device_keyboard_focus_set(E_Seat *seat);
 
 EINTERN void e_comp_wl_data_current_device_id_set(int id);
 EINTERN int  e_comp_wl_data_current_device_id_get(void);
index 5fe4f4596bf2a30f011697cb6955d1348223ec0d..4ef729cfe431ee59c66c663978f8c09ad9570a6f 100644 (file)
@@ -35,6 +35,7 @@ struct _E_Seat
      {
         Eina_Bool enabled : 1;
         unsigned int num_devices;
+        struct wl_resource *focus;
      } kbd;
    E_Zone *zone;
 };
@@ -1130,3 +1131,22 @@ e_seat_keyboard_resource_is_for_ec(struct wl_resource *resource, E_Client *ec)
 
    return ret;
 }
+
+EINTERN struct wl_resource *
+e_seat_keyboard_focus_surface_get(E_Seat *seat)
+{
+   E_Seat *s;
+
+   if (!seat) s = _current_seat;
+   else s = seat;
+
+   return s->kbd.focus;
+}
+
+EINTERN void
+e_seat_keyboard_focus_surface_set(E_Seat *seat, struct wl_resource *surface)
+{
+   if (!seat) return;
+
+   seat->kbd.focus = surface;
+}
index 97b4d46c61c9b9cd8743d85139de0d0d6c65419e..11645a8a0924d45e1ee3f1329c06040e7840c4f2 100644 (file)
@@ -71,5 +71,7 @@ EINTERN E_Seat     *e_seat_current_get();
 EINTERN const char *e_seat_name_get(E_Seat *seat);
 EINTERN E_Seat     *e_seat_find_by_zone(E_Zone *zone);
 EINTERN Eina_Bool   e_seat_keyboard_resource_is_for_ec(struct wl_resource *resource, E_Client *ec);
+EINTERN struct wl_resource *e_seat_keyboard_focus_surface_get(E_Seat *seat);
+EINTERN void                e_seat_keyboard_focus_surface_set(E_Seat *seat, struct wl_resource *surface);
 
 #endif // E_SEAT_INTERN_H