Reuse E_Client from usable list 69/72369/6
authorMinJeong Kim <minjjj.kim@samsung.com>
Tue, 31 May 2016 15:14:04 +0000 (00:14 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Thu, 2 Jun 2016 04:29:26 +0000 (21:29 -0700)
Reuse E_Client instead of creating new E_Client if there is availble
E_Client. (e.g. clients for launchscreen)

Change-Id: Ia1072bcd6f62982e5cd437bc40224a9bf99a5c00
Signed-off-by: MinJeong Kim <minjjj.kim@samsung.com>
src/bin/e_comp_wl.c
src/modules/wl_desktop_shell/e_mod_main.c

index 55d8e36d46749254452a2e463a87a63a7a76d463..1d32ca31c72f774f6b95d56eaadf116359c8dc24 100644 (file)
@@ -40,6 +40,8 @@ static void _e_comp_wl_subsurface_check_below_bg_rectangle(E_Client *ec);
 static void _e_comp_wl_subsurface_show(E_Client *ec);
 static void _e_comp_wl_subsurface_hide(E_Client *ec);
 
+static E_Client * _e_comp_wl_client_usable_get(pid_t pid, E_Pixmap *ep);
+
 /* local variables */
 typedef struct _E_Comp_Wl_Transform_Context
 {
@@ -2795,7 +2797,10 @@ _e_comp_wl_compositor_cb_surface_create(struct wl_client *client, struct wl_reso
 
         DBG("\tUsing Pixmap: %p", ep);
 
-        ec = e_client_new(ep, 0, internal);
+        if (!(ec = _e_comp_wl_client_usable_get(pid, ep)))
+          {
+             ec = e_client_new(ep, 0, internal);
+          }
      }
    if (ec)
      {
@@ -4005,6 +4010,53 @@ _e_comp_wl_client_cb_uniconify(void *data EINA_UNUSED, E_Client *ec)
      e_client_uniconify(subc);
 }
 
+static E_Client *
+_e_comp_wl_client_usable_get(pid_t pid, E_Pixmap *ep)
+{
+   /* NOTE: this will return usable E_Client for a surface of specified process
+    * by pid. it doesn't care whatever this surfaces is for but care only what
+    * is owner process of the surface.
+    */
+
+   E_Client *ec = NULL, *_ec = NULL;
+   Eina_List *l;
+
+   /* find launchscreen client list */
+   if (e_comp->launchscrns)
+     {
+        EINA_LIST_FOREACH(e_comp->launchscrns, l, _ec)
+          {
+             if (_ec->netwm.pid == pid)
+               {
+                  ec = _ec;
+                  break;
+               }
+          }
+        if (ec)
+          {
+             E_Pixmap *oldep = NULL;
+
+             e_comp->launchscrns = eina_list_remove(e_comp->launchscrns, ec);
+
+             oldep = e_client_pixmap_change(ec, ep);
+             if (oldep)
+               {
+                  e_pixmap_del(oldep);
+                  e_pixmap_free(oldep);
+               }
+
+             if (ec->internal)
+               ec->internal = 0;
+
+             /* to set-up comp data */
+             _e_comp_wl_client_cb_new(NULL, ec);
+             _e_comp_wl_client_evas_init(ec);
+          }
+     }
+
+   return ec;
+}
+
 static void
 _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
 {
index a9390f01a807e3efaad265861bcecc86664b2d7c..50297980dfcea8b6931f45a53afb092fb3fd14d7 100644 (file)
@@ -497,6 +497,9 @@ _e_shell_surface_map(struct wl_resource *resource)
    /* map this surface if needed */
    if ((!ec->comp_data->mapped) && (e_pixmap_usable_get(ec->pixmap)))
      {
+        /* unset previous content */
+        e_comp_object_content_unset(ec->frame);
+
         ec->visible = EINA_TRUE;
         evas_object_geometry_set(ec->frame, ec->x, ec->y, ec->w, ec->h);
         evas_object_show(ec->frame);
@@ -1071,6 +1074,9 @@ _e_xdg_shell_surface_map_cb_timer(void *data)
               (unsigned int)e_client_util_win_get(ec),
               ec->w, ec->h);
 
+        /* unset previous content */
+        e_comp_object_content_unset(ec->frame);
+
         /* map this surface if needed */
         ec->visible = EINA_TRUE;
         evas_object_show(ec->frame);
@@ -1156,6 +1162,9 @@ _e_xdg_shell_surface_map(struct wl_resource *resource)
               (unsigned int)e_client_util_win_get(ec),
               ec->w, ec->h);
 
+        /* unset previous content */
+        e_comp_object_content_unset(ec->frame);
+
         /* map this surface if needed */
         ec->visible = EINA_TRUE;
         evas_object_show(ec->frame);