e_tizen_wl_shell: make e_tizen_wl_shell_magnifier.c file 03/325603/1
authorSooChan Lim <sc1.lim@samsung.com>
Fri, 30 May 2025 01:18:09 +0000 (10:18 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 12 Jun 2025 10:40:32 +0000 (19:40 +0900)
Move the magnifier impelementation to this e_tizen_ws_shell_magnifier.c file.

Change-Id: Ia290e4673af03ea13bd24ad1333fa0347fca7d42

src/bin/Makefile.mk
src/bin/meson.build
src/bin/server/e_tizen_ws_shell_manager.c
src/bin/server/e_tizen_ws_shell_srv_magnifier.c [new file with mode: 0644]
src/bin/server/e_tizen_ws_shell_srv_magnifier_intern.h [new file with mode: 0644]

index 18bb20103824f29568144ac21d4c835c6b1bf43c..73e12434cb80517ba35b7e4ae4727dea71e9061c 100644 (file)
@@ -212,6 +212,7 @@ src/bin/server/e_tizen_ws_shell_srv_quickpanel.c \
 src/bin/server/e_tizen_ws_shell_srv_screensaver_manager.c \
 src/bin/server/e_tizen_ws_shell_srv_screensaver.c \
 src/bin/server/e_tizen_ws_shell_srv_softkey.c \
+src/bin/server/e_tizen_ws_shell_srv_magnifier.c \
 src/bin/server/e_tizen_indicator.c \
 src/bin/server/e_tizen_clipboard.c \
 src/bin/server/e_surface_view.c \
index 6ee9707cce3c444327250b27f76830d2ce375be7..ecb903cc62f678a26df2b9d776eebb22d4c80fb1 100644 (file)
@@ -216,6 +216,7 @@ e_sources = [
   'server/e_tizen_ws_shell_srv_screensaver_manager.c',
   'server/e_tizen_ws_shell_srv_screensaver.c',
   'server/e_tizen_ws_shell_srv_softkey.c',
+  'server/e_tizen_ws_shell_srv_magnifier.c',
   'server/e_tizen_indicator.c',
   'server/e_tizen_clipboard.c',
   'server/e_surface_view.c',
index e953338b7e76974542f652551820e772a3584847..acf9d2b880f42251d69cae2f6d95871d5c601e66 100644 (file)
@@ -13,7 +13,6 @@
 #include "e_screensaver_intern.h"
 #include "e_security_intern.h"
 #include "e_privilege_intern.h"
-#include "e_magnifier_intern.h"
 #include "e_config_intern.h"
 #include "e_tizen_ws_shell_srv_cbhm_intern.h"
 #include "e_tizen_ws_shell_srv_indicator_intern.h"
@@ -21,6 +20,7 @@
 #include "e_tizen_ws_shell_srv_screensaver_manager_intern.h"
 #include "e_tizen_ws_shell_srv_screensaver_intern.h"
 #include "e_tizen_ws_shell_srv_softkey_intern.h"
+#include "e_tizen_ws_shell_srv_magnifier_intern.h"
 
 #include <tzsh_server.h>
 
@@ -681,85 +681,10 @@ _tzsh_srv_iface_cb_softkey_get(struct wl_client *client, struct wl_resource *res
      }
 }
 
-static void
-_tzsh_srv_magnifier_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
-{
-   wl_resource_destroy(resource);
-}
-
-static void
-_tzsh_srv_magnifier_cb_zoom_geometry_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t angle, int32_t x, int32_t y, uint32_t w, uint32_t h)
-{
-   E_Tizen_Ws_Shell_Srv *tzsh_srv;
-   E_Client *ec;
-
-   tzsh_srv = wl_resource_get_user_data(resource);
-
-   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
-   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
-   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
-
-   ELOGF("TZSH", "[MAGNIFIER] Set Geometry. angle:%d, geo:%d,%d,%dx%d", tzsh_srv->ec, angle, x, y, w, h);
-
-   ec = tzsh_srv->ec;
-   // angle: 0, 90, 180, 270
-   e_magnifier_zoom_obj_geometry_set(ec, angle, x, y, w, h);
-}
-
-static void
-_tzsh_srv_magnifier_cb_ratio_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t ratio)
-{
-   E_Tizen_Ws_Shell_Srv *tzsh_srv;
-   E_Client *ec;
-
-   tzsh_srv = wl_resource_get_user_data(resource);
-
-   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
-   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
-   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
-
-   ELOGF("TZSH", "[MAGNIFIER] Set Ratio. ratio:%d", tzsh_srv->ec, ratio);
-
-   ec = tzsh_srv->ec;
-   // ratio : 100 ~ 200 (each 10)
-   e_magnifier_zoom_obj_ratio_set(ec, ratio);
-}
-
-static void
-_tzsh_srv_magnifier_cb_enable_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t enable)
-{
-   E_Tizen_Ws_Shell_Srv *tzsh_srv;
-   E_Client *ec;
-
-   tzsh_srv = wl_resource_get_user_data(resource);
-
-   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
-   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
-   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
-
-   ELOGF("TZSH", "[MAGNIFIER] Set Enable. enable:%d", tzsh_srv->ec, enable);
-
-   ec = tzsh_srv->ec;
-
-   if (enable)
-     e_magnifier_show(ec);
-   else
-     e_magnifier_hide(ec);
-}
-
-static const struct tws_service_magnifier_interface _tzsh_srv_magnifier_iface =
-{
-   _tzsh_srv_magnifier_cb_destroy,
-   _tzsh_srv_magnifier_cb_zoom_geometry_set,
-   _tzsh_srv_magnifier_cb_ratio_set,
-   _tzsh_srv_magnifier_cb_enable_set,
-};
-
 static void
 _tzsh_srv_iface_cb_magnifier_get(struct wl_client *client, struct wl_resource *res_tzsh_srv, uint32_t id)
 {
    E_Tizen_Ws_Shell_Srv *tzsh_srv;
-   struct wl_resource *res;
 
    tzsh_srv = wl_resource_get_user_data(res_tzsh_srv);
    EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
@@ -767,15 +692,24 @@ _tzsh_srv_iface_cb_magnifier_get(struct wl_client *client, struct wl_resource *r
    if (!eina_list_data_find(g_tizen_ws_shell_mgr->tzsh_srvs, tzsh_srv))
      return;
 
-   res = wl_resource_create(client, &tws_service_magnifier_interface, 1, id);
-   if (!res)
+   if (tzsh_srv->role != TZSH_SRV_ROLE_MAGNIFIER)
      {
-        wl_client_post_no_memory(client);
+        ERR("Could not find magnifier service");
+        tizen_ws_shell_send_error(res_tzsh_srv,
+                                   TIZEN_WS_SHELL_ERROR_NO_SERVICE);
         return;
      }
 
-   ELOGF("TZSH", "[MAGNIFIER] resource created. res:%p, res_tzsh_srv:%p, id:%d", NULL, res, res_tzsh_srv, id);
-   wl_resource_set_implementation(res, &_tzsh_srv_magnifier_iface, tzsh_srv, NULL);
+   tzsh_srv->client = client;
+   tzsh_srv->id = id;
+
+   if (!e_tizen_ws_shell_srv_magnifier_init(tzsh_srv))
+     {
+        ERR("e_tizen_ws_shell_srv_magnifier_init() failed.");
+        tizen_ws_shell_send_error(res_tzsh_srv,
+                                  TIZEN_WS_SHELL_ERROR_NOT_SUPPORTED);
+        return;
+     }
 }
 
 static void
diff --git a/src/bin/server/e_tizen_ws_shell_srv_magnifier.c b/src/bin/server/e_tizen_ws_shell_srv_magnifier.c
new file mode 100644 (file)
index 0000000..57a5ab9
--- /dev/null
@@ -0,0 +1,104 @@
+#include "e_tizen_ws_shell_srv_magnifier_intern.h"
+#include "e_magnifier_intern.h"
+
+#include <tzsh_server.h>
+
+static void
+_tzsh_srv_magnifier_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
+{
+   wl_resource_destroy(resource);
+}
+
+static void
+_tzsh_srv_magnifier_cb_zoom_geometry_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t angle, int32_t x, int32_t y, uint32_t w, uint32_t h)
+{
+   E_Tizen_Ws_Shell_Srv *tzsh_srv;
+   E_Client *ec;
+
+   tzsh_srv = wl_resource_get_user_data(resource);
+
+   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
+   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
+   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
+
+   ELOGF("TZSH", "[MAGNIFIER] Set Geometry. angle:%d, geo:%d,%d,%dx%d", tzsh_srv->ec, angle, x, y, w, h);
+
+   ec = tzsh_srv->ec;
+   // angle: 0, 90, 180, 270
+   e_magnifier_zoom_obj_geometry_set(ec, angle, x, y, w, h);
+}
+
+static void
+_tzsh_srv_magnifier_cb_ratio_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t ratio)
+{
+   E_Tizen_Ws_Shell_Srv *tzsh_srv;
+   E_Client *ec;
+
+   tzsh_srv = wl_resource_get_user_data(resource);
+
+   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
+   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
+   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
+
+   ELOGF("TZSH", "[MAGNIFIER] Set Ratio. ratio:%d", tzsh_srv->ec, ratio);
+
+   ec = tzsh_srv->ec;
+   // ratio : 100 ~ 200 (each 10)
+   e_magnifier_zoom_obj_ratio_set(ec, ratio);
+}
+
+static void
+_tzsh_srv_magnifier_cb_enable_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t enable)
+{
+   E_Tizen_Ws_Shell_Srv *tzsh_srv;
+   E_Client *ec;
+
+   tzsh_srv = wl_resource_get_user_data(resource);
+
+   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv);
+   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->tzsh);
+   EINA_SAFETY_ON_NULL_RETURN(tzsh_srv->ec);
+
+   ELOGF("TZSH", "[MAGNIFIER] Set Enable. enable:%d", tzsh_srv->ec, enable);
+
+   ec = tzsh_srv->ec;
+
+   if (enable)
+     e_magnifier_show(ec);
+   else
+     e_magnifier_hide(ec);
+}
+
+static const struct tws_service_magnifier_interface _tzsh_srv_magnifier_iface =
+{
+   _tzsh_srv_magnifier_cb_destroy,
+   _tzsh_srv_magnifier_cb_zoom_geometry_set,
+   _tzsh_srv_magnifier_cb_ratio_set,
+   _tzsh_srv_magnifier_cb_enable_set,
+};
+
+EINTERN Eina_Bool
+e_tizen_ws_shell_srv_magnifier_init(E_Tizen_Ws_Shell_Srv *tzsh_srv)
+{
+   struct wl_client *client;
+   struct wl_resource *res;
+   uint32_t id;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(tzsh_srv, EINA_FALSE);
+
+   client = tzsh_srv->client;
+   id = tzsh_srv->id;
+
+   res = wl_resource_create(client, &tws_service_magnifier_interface, 1, id);
+   if (!res)
+     {
+        wl_client_post_no_memory(client);
+        return EINA_FALSE;
+     }
+
+   wl_resource_set_implementation(res, &_tzsh_srv_magnifier_iface, tzsh_srv, NULL);
+
+   ELOGF("TZSH", "[MAGNIFIER] resource created. res:%p, id:%d", NULL, res, id);
+
+   return EINA_TRUE;
+}
diff --git a/src/bin/server/e_tizen_ws_shell_srv_magnifier_intern.h b/src/bin/server/e_tizen_ws_shell_srv_magnifier_intern.h
new file mode 100644 (file)
index 0000000..084ba92
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef E_TIZEN_WS_SHELL_SRV_MAGNIFIER_INTERN_H
+#define E_TIZEN_WS_SHELL_SRV_MAGNIFIER_INTERN_H
+
+#include "e_intern.h"
+#include "e_tizen_ws_shell_manager_intern.h"
+
+EINTERN Eina_Bool e_tizen_ws_shell_srv_magnifier_init(E_Tizen_Ws_Shell_Srv *tzsh_srv);
+
+#endif