e_client: Add e_client_shell APIs and refactor 08/304508/1
authorSeunghun Lee <shiin.lee@samsung.com>
Tue, 5 Dec 2023 02:01:00 +0000 (11:01 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 18 Jan 2024 06:30:43 +0000 (15:30 +0900)
This commit introduces a new set of APIs under the `e_client_shell`
namespace, which are designed to provide an easier and more intuitive
way to interact with the shell component in the e_client.

These APIs replace the previous approach of directly accessing
`ec->comp_data->shell`, resulting in improved code organization and
maintainability.

Change-Id: Iec4c951b8e0acc51cbccc310fcc8edf40232fd95

src/bin/e_client.c
src/bin/e_client_intern.h
src/bin/e_comp_wl.c
src/bin/e_comp_wl_rsm.c
src/bin/e_comp_wl_shell.c
src/bin/e_eom.c
src/bin/e_output.c
src/bin/e_policy_wl.c

index 87a2747..17a2173 100644 (file)
@@ -7090,3 +7090,68 @@ e_client_destroy_listener_get(E_Client *ec, wl_notify_func_t notify)
    API_ENTRY_VAL(NULL);
    return wl_signal_get(&priv->events.destroy, notify);
 }
+
+EINTERN void
+e_client_shell_configure_send(E_Client *ec, uint32_t edges, int32_t width, int32_t height)
+{
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+   EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
+
+   if ((!ec->comp_data->shell.surface) ||
+       (!ec->comp_data->shell.configure_send))
+     return;
+
+   ec->comp_data->shell.configure_send(ec->comp_data->shell.surface, edges, width, height);
+}
+
+EINTERN void
+e_client_shell_configure(E_Client *ec, Evas_Coord x, Evas_Coord y, Evas_Coord width, Evas_Coord height)
+{
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+   EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
+
+   if ((!ec->comp_data->shell.surface) ||
+       (!ec->comp_data->shell.configure))
+     return;
+
+   ec->comp_data->shell.configure(ec->comp_data->shell.surface, x, y, width, height);
+}
+
+EINTERN void
+e_client_shell_ping(E_Client *ec)
+{
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+   EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
+
+   if ((!ec->comp_data->shell.surface) ||
+       (!ec->comp_data->shell.ping))
+     return;
+
+   ec->comp_data->shell.ping(ec->comp_data->shell.surface);
+}
+
+EINTERN void
+e_client_shell_map(E_Client *ec)
+{
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+   EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
+
+   if ((!ec->comp_data->shell.surface) ||
+       (!ec->comp_data->shell.map))
+     return;
+
+   ec->comp_data->shell.map(ec->comp_data->shell.surface);
+}
+
+EINTERN void
+e_client_shell_unmap(E_Client *ec)
+{
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+   EINA_SAFETY_ON_NULL_RETURN(ec->comp_data);
+
+   if ((!ec->comp_data->shell.surface) ||
+       (!ec->comp_data->shell.unmap))
+     return;
+
+   ec->comp_data->shell.unmap(ec->comp_data->shell.surface);
+}
index 36c717a..c527552 100644 (file)
@@ -57,4 +57,10 @@ 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_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 7b2e575..8144ac2 100644 (file)
@@ -2,6 +2,7 @@
 #include "e_foreign.h"
 #include "e_wtz_shell.h"
 #include "e_comp_wl_private.h"
+#include "e_client_intern.h"
 #include <tizen-extension-server-protocol.h>
 
 #include <relative-pointer-unstable-v1-server-protocol.h>
@@ -220,9 +221,7 @@ _e_comp_wl_configure_send(E_Client *ec, Eina_Bool edges, Eina_Bool send_size)
         w = h = -1;
      }
 
-   ec->comp_data->shell.configure_send(ec->comp_data->shell.surface,
-                                       edges * e_comp_wl->resize.edges,
-                                       w, h);
+   e_client_shell_configure_send(ec, edges * e_comp_wl->resize.edges, w, h);
 }
 
 static void
@@ -2174,9 +2173,7 @@ _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event
         h = E_CLAMP(h, 1, h);
         e_client_resize_limit(ec, &w, &h);
 
-        ec->comp_data->shell.configure_send(ec->comp_data->shell.surface,
-                                            e_comp_wl->resize.edges,
-                                            w, h);
+        e_client_shell_configure_send(ec, e_comp_wl->resize.edges, w, h);
      }
    else if ((!ec->fullscreen) && (!ec->maximized) &&
             (!ec->comp_data->maximize_pre))
@@ -2210,11 +2207,9 @@ _e_comp_wl_evas_cb_maximize_done(void *data, Evas_Object *obj EINA_UNUSED, void
 
    if (e_object_is_del(E_OBJECT(ec))) return;
 
-   if (ec->comp_data->shell.configure_send)
-     {
-        e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
-        ec->comp_data->shell.configure_send(ec->comp_data->shell.surface, 0, w, h);
-     }
+   e_client_maximized_geometry_get(ec, NULL, NULL, &w, &h);
+   e_client_shell_configure_send(ec, 0, w, h);
+
    ec->comp_data->maximize_pre = 0;
 }
 
@@ -2315,11 +2310,8 @@ _e_comp_wl_evas_cb_ping(void *data, Evas_Object *obj EINA_UNUSED, void *event EI
    E_Client *ec;
 
    if (!(ec = data)) return;
-   if (!(ec->comp_data)) return;
-   if (!(ec->comp_data->shell.ping)) return;
-   if (!(ec->comp_data->shell.surface)) return;
 
-   ec->comp_data->shell.ping(ec->comp_data->shell.surface);
+   e_client_shell_ping(ec);
 }
 
 static void
@@ -2986,7 +2978,7 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
                          }
                        ec->show_pending.running = EINA_FALSE;
                     }
-                  cdata->shell.unmap(cdata->shell.surface);
+                  e_client_shell_unmap(ec);
                }
              else if ((ec->internal) ||
                       (e_comp_wl_subsurface_check(ec)) ||
@@ -3016,7 +3008,7 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state)
                  (!ec->ignored))
                {
                   ELOGF("COMP", "Try to map. Call shell.map.", ec);
-                  cdata->shell.map(cdata->shell.surface);
+                  e_client_shell_map(ec);
                }
              else if ((ec->internal) ||
                       (e_comp_wl_subsurface_can_show(ec)) ||
@@ -4090,7 +4082,7 @@ e_comp_wl_surface_commit(E_Client *ec)
              if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.unmap))
                {
                   ELOGF("COMP", "Try to unmap2. Call shell.unmap.", ec);
-                  ec->comp_data->shell.unmap(ec->comp_data->shell.surface);
+                  e_client_shell_unmap(ec);
                }
              else if (ec->internal || e_comp_wl_subsurface_check(ec) ||
                       (ec == e_comp_wl->drag_client))
@@ -4114,7 +4106,7 @@ e_comp_wl_surface_commit(E_Client *ec)
                  (!ec->ignored))
                {
                   ELOGF("COMP", "Try to map2. Call shell.map.", ec);
-                  ec->comp_data->shell.map(ec->comp_data->shell.surface);
+                  e_client_shell_map(ec);
                }
              else if (ec->internal || e_comp_wl_subsurface_can_show(ec) ||
                       (ec == e_comp_wl->drag_client))
@@ -5521,13 +5513,7 @@ e_comp_wl_commit_sync_configure(E_Client *ec)
    // cw interceptor(move,resize) won't work if wait_commit is TRUE
    ec->surface_sync.wait_commit = EINA_FALSE;
 
-   if ((ec->comp_data->shell.surface) &&
-       (ec->comp_data->shell.configure))
-     {
-        ec->comp_data->shell.configure(ec->comp_data->shell.surface,
-                                       ec->x, ec->y,
-                                       ec->w, ec->h);
-     }
+   e_client_shell_configure(ec, ec->x, ec->y, ec->w, ec->h);
 
    // rollback wait_commit if there are pending requests remained
    if (eina_list_count(ec->surface_sync.pending_geometry))
index 1ae81b8..da5d28d 100644 (file)
@@ -1,6 +1,7 @@
 #include "e.h"
 #include "e_policy_wl.h"
 #include "e_device.h"
+#include "e_client_intern.h"
 #include <tizen-remote-surface-server-protocol.h>
 #include <tbm_surface.h>
 #include <tbm_surface_internal.h>
@@ -360,7 +361,7 @@ _remote_provider_offscreen_set(E_Comp_Wl_Remote_Provider* provider, Eina_Bool se
         if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.unmap))
           {
              ELOGF("COMP", "Call shell.unmap by rsm", ec);
-             ec->comp_data->shell.unmap(ec->comp_data->shell.surface);
+             e_client_shell_unmap(ec);
           }
         else
           {
@@ -3015,9 +3016,7 @@ _e_comp_wl_remote_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *st
         ec->client.h = state->bh;
         e_client_size_set(ec, state->bw, state->bh);
 
-        if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.configure))
-          ec->comp_data->shell.configure(ec->comp_data->shell.surface,
-                                         x, y, ec->w, ec->h);
+        e_client_shell_configure(ec, x, y, ec->w, ec->h);
      }
 
    sx = state->sx;
index cc33d04..4cccbc5 100644 (file)
@@ -1,4 +1,5 @@
 #include "e.h"
+#include "e_client_intern.h"
 #include <xdg-shell-unstable-v5-server-protocol.h>
 #include <xdg-shell-unstable-v6-server-protocol.h>
 #include <tizen-extension-server-protocol.h>
@@ -404,12 +405,8 @@ e_shell_e_client_destroy(E_Client *ec)
      {
         if (ec->comp_data->mapped)
           {
-             if ((ec->comp_data->shell.surface) &&
-                 (ec->comp_data->shell.unmap))
-               {
-                  ELOGF("SHELL", "Call shell.unmap by destroy surface", ec);
-                  ec->comp_data->shell.unmap(ec->comp_data->shell.surface);
-               }
+             ELOGF("SHELL", "Call shell.unmap by destroy surface", ec);
+             e_client_shell_unmap(ec);
           }
         e_policy_client_unmap(ec);
      }
index 5171cce..aef9eca 100644 (file)
@@ -3,6 +3,7 @@
 #endif
 
 #include "e.h"
+#include "e_client_intern.h"
 #include <xdg-shell-unstable-v5-server-protocol.h>
 #include <eom-server-protocol.h>
 #include <eom.h>
@@ -402,7 +403,7 @@ _e_eom_output_send_configure_event(E_EomOutput *eom_output, E_Client *ec)
 
    /* get the output size */
    e_output_size_get(eom_output->output, &w, &h);
-   cdata->shell.configure_send(cdata->shell.surface, 0, w, h);
+   e_client_shell_configure_send(ec, 0, w, h);
 
    EOMINF("Send Configure Event for Presentation (%d X %d)", ec, eom_output->output, w, h);
 
index 9c9644d..82d0fb0 100644 (file)
@@ -1,4 +1,5 @@
 #include "e.h"
+#include "e_client_intern.h"
 #include <device/board-internal.h>
 
 #define EOERR(f, output, x...)             \
@@ -714,18 +715,13 @@ static void
 _e_output_client_resize(int w, int h)
 {
    E_Client *ec = NULL;
-   E_Comp_Wl_Client_Data *cdata;
 
    E_CLIENT_FOREACH(ec)
      {
         if ((ec->visible && !ec->input_only) ||
            (e_client_util_name_get(ec) != NULL && !ec->input_only))
           {
-             cdata = e_client_cdata_get(ec);
-             if (cdata == NULL) continue;
-             if (cdata->shell.configure_send == NULL) continue;
-
-             cdata->shell.configure_send(cdata->shell.surface, 0, w ,h);
+             e_client_shell_configure_send(ec, 0, w, h);
           }
      }
 }
index f202534..4ce7ba5 100644 (file)
@@ -15,6 +15,7 @@
 #include "e_policy_visibility.h"
 #include "e_appinfo.h"
 #include "e_subsurface_watcher.h"
+#include "e_client_intern.h"
 
 #include <device/display.h>
 #include <wayland-server.h>
@@ -3686,14 +3687,7 @@ _tzpol_iface_cb_set_layout(struct wl_client *client EINA_UNUSED, struct wl_resou
    e_client_frame_geometry_set(ec, x, y, w, h);
 
    if (!ec->visible)
-     {
-        E_Comp_Wl_Client_Data *cdata;
-        cdata = e_client_cdata_get(ec);
-        if (cdata && cdata->shell.configure_send && cdata->shell.surface)
-          {
-             cdata->shell.configure_send(cdata->shell.surface, 0, w, h);
-          }
-     }
+     e_client_shell_configure_send(ec, 0, w, h);
 }
 
 // --------------------------------------------------------
@@ -8386,7 +8380,7 @@ e_policy_wl_clipboard_data_selected_send(E_Client *ec)
 static void
 _e_policy_wl_cb_hook_shell_surface_ready(void *d, E_Client *ec)
 {
-   E_Comp_Wl_Client_Data *cdata;
+   int w = 0, h = 0;
 
    if (EINA_UNLIKELY(!ec))
      return;
@@ -8397,18 +8391,12 @@ _e_policy_wl_cb_hook_shell_surface_ready(void *d, E_Client *ec)
 
    e_client_base_output_resolution_transform_adjust(ec);
 
-   cdata = e_client_cdata_get(ec);
-   if ((cdata->shell.configure_send) &&
-       (cdata->shell.surface))
+   if (ec->lock_client_size)
      {
-        int w = 0, h = 0;
-        if (ec->lock_client_size)
-          {
-             w = ec->w;
-             h = ec->h;
-          }
-        cdata->shell.configure_send(cdata->shell.surface, 0, w, h);
+        w = ec->w;
+        h = ec->h;
      }
+   e_client_shell_configure_send(ec, 0, w, h);
 }
 
 static void