screeenshot: use only tizen_screenshooter interface for one shot 29/276729/1
authorJunkyeong Kim <jk0430.kim@samsung.com>
Thu, 23 Jun 2022 12:00:13 +0000 (21:00 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Thu, 23 Jun 2022 12:00:19 +0000 (21:00 +0900)
use tizen_screenshooter interface version 3 shoot request and done event.
erase screenshooter interface related codes.

Change-Id: I13ca76bac9da7148495a43a8cb1cb11da8a047c1
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
src/efl_util.c

index a01896a..39022cf 100644 (file)
@@ -36,7 +36,6 @@
 #include <wayland-client.h>
 #include <wayland-tbm-client.h>
 #include <tizen-extension-client-protocol.h>
-#include <screenshooter-client-protocol.h>
 
 #include <efl_util_screenshot_extension.h>
 
@@ -156,7 +155,6 @@ typedef struct _Efl_Util_Data
       struct
       {
          struct wl_event_queue *queue;
-         struct screenshooter *screenshooter;
          struct tizen_screenshooter *tz_screenshooter;
          struct wayland_tbm_client *tbm_client;
          Eina_List *output_list;
@@ -208,7 +206,7 @@ static Efl_Util_Data _eflutil =
       EINA_FALSE,
       NULL, NULL, NULL,
       { 0, NULL, NULL, NULL }, /* tizen_policy protocol */
-      { NULL, NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
+      { NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
       { NULL, -1, NULL, NULL, NULL, 0, 0 }, /* tizen_input_device_manager protocol */
       NULL, /* wl_seat protocol */
       { 0, NULL, NULL } /* display_policy protocol */
@@ -458,33 +456,29 @@ static const struct wl_output_listener output_listener =
 };
 
 static void
-_cb_wl_screenshot_done(void *data, struct screenshooter *screenshooter)
+_cb_tz_screenshot_format(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t format)
 {
-   Eina_Bool *shot_done = (Eina_Bool*)data;
-   if (shot_done)
-     *shot_done = EINA_TRUE;
 }
 
-static const struct screenshooter_listener screenshooter_listener =
-{
-    _cb_wl_screenshot_done
-};
-
 static void
-_cb_tz_screenshot_format(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t format)
+_cb_tz_screenshot_noti(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t noti)
 {
+   _eflutil.wl.shot.noti = noti;
 }
 
 static void
-_cb_tz_screenshot_noti(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t noti)
+_cb_tz_screenshot_done(void *data, struct tizen_screenshooter *tz_screenshooter)
 {
-   _eflutil.wl.shot.noti = noti;
+   Eina_Bool *shot_done = (Eina_Bool*)data;
+   if (shot_done)
+     *shot_done = EINA_TRUE;
 }
 
 static const struct tizen_screenshooter_listener tz_screenshooter_listener =
 {
     _cb_tz_screenshot_format,
-    _cb_tz_screenshot_noti
+    _cb_tz_screenshot_noti,
+    _cb_tz_screenshot_done,
 };
 
 static void
@@ -622,12 +616,7 @@ _cb_wl_reg_screenshooter_global(void *data,
                   const char *interface,
                   unsigned int version)
 {
-   if (strcmp(interface, "screenshooter") == 0)
-     {
-        _eflutil.wl.shot.screenshooter = wl_registry_bind(reg, name, &screenshooter_interface, version);
-        screenshooter_add_listener(_eflutil.wl.shot.screenshooter, &screenshooter_listener, NULL);
-     }
-   else if (strcmp(interface, "tizen_screenshooter") == 0)
+   if (strcmp(interface, "tizen_screenshooter") == 0)
      {
         _eflutil.wl.shot.tz_screenshooter = wl_registry_bind(reg, name, &tizen_screenshooter_interface, version);
         tizen_screenshooter_add_listener(_eflutil.wl.shot.tz_screenshooter, &tz_screenshooter_listener, NULL);
@@ -2135,7 +2124,7 @@ efl_util_screenshot_initialize(int width, int height)
         EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_memory);
      }
 
-   if (!_eflutil.wl.shot.screenshooter)
+   if (!_eflutil.wl.shot.tz_screenshooter)
      {
         ret = _wl_init();
         if (ret == (int)EINA_FALSE)
@@ -2165,7 +2154,6 @@ efl_util_screenshot_initialize(int width, int height)
 
         ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
         EINA_SAFETY_ON_TRUE_GOTO(ret == -1, fail_init);
-        EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.screenshooter, fail_init);
         EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tz_screenshooter, fail_init);
 
         _eflutil.wl.shot.tbm_client = wayland_tbm_client_init(_eflutil.wl.dpy);
@@ -2205,7 +2193,7 @@ efl_util_screenshot_initialize(int width, int height)
    g_screenshot = screenshot;
    set_last_result(EFL_UTIL_ERROR_NONE);
 
-   screenshooter_set_user_data(_eflutil.wl.shot.screenshooter, &screenshot->shot_done);
+   tizen_screenshooter_set_user_data(_eflutil.wl.shot.tz_screenshooter, &screenshot->shot_done);
 
    _screenshot_mutex_unlock();
 
@@ -2258,11 +2246,6 @@ efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
         _eflutil.wl.shot.tbm_client = NULL;
      }
 
-   if (_eflutil.wl.shot.screenshooter)
-     {
-        screenshooter_destroy(_eflutil.wl.shot.screenshooter);
-        _eflutil.wl.shot.screenshooter = NULL;
-     }
    if (_eflutil.wl.shot.tz_screenshooter)
      {
         tizen_screenshooter_destroy(_eflutil.wl.shot.tz_screenshooter);
@@ -2320,15 +2303,16 @@ efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
         goto fail;
      }
 
-   screenshooter_shoot(_eflutil.wl.shot.screenshooter, output->output, buffer);
+   tizen_screenshooter_shoot(_eflutil.wl.shot.tz_screenshooter, output->output, buffer);
 
    screenshot->shot_done = EINA_FALSE;
+
    while (!screenshot->shot_done && ret != -1)
      ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
 
    if (ret == -1)
      {
-        fprintf(stderr, "[screenshot] fail: screenshooter_shoot\n"); /* LCOV_EXCL_LINE */
+        fprintf(stderr, "[screenshot] fail: tizen_screenshooter_shoot\n"); /* LCOV_EXCL_LINE */
         goto fail;
      }