e_comp_wl_data: Add secondary add/remove function 84/300184/1
authorJunkyeong Kim <jk0430.kim@samsung.com>
Wed, 18 Oct 2023 05:08:44 +0000 (14:08 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Wed, 18 Oct 2023 05:54:18 +0000 (14:54 +0900)
Use secondary_list to support multiple secondary selection.

Change-Id: Id3505a47bf3b877e2c69d533d03573106555eb3a

src/bin/e_comp_wl.h
src/bin/e_comp_wl_data.c
src/bin/e_comp_wl_data.h

index 4deee07bf0561de238b0236ebf8e72121cc7c440..78b12e3fcc4da1fe5d013fb7d95f2cd62621648e 100644 (file)
@@ -308,6 +308,7 @@ struct _E_Comp_Wl_Data
 
         struct wl_resource *cbhm;
         struct wl_resource *secondary;
+        Eina_List *secondary_list;
         Eina_List *data_only_list;
         Eina_Bool secondary_selection_sent;
      } selection;
index 2a7b01186975d958804b21c1e6aeab04038dca85..79242f258bbd71803d4bd3843fe4d0a917345e0e 100644 (file)
@@ -1632,3 +1632,54 @@ e_comp_wl_data_offer_mimetype_action_accept(E_Comp_Wl_Data_Offer *offer)
    offer->preferred_dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
    _e_comp_wl_data_offer_update_action(offer);
 }
+
+static Eina_Bool
+_e_comp_wl_data_secondary_list_check(E_Client *ec)
+{
+   E_Client *tmp;
+   Eina_List *l;
+
+   if (e_comp_wl->selection.secondary_list == NULL)
+     return EINA_FALSE;
+
+   EINA_LIST_FOREACH(e_comp_wl->selection.secondary_list, l, tmp)
+     {
+        if (tmp == ec)
+          return EINA_TRUE;
+     }
+
+   return EINA_FALSE;
+}
+
+EINTERN void
+e_comp_wl_data_secondary_add(E_Client *ec)
+{
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+
+   if (_e_comp_wl_data_secondary_list_check(ec) == EINA_TRUE)
+     return;
+
+   e_comp_wl->selection.secondary_list = eina_list_append(e_comp_wl->selection.secondary_list, ec);
+   DBG("add secondary %s(%p). listcount(%d)",
+       e_client_util_name_get(ec), ec, eina_list_count(e_comp_wl->selection.secondary_list));
+}
+
+EINTERN void
+e_comp_wl_data_secondary_remove(E_Client *ec)
+{
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+
+   if (_e_comp_wl_data_secondary_list_check(ec) == EINA_FALSE)
+     return;
+
+   e_comp_wl->selection.secondary_list = eina_list_remove(e_comp_wl->selection.secondary_list, ec);
+   DBG("remove secondary %s(%p). listcount(%d)",
+       e_client_util_name_get(ec), ec, eina_list_count(e_comp_wl->selection.secondary_list));
+
+
+   if (eina_list_count(e_comp_wl->selection.secondary_list) == 0)
+     {
+        eina_list_free(e_comp_wl->selection.secondary_list);
+        e_comp_wl->selection.secondary_list = NULL;
+     }
+}
index b9c4bc0631a0af21d64be1c4112fc631a27f095b..aec93bc62a60e5f24612a0b21873d35fa8ceda8c 100644 (file)
@@ -106,6 +106,7 @@ EINTERN Eina_Bool e_comp_wl_data_device_manual_selection_set(void *data, size_t
 EINTERN void e_comp_wl_data_current_device_id_set(int id);
 EINTERN int e_comp_wl_data_current_device_id_get(void);
 EINTERN void e_comp_wl_data_offer_mimetype_action_accept(E_Comp_Wl_Data_Offer *offer);
-
+EINTERN void e_comp_wl_data_secondary_add(E_Client *ec);
+EINTERN void e_comp_wl_data_secondary_remove(E_Client *ec);
 # endif
 #endif