e_client: Introduce e_client_{show,hide} 09/304509/1
authorSeunghun Lee <shiin.lee@samsung.com>
Tue, 5 Dec 2023 06:19:58 +0000 (15:19 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 18 Jan 2024 06:30:43 +0000 (15:30 +0900)
In this commit, we have added two new APIs - `e_client_show()` and
`e_client_hide()` - to enhance code organization and readability.

Change-Id: I9c614f49d007668ec5961ff5d6064d8fb47d1b23

src/bin/e_client.c
src/bin/e_client_intern.h
src/bin/e_comp_wl.c

index 17a2173..2f64e88 100644 (file)
@@ -7130,8 +7130,8 @@ e_client_shell_ping(E_Client *ec)
    ec->comp_data->shell.ping(ec->comp_data->shell.surface);
 }
 
-EINTERN void
-e_client_shell_map(E_Client *ec)
+static void
+_e_client_shell_map(E_Client *ec)
 {
    EINA_SAFETY_ON_NULL_RETURN(ec);
    EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
@@ -7155,3 +7155,103 @@ e_client_shell_unmap(E_Client *ec)
 
    ec->comp_data->shell.unmap(ec->comp_data->shell.surface);
 }
+
+EINTERN void
+e_client_show(E_Client *ec)
+{
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+   EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
+
+   if (ec->comp_data->mapped)
+     return;
+
+   if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.map) &&
+       (!ec->ignored))
+     {
+        ELOGF("E_CLIENT", "Map.", ec);
+        _e_client_shell_map(ec);
+     }
+   else if (ec->internal || e_comp_wl_subsurface_can_show(ec) ||
+            (ec == e_comp_wl->drag_client))
+     {
+        ELOGF("E_CLIENT", "Map. internal:%d, drag:%d",
+              ec, ec->internal, (ec == e_comp_wl->drag_client));
+        ec->visible = EINA_TRUE;
+        ec->ignored = 0;
+        evas_object_show(ec->frame);
+        ec->comp_data->mapped = 1;
+     }
+}
+
+EINTERN void
+e_client_hide(E_Client *ec)
+{
+   API_ENTRY;
+
+   EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
+
+   if (!ec->comp_data->mapped)
+     return;
+
+   if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.unmap))
+     {
+        ELOGF("E_CLIENT", "Unmap", ec);
+
+        if (priv->hide_by_request)
+          ELOGF("COMP", "Currenlty hide_by_request state.", ec);
+
+        e_client_shell_unmap(ec);
+     }
+   else if (ec->internal || e_comp_wl_subsurface_check(ec) ||
+            (ec == e_comp_wl->drag_client))
+     {
+        ELOGF("E_CLIENT", "Unmap. internal:%d, sub:%p, drag:%d",
+              ec, ec->internal, ec->comp_data->sub.data, (ec == e_comp_wl->drag_client));
+        ec->visible = EINA_FALSE;
+        evas_object_hide(ec->frame);
+        ec->comp_data->mapped = 0;
+     }
+}
+
+EINTERN void
+e_client_hide_with_show_pending_cancel(E_Client *ec)
+{
+   API_ENTRY;
+
+   EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
+
+   if (!ec->comp_data->mapped)
+     return;
+
+   if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.unmap))
+     {
+        ELOGF("E_CLIENT", "Unmap", ec);
+
+        if (priv->hide_by_request)
+          ELOGF("COMP", "Currenlty hide_by_request state.", ec);
+
+        if (ec->show_pending.count > 0)
+          {
+             ELOGF("E_CLIENT", "Reset show_pending!!! (count:%d, run:%d)", ec, ec->show_pending.count, ec->show_pending.running);
+             ec->show_pending.count = 0;
+             if (ec->show_pending.running)
+               {
+                  // need to send visibility false;
+                  ec->visibility.obscured = E_VISIBILITY_UNOBSCURED;
+                  ELOGF("POL_VIS", "CLIENT VIS ON (fake).  argb:%d, opaque:%2d", ec, ec->argb, ec->visibility.opaque);
+                  EC_CHANGED(ec);
+               }
+             ec->show_pending.running = EINA_FALSE;
+          }
+        e_client_shell_unmap(ec);
+     }
+   else if ((ec->internal) || (e_comp_wl_subsurface_check(ec)) ||
+            (ec == e_comp_wl->drag_client))
+     {
+        ELOGF("E_CLIENT", "Unmap. internal:%d, sub:%p, drag:%d",
+              ec, ec->internal, ec->comp_data->sub.data, (ec == e_comp_wl->drag_client));
+        ec->visible = EINA_FALSE;
+        evas_object_hide(ec->frame);
+        ec->comp_data->mapped = 0;
+     }
+}
index c527552..a2a7307 100644 (file)
@@ -57,10 +57,13 @@ EINTERN void e_client_unstick_listener_add(E_Client *ec, struct wl_listener *lis
 
 EINTERN struct wl_listener  *e_client_destroy_listener_get(E_Client *ec, wl_notify_func_t notify);
 
+void e_client_show(E_Client *ec);
+void e_client_hide(E_Client *ec);
+void e_client_hide_with_show_pending_cancel(E_Client *ec);
+
 void e_client_shell_configure_send(E_Client *ec, uint32_t edges, int32_t width, int32_t height);
 void e_client_shell_configure(E_Client *ec, Evas_Coord x, Evas_Coord y, Evas_Coord width, Evas_Coord height);
 void e_client_shell_ping(E_Client *ec);
-void e_client_shell_map(E_Client *ec);
 void e_client_shell_unmap(E_Client *ec);
 
 #endif
index 8144ac2..886a81d 100644 (file)
@@ -2958,38 +2958,9 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
         /* unmap ec */
         if (cdata->mapped)
           {
-             if (hide_by_request)
-               ELOGF("COMP", "Currenlty hide_by_request state. pixmap_usable:%d", ec, pixmap_usable);
+             ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
 
-             if ((cdata->shell.surface) &&
-                 (cdata->shell.unmap))
-               {
-                  ELOGF("COMP", "Try to unmap. Call shell.unmap.", ec);
-                  if (ec->show_pending.count > 0)
-                    {
-                       ELOGF("E_CLIENT", "Reset show_pending!!! (count:%d, run:%d)", ec, ec->show_pending.count, ec->show_pending.running);
-                       ec->show_pending.count = 0;
-                       if (ec->show_pending.running)
-                         {
-                            // need to send visibility false;
-                            ec->visibility.obscured = E_VISIBILITY_UNOBSCURED;
-                            ELOGF("POL_VIS", "CLIENT VIS ON (fake).  argb:%d, opaque:%2d", ec, ec->argb, ec->visibility.opaque);
-                            EC_CHANGED(ec);
-                         }
-                       ec->show_pending.running = EINA_FALSE;
-                    }
-                  e_client_shell_unmap(ec);
-               }
-             else if ((ec->internal) ||
-                      (e_comp_wl_subsurface_check(ec)) ||
-                      (ec == e_comp_wl->drag_client))
-               {
-                  ELOGF("COMP", "Try to unmap. Hide window. internal:%d, sub:%p, drag:%d",
-                        ec, ec->internal, cdata->sub.data, (ec == e_comp_wl->drag_client));
-                  ec->visible = EINA_FALSE;
-                  evas_object_hide(ec->frame);
-                  cdata->mapped = 0;
-               }
+             e_client_hide_with_show_pending_cancel(ec);
           }
 
         if ((cdata->sub.below_obj) &&
@@ -3001,27 +2972,7 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
    else
      {
         /* map ec */
-        if (!cdata->mapped)
-          {
-             if ((cdata->shell.surface) &&
-                 (cdata->shell.map) &&
-                 (!ec->ignored))
-               {
-                  ELOGF("COMP", "Try to map. Call shell.map.", ec);
-                  e_client_shell_map(ec);
-               }
-             else if ((ec->internal) ||
-                      (e_comp_wl_subsurface_can_show(ec)) ||
-                      (ec == e_comp_wl->drag_client))
-               {
-                  ELOGF("COMP", "Try to map. Show window. internal:%d, drag:%d",
-                        ec, ec->internal, (ec == e_comp_wl->drag_client));
-                  ec->visible = EINA_TRUE;
-                  ec->ignored = 0;
-                  evas_object_show(ec->frame);
-                  cdata->mapped = 1;
-               }
-          }
+        e_client_show(ec);
 
         if ((cdata->sub.below_obj) &&
             (!evas_object_visible_get(cdata->sub.below_obj)) &&
@@ -4076,23 +4027,9 @@ e_comp_wl_surface_commit(E_Client *ec)
      {
         if (ec->comp_data->mapped)
           {
-             if (hide_by_request)
-               ELOGF("COMP", "Currenlty hide_by_request state2. pixmap_usable:%d", ec, pixmap_usable);
+             ELOGF("COMP", "Unmap. pixmap_usable:%d", ec, pixmap_usable);
 
-             if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.unmap))
-               {
-                  ELOGF("COMP", "Try to unmap2. Call shell.unmap.", ec);
-                  e_client_shell_unmap(ec);
-               }
-             else if (ec->internal || e_comp_wl_subsurface_check(ec) ||
-                      (ec == e_comp_wl->drag_client))
-               {
-                  ELOGF("COMP", "Try to unmap2. Hide window. internal:%d, sub:%p, drag:%d",
-                        ec, ec->internal, ec->comp_data->sub.data, (ec == e_comp_wl->drag_client));
-                  ec->visible = EINA_FALSE;
-                  evas_object_hide(ec->frame);
-                  ec->comp_data->mapped = 0;
-               }
+             e_client_hide(ec);
           }
 
         if (ec->comp_data->sub.below_obj && evas_object_visible_get(ec->comp_data->sub.below_obj))
@@ -4100,25 +4037,7 @@ e_comp_wl_surface_commit(E_Client *ec)
      }
    else
      {
-        if (!ec->comp_data->mapped)
-          {
-             if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.map) &&
-                 (!ec->ignored))
-               {
-                  ELOGF("COMP", "Try to map2. Call shell.map.", ec);
-                  e_client_shell_map(ec);
-               }
-             else if (ec->internal || e_comp_wl_subsurface_can_show(ec) ||
-                      (ec == e_comp_wl->drag_client))
-               {
-                  ELOGF("COMP", "Try to map2. Show window. internal:%d, drag:%d",
-                        ec, ec->internal, (ec == e_comp_wl->drag_client));
-                  ec->visible = EINA_TRUE;
-                  ec->ignored = 0;
-                  evas_object_show(ec->frame);
-                  ec->comp_data->mapped = 1;
-               }
-          }
+        e_client_show(ec);
 
         if (ec->comp_data->sub.below_obj && !evas_object_visible_get(ec->comp_data->sub.below_obj)
             && evas_object_visible_get(ec->frame))