screenshot: use shot wl event queue 38/103638/1
authorJunkyeong Kim <jk0430.kim@samsung.com>
Fri, 9 Dec 2016 04:39:19 +0000 (13:39 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Fri, 9 Dec 2016 04:39:22 +0000 (13:39 +0900)
Change-Id: I2457c82ae546106d31cf56f351a712620783aaeb
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
src/efl_util.c

index d564633..2436df1 100644 (file)
@@ -106,6 +106,7 @@ typedef struct _Efl_Util_Data
       } policy;
       struct
       {
+         struct wl_event_queue *queue;
          struct screenshooter *screenshooter;
          struct tizen_screenshooter *tz_screenshooter;
          struct wayland_tbm_client *tbm_client;
@@ -137,7 +138,7 @@ static Efl_Util_Data _eflutil =
       EINA_FALSE,
       NULL, NULL,
       { NULL, NULL, NULL }, /* tizen_policy protocol */
-      { NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
+      { NULL, NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
       { NULL, -1 } /* tizen_input_device_manager protocol */
    },
    {
@@ -472,6 +473,8 @@ _cb_wl_reg_screenshooter_global(void *data,
      {
         _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);
+
+        wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
      }
 }
 
@@ -1462,19 +1465,28 @@ efl_util_screenshot_initialize(int width, int height)
 
    if (!_eflutil.wl.shot.screenshooter)
      {
-        _wl_init();
+        ret = _wl_init();
+        if (ret == (int)EINA_FALSE)
+          {
+             set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
+             return NULL;
+          }
+        wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
 
         display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
         EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail_init);
 
-        wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.queue);
+        _eflutil.wl.shot.queue = wl_display_create_queue(_eflutil.wl.dpy);
+        EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.queue, fail_init);
 
         reg = wl_display_get_registry(display_wrapper);
         EINA_SAFETY_ON_NULL_GOTO(reg, fail_init);
 
+        wl_proxy_set_queue((struct wl_proxy*)reg, _eflutil.wl.shot.queue);
+
         wl_registry_add_listener(reg, &_wl_reg_screenshooter_listener, NULL);
 
-        ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+        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);
@@ -1483,9 +1495,6 @@ efl_util_screenshot_initialize(int width, int height)
         EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail_init);
      }
 
-   wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
-   wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
-
    if (_eflutil.wl.shot.noti == 0)
      {
         fprintf(stderr, "[screenshot] fail: privilege error\n"); /* LCOV_EXCL_LINE */
@@ -1547,6 +1556,12 @@ efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
    free(screenshot);
    g_screenshot = NULL;
 
+   if (_eflutil.wl.shot.queue)
+     {
+        wl_event_queue_destroy(_eflutil.wl.shot.queue);
+        _eflutil.wl.shot.queue = NULL;
+     }
+
    if (_eflutil.wl.shot.screenshooter)
      {
         screenshooter_destroy(_eflutil.wl.shot.screenshooter);
@@ -1601,7 +1616,7 @@ efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
 
    screenshot->shot_done = EINA_FALSE;
    while (!screenshot->shot_done && ret != -1)
-     ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+     ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
 
    if (ret == -1)
      {