e_service_kvm: Implement kvm secondary selection 12/296712/2
authorJunkyeong Kim <jk0430.kim@samsung.com>
Wed, 2 Aug 2023 07:10:51 +0000 (16:10 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Thu, 3 Aug 2023 09:34:21 +0000 (09:34 +0000)
If kvm_service secondary_selection set,
e20 send wl_selection_data to secondary_selection like cbhm.

Change-Id: Ie7fe9f86eed41fb61c43a401d63dd127e5866fb2

src/bin/e_comp_wl.h
src/bin/e_comp_wl_data.c
src/bin/e_compositor.c
src/bin/services/e_service_kvm.c

index 6327498..3023de8 100644 (file)
@@ -308,6 +308,7 @@ struct _E_Comp_Wl_Data
         E_Client *target;
 
         struct wl_resource *cbhm;
+        struct wl_resource *secondary;
         Eina_List *data_only_list;
      } selection;
 
index 2b9653f..6fcafd8 100644 (file)
@@ -530,7 +530,7 @@ _e_comp_wl_data_device_selection_set(void *data EINA_UNUSED, E_Comp_Wl_Data_Sour
 {
    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;
+   struct wl_client *source_client = NULL, *sel_client = NULL, *cbhm_client = NULL, *secondary_selection_client = NULL;
 
    sel_source = (E_Comp_Wl_Data_Source*)e_comp_wl->selection.data_source;
 
@@ -540,6 +540,8 @@ _e_comp_wl_data_device_selection_set(void *data EINA_UNUSED, E_Comp_Wl_Data_Sour
      sel_client = wl_resource_get_client(sel_source->resource);
    if (e_comp_wl->selection.cbhm)
      cbhm_client = wl_resource_get_client(e_comp_wl->selection.cbhm);
+   if (e_comp_wl->selection.secondary)
+     secondary_selection_client = wl_resource_get_client(e_comp_wl->selection.secondary);
 
    if ((sel_source) &&
        (sel_client == source_client) &&
@@ -572,7 +574,7 @@ _e_comp_wl_data_device_selection_set(void *data EINA_UNUSED, E_Comp_Wl_Data_Sour
    if (e_comp_wl->kbd.enabled)
      focus = e_comp_wl->kbd.focus;
 
-   //if source is from cbhm_client do not crate data offer for cbhm
+   //if source is from cbhm_client do not create data offer for cbhm
    if ((cbhm_client) && (source_client != cbhm_client))
      {
         data_device_res =
@@ -584,6 +586,20 @@ _e_comp_wl_data_device_selection_set(void *data EINA_UNUSED, E_Comp_Wl_Data_Sour
                                                          data_device_res);
              wl_data_device_send_selection(data_device_res, offer_res);
           }
+
+        if (secondary_selection_client)
+          {
+             if (secondary_selection_client != source_client)
+               {
+                  data_device_res = e_comp_wl_data_find_for_client(secondary_selection_client);
+                  if ((data_device_res) && (source))
+                    {
+                       offer_res =
+                          _e_comp_wl_data_device_data_offer_create(source, data_device_res);
+                       wl_data_device_send_selection(data_device_res, offer_res);
+                    }
+               }
+          }
      }
    else
      {
index 391dc97..87ca02f 100644 (file)
@@ -492,6 +492,9 @@ _e_surface_destroy(E_Surface *surface)
    if (e_comp_wl->selection.cbhm == surface->base.surface)
      e_comp_wl->selection.cbhm = NULL;
 
+   if (e_comp_wl->selection.secondary == surface->base.surface)
+     e_comp_wl->selection.secondary = NULL;
+
    if (surface->base.viewport_transform)
      {
         e_client_transform_core_remove(surface->ec, surface->base.viewport_transform);
index 8b3c15a..a235dc3 100644 (file)
@@ -30,6 +30,8 @@ _kvm_client_del(void)
      }
    E_FREE_FUNC(_kvm_del_hook, e_client_hook_del);
    E_FREE(_kvm_service);
+
+   e_comp_wl->selection.secondary = NULL;
 }
 
 static void
@@ -188,6 +190,7 @@ e_service_kvm_drop_perform(E_Client *ec)
 EINTERN Eina_Bool
 e_service_kvm_secondary_selection_set(E_Client *ec, Eina_Bool set)
 {
+   E_Comp_Wl_Client_Data *cdata;
    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(_kvm_service, EINA_FALSE);
 
@@ -199,7 +202,19 @@ e_service_kvm_secondary_selection_set(E_Client *ec, Eina_Bool set)
 
    ELOGF("KVM", "secondary selection set requested!, set:%d", ec, set);
 
-   //TODO: set as secondary selection
+   cdata = e_client_cdata_get(ec);
+   if (set)
+     {
+        if (!cdata) return EINA_FALSE;
+        e_comp_wl->selection.secondary = cdata->surface;
+     }
+   else
+     {
+        if (!cdata || e_comp_wl->selection.secondary == cdata->surface)
+          e_comp_wl->selection.secondary = NULL;
+        else
+          return EINA_FALSE;
+     }
 
    return EINA_TRUE;
 }