deactivate gestures during all deactivated clients destroy/request activated 23/216723/1
authorjeon <jhyuni.kang@samsung.com>
Thu, 31 Oct 2019 07:07:17 +0000 (16:07 +0900)
committerjeon <jhyuni.kang@samsung.com>
Thu, 31 Oct 2019 07:07:17 +0000 (16:07 +0900)
Change-Id: Idddd1faa446832327c1ddf355da95f05f46584ec

src/e_mod_main.c
src/e_mod_main.h

index 5f570475c3a88166e2d0acccbe275dd90696f381..2232e00a329c298070a7fe87574c9b530c2c1fcf 100644 (file)
@@ -1251,11 +1251,29 @@ _e_gesture_deactivate_find_surface(Eina_List *list, struct wl_resource *surface)
    return EINA_FALSE;
 }
 
+static Eina_Bool
+_e_gesture_deactivate_find_client(Eina_List *list, struct wl_client *client)
+{
+   Eina_List *l;
+   struct wl_client *client_data;
+
+   EINA_LIST_FOREACH(list, l, client_data)
+     {
+        if (client_data == client)
+          {
+             return EINA_TRUE;
+          }
+     }
+   return EINA_FALSE;
+}
+
 static void
 _e_gesture_deactivate_list_unset(struct wl_client *client, struct wl_resource *surface, E_Gesture_Activate_Info *info, unsigned int type)
 {
    Eina_List *l, *l_next;
    struct wl_resource *surface_data;
+   struct wl_client *client_data;
+   Eina_Bool removed = EINA_FALSE;
 
    if (surface)
      {
@@ -1264,18 +1282,37 @@ _e_gesture_deactivate_list_unset(struct wl_client *client, struct wl_resource *s
              if (surface_data == surface)
                {
                   info->surfaces = eina_list_remove_list(info->surfaces, l);
+                  removed = EINA_TRUE;
+                  if (info->surface == surface)
+                    {
+                       info->surface = NULL;
+                       if (eina_list_count(info->clients) == 0)
+                         {
+                            info->active = EINA_TRUE;
+                         }
+                    }
                   break;
                }
           }
      }
-   else if (info->client && (info->client == client))
-     {
-        info->client = NULL;
-        info->active = EINA_TRUE;
-     }
    else
      {
-        GTWRN("Failed to unset %s deactivate. surface: %p, client: %p (already deactivated client: %p)\n", _e_gesture_util_type_to_string(type), surface, client, info->client);
+        EINA_LIST_FOREACH_SAFE(info->clients, l, l_next, client_data)
+          {
+             if (client_data == client)
+               {
+                  info->clients = eina_list_remove_list(info->clients, l);
+                  removed = EINA_TRUE;
+                  break;
+               }
+          }
+        if (removed && (eina_list_count(info->clients) == 0))
+          {
+             if (!info->surface)
+               {
+                  info->active = EINA_TRUE;
+               }
+          }
      }
 }
 
@@ -1342,6 +1379,7 @@ _e_gesture_deactivate_list_set(struct wl_client *client, struct wl_resource *sur
 {
    int ret = TIZEN_GESTURE_ERROR_NONE;
    E_Client *focused_ec = NULL;
+   Eina_Bool added = EINA_FALSE;
 
    if (surface)
      {
@@ -1354,19 +1392,26 @@ _e_gesture_deactivate_list_set(struct wl_client *client, struct wl_resource *sur
                  surface == focused_ec->comp_data->wl_surface)
                {
                   info->active = EINA_FALSE;
+                  info->surface = surface;
                }
+             added = EINA_TRUE;
           }
      }
-   else if (!info->client)
+   else
      {
-        info->client = client;
-        info->active = EINA_FALSE;
-        _e_gesture_deactivate_listener_add(client, surface);
+        if (!_e_gesture_deactivate_find_client(info->clients, client))
+          {
+             info->clients = eina_list_append(info->clients, client);
+             _e_gesture_deactivate_listener_add(client, surface);
+             info->active = EINA_FALSE;
+             added = EINA_TRUE;
+          }
      }
-   else
+
+   if (!added)
      {
-        GTWRN("Failed to deactivate %s !(request surface: %p, client: %p), already deactivated client: %p\n",
-              _e_gesture_util_type_to_string(type), surface, client, info->client);
+        GTWRN("Failed to deactivate %s !(request surface: %p, client: %p)\n",
+              _e_gesture_util_type_to_string(type), surface, client);
         ret = TIZEN_GESTURE_ERROR_GRABBED_ALREADY;
      }
 
@@ -1704,10 +1749,23 @@ _e_gesture_deactivate_surface_list_check(struct wl_resource *surface, E_Gesture_
 {
    Eina_Bool res;
 
+   if (eina_list_count(info->surfaces) == 0) return;
+
    res = _e_gesture_deactivate_find_surface(info->surfaces, surface);
 
-   if (res) info->active = EINA_FALSE;
-   else info->active = EINA_TRUE;
+   if (res)
+     {
+        info->active = EINA_FALSE;
+        info->surface = surface;
+     }
+   else
+     {
+        if (eina_list_count(info->clients) == 0)
+          {
+             info->active = EINA_TRUE;
+          }
+        info->surface = NULL;
+     }
 }
 
 static void
@@ -1721,26 +1779,11 @@ _e_gesture_deactivate_surface_check(E_Client *ec)
    surface = ec->comp_data->wl_surface;
    if (!surface) return;
 
-   if (!gesture->gesture_events.edge_swipes.base.activation.client)
-     {
-        _e_gesture_deactivate_surface_list_check(surface, &gesture->gesture_events.edge_swipes.base.activation);
-     }
-   if (!gesture->gesture_events.taps.activation.client)
-     {
-        _e_gesture_deactivate_surface_list_check(surface, &gesture->gesture_events.taps.activation);
-     }
-   if (!gesture->gesture_events.palm_covers.activation.client)
-     {
-        _e_gesture_deactivate_surface_list_check(surface, &gesture->gesture_events.palm_covers.activation);
-     }
-   if (!gesture->gesture_events.pans.activation.client)
-     {
-        _e_gesture_deactivate_surface_list_check(surface, &gesture->gesture_events.pans.activation);
-     }
-   if (!gesture->gesture_events.pinchs.activation.client)
-     {
-        _e_gesture_deactivate_surface_list_check(surface, &gesture->gesture_events.pinchs.activation);
-     }
+   _e_gesture_deactivate_surface_list_check(surface, &gesture->gesture_events.edge_swipes.base.activation);
+   _e_gesture_deactivate_surface_list_check(surface, &gesture->gesture_events.taps.activation);
+   _e_gesture_deactivate_surface_list_check(surface, &gesture->gesture_events.palm_covers.activation);
+   _e_gesture_deactivate_surface_list_check(surface, &gesture->gesture_events.pans.activation);
+   _e_gesture_deactivate_surface_list_check(surface, &gesture->gesture_events.pinchs.activation);
 }
 
 static void
index dfe43c3f6784c5e179687ccb8ca8a555e6bf536d..1078c6d33118dfe51b9d979815bdce56c27bce81 100644 (file)
@@ -150,7 +150,8 @@ struct _E_Gesture_Event_Info
 struct _E_Gesture_Activate_Info
 {
    Eina_Bool active;
-   struct wl_client *client;
+   struct wl_resource *surface;
+   Eina_List *clients;
    Eina_List *surfaces;
 };