* limitations under the License.
*/
+#define _GNU_SOURCE
+
#define LOG_TAG "TIZEN_N_EFL_UTIL"
#include <efl_util.h>
#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>
#undef LOG_TAG
#endif
-/* Determine Tizen profile at runtime */
-#include <system_info.h>
-typedef enum {
- TIZEN_PROFILE_UNKNOWN = 0,
- TIZEN_PROFILE_MOBILE = 0x1,
- TIZEN_PROFILE_WEARABLE = 0x2,
- TIZEN_PROFILE_TV = 0x4,
- TIZEN_PROFILE_IVI = 0x8,
- TIZEN_PROFILE_COMMON = 0x10,
-} tizen_profile_t;
-static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
-static tizen_profile_t _get_tizen_profile()
-{
- char *profileName;
- system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
- switch (*profileName) {
- case 'm':
- case 'M':
- profile = TIZEN_PROFILE_MOBILE;
- break;
- case 'w':
- case 'W':
- profile = TIZEN_PROFILE_WEARABLE;
- break;
- case 't':
- case 'T':
- profile = TIZEN_PROFILE_TV;
- break;
- case 'i':
- case 'I':
- profile = TIZEN_PROFILE_IVI;
- break;
- default: // common or unknown ==> ALL ARE COMMON.
- profile = TIZEN_PROFILE_COMMON;
- }
- free(profileName);
-
- return profile;
-}
-static inline tizen_profile_t get_tizen_profile()
-{
- if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
- return profile;
- return _get_tizen_profile();
-}
-
-
#define LOG_TAG "TIZEN_N_EFL_UTIL"
-#define EFL_UTIL_INPUT_GENERATOR_DEFAULT_TIME_OUT 1000
-#define EFL_UTIL_INPUT_GENERATOR_DEFAULT_DISPATCH_TIME_OUT 10
#define EFL_UTIL_INPUT_GENERATOR_TOUCH_MAX_FINGER 10
+#define NUM_EVENT_WAIT_DONE_COUNT 10
+
typedef struct _Efl_Util_Wl_Surface_Lv_Info
{
void *surface; /* wl_surface */
Efl_Util_Gesture_Common_Grab_Data base;
} Efl_Util_Gesture_Palm_Cover_Grab_Data;
-typedef struct _Efl_Util_Device_Info
-{
- struct tizen_input_device *device;
- Ecore_Device_Class clas;
- Eina_Stringshare *name;
-} Efl_Util_Device_Info;
-
typedef struct _E_Devicemgr_Inputgen_Touch_Axis
{
double radius_x;
struct
{
struct wl_event_queue *queue;
- struct screenshooter *screenshooter;
struct tizen_screenshooter *tz_screenshooter;
struct wayland_tbm_client *tbm_client;
Eina_List *output_list;
Eina_List *devices;
Eina_List *wait_devices;
struct wl_event_source *wait_timer;
+ int max_touch_count;
+ int request_touch_count;
} devmgr;
struct
{
EINA_FALSE,
NULL, NULL, NULL,
{ 0, NULL, NULL, NULL }, /* tizen_policy protocol */
- { NULL, NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
- { NULL, -1, NULL, NULL, NULL }, /* tizen_input_device_manager protocol */
+ { NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
+ { NULL, -1, NULL, NULL, NULL, 0, 0 }, /* tizen_input_device_manager protocol */
{ 0, NULL, NULL } /* display_policy protocol */
},
};
static void _cb_wl_tz_display_policy_brightness_done(void *data, struct tizen_display_policy *tizen_display_policy, struct wl_surface *surface_resource, int32_t brightness, uint32_t state);
-static void _cb_device_info(void *data, struct tizen_input_device *tizen_input_device EINA_UNUSED, const char *name, uint32_t clas, uint32_t subclas EINA_UNUSED, struct wl_array *axes EINA_UNUSED);
-static void _cb_event_device(void *data EINA_UNUSED, struct tizen_input_device *tizen_input_device EINA_UNUSED, unsigned int serial EINA_UNUSED, const char *name EINA_UNUSED, uint32_t time EINA_UNUSED);
-static void _cb_axis(void *data EINA_UNUSED, struct tizen_input_device *tizen_input_device EINA_UNUSED, uint32_t axis_type EINA_UNUSED, wl_fixed_t value EINA_UNUSED);
-
static void _cb_device_add(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t serial EINA_UNUSED, const char *identifier EINA_UNUSED, struct tizen_input_device *device EINA_UNUSED, struct wl_seat *seat EINA_UNUSED);
static void _cb_device_remove(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t serial EINA_UNUSED, const char *identifier EINA_UNUSED, struct tizen_input_device *device EINA_UNUSED, struct wl_seat *seat EINA_UNUSED);
static void _cb_error(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t errorcode);
static void _cb_block_expired(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED);
+static void _cb_max_touch_count(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t serial EINA_UNUSED, int32_t max_count EINA_UNUSED, struct wl_seat *seat EINA_UNUSED);
static void _cb_gesture_edge_swipe_notify(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t fingers EINA_UNUSED, uint32_t edge EINA_UNUSED, uint32_t edge_size EINA_UNUSED, uint32_t start_point EINA_UNUSED, uint32_t end_point EINA_UNUSED, uint32_t error);
static void _cb_gesture_edge_swipe(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, int sx, int sy, uint32_t edge);
_cb_wl_conformant_region,
};
-static const struct tizen_input_device_listener _wl_tz_input_device_listener =
-{
- _cb_device_info,
- _cb_event_device,
- _cb_axis,
-};
-
struct tizen_input_device_manager_listener _wl_tz_devmgr_listener =
{
_cb_device_add,
_cb_device_remove,
_cb_error,
- _cb_block_expired
+ _cb_block_expired,
+ _cb_max_touch_count
};
struct tizen_display_policy_listener _wl_tz_display_policy_listener =
return EINA_TRUE;
fail:
- if (display_wrapper)
- wl_proxy_wrapper_destroy(display_wrapper);
ecore_wl2_shutdown();
return EINA_FALSE;
};
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
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);
if (lv_info->wait_for_done)
{
int count = 0;
- while (lv_info->wait_for_done && (count < 3))
+ while (lv_info->wait_for_done && (count < NUM_EVENT_WAIT_DONE_COUNT))
{
ecore_wl2_display_flush(_eflutil.wl.wl2_display);
wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
if (lv_info->wait_for_done)
{
int count = 0;
- while ((lv_info->wait_for_done) && (count < 3))
+ while ((lv_info->wait_for_done) && (count < NUM_EVENT_WAIT_DONE_COUNT))
{
ecore_wl2_display_flush(_eflutil.wl.wl2_display);
wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
if (scr_mode_info->wait_for_done)
{
int count = 0;
- while (scr_mode_info->wait_for_done && (count < 3))
+ while (scr_mode_info->wait_for_done && (count < NUM_EVENT_WAIT_DONE_COUNT))
{
ecore_wl2_display_flush(_eflutil.wl.wl2_display);
wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
if (brightness_info->wait_for_done)
{
int count = 0;
- while (brightness_info->wait_for_done && (count < 3))
+ while (brightness_info->wait_for_done && (count < NUM_EVENT_WAIT_DONE_COUNT))
{
ecore_wl2_display_flush(_eflutil.wl.wl2_display);
wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
return EFL_UTIL_ERROR_NONE;
}
-
struct _efl_util_inputgen_h
{
unsigned int init_type;
E_Devicemgr_Inputgen_Touch_Axis *axis_info;
};
-static Eina_Bool
-_efl_util_input_check_wait_device_full(void)
-{
- Eina_List *l, *ll, *l_next;
- Efl_Util_Device_Info *dev, *wait_dev;
- int wait_cnt = 0;
-
- wait_cnt = eina_list_count(_eflutil.wl.devmgr.wait_devices);
- if (wait_cnt <= 0) return EINA_TRUE;
-
- EINA_LIST_FOREACH(_eflutil.wl.devmgr.devices, l, dev)
- {
- EINA_LIST_FOREACH_SAFE(_eflutil.wl.devmgr.wait_devices, ll, l_next, wait_dev)
- {
- if ((dev->clas == wait_dev->clas) &&
- (!strncmp(dev->name, wait_dev->name, eina_stringshare_strlen(wait_dev->name))))
- {
- eina_stringshare_del(wait_dev->name);
- _eflutil.wl.devmgr.wait_devices = eina_list_remove_list(_eflutil.wl.devmgr.wait_devices, ll);
- free(wait_dev);
-
- wait_cnt--;
- if (wait_cnt <= 0) return EINA_TRUE;
-
- break;
- }
- }
- }
-
- return EINA_FALSE;
-}
-
-static Eina_Bool
-_efl_util_input_check_wait_device(const char *name, unsigned int type)
-{
- Eina_List *l, *l_next;
- Efl_Util_Device_Info *wait_dev;
- int wait_cnt = 0;
-
- wait_cnt = eina_list_count(_eflutil.wl.devmgr.wait_devices);
- if (wait_cnt <= 0) return EINA_TRUE;
-
- EINA_LIST_FOREACH_SAFE(_eflutil.wl.devmgr.wait_devices, l, l_next, wait_dev)
- {
- if ((type == wait_dev->clas) &&
- (!strncmp(name, wait_dev->name, eina_stringshare_strlen(wait_dev->name))))
- {
- eina_stringshare_del(wait_dev->name);
- _eflutil.wl.devmgr.wait_devices = eina_list_remove_list(_eflutil.wl.devmgr.wait_devices, l);
- free(wait_dev);
-
- wait_cnt--;
- if (wait_cnt <= 0) return EINA_TRUE;
-
- break;
- }
- }
-
- return EINA_FALSE;
-}
-
-static void
-_cb_device_info(void *data, struct tizen_input_device *tizen_input_device EINA_UNUSED, const char *name, uint32_t clas, uint32_t subclas EINA_UNUSED, struct wl_array *axes EINA_UNUSED)
-{
- Efl_Util_Device_Info *dev;
-
- if (!(dev = data)) return;
- dev->clas = (Ecore_Device_Class)clas;
- dev->name = eina_stringshare_add(name);
-
- if (_eflutil.wl.devmgr.wait_timer &&
- _efl_util_input_check_wait_device(name, clas))
- {
- wl_event_source_remove(_eflutil.wl.devmgr.wait_timer);
- _eflutil.wl.devmgr.wait_timer = NULL;
- }
-}
-
-/* LCOV_EXCL_START */
-static void
-_cb_event_device(void *data EINA_UNUSED, struct tizen_input_device *tizen_input_device EINA_UNUSED, unsigned int serial EINA_UNUSED, const char *name EINA_UNUSED, uint32_t time EINA_UNUSED)
-{
- ;
-}
-
-static void
-_cb_axis(void *data EINA_UNUSED, struct tizen_input_device *tizen_input_device EINA_UNUSED, uint32_t axis_type EINA_UNUSED, wl_fixed_t value EINA_UNUSED)
-{
- ;
-}
-/* LCOV_EXCL_STOP */
-
static void
_cb_device_add(void *data EINA_UNUSED,
struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
struct tizen_input_device *device,
struct wl_seat *seat EINA_UNUSED)
{
- Efl_Util_Device_Info *dev;
-
- EINA_SAFETY_ON_NULL_RETURN(device);
-
- dev = (Efl_Util_Device_Info *)calloc(1, sizeof(Efl_Util_Device_Info));
- EINA_SAFETY_ON_NULL_RETURN(dev);
-
- dev->device = device;
- tizen_input_device_add_listener(device, &_wl_tz_input_device_listener, dev);
-
- _eflutil.wl.devmgr.devices = eina_list_append(_eflutil.wl.devmgr.devices, dev);
+ ;
}
static void
struct tizen_input_device *device,
struct wl_seat *seat EINA_UNUSED)
{
- Eina_List *l, *l_next;
- Efl_Util_Device_Info *dev;
-
- EINA_LIST_FOREACH_SAFE(_eflutil.wl.devmgr.devices, l, l_next, dev)
- {
- if (dev->device == device)
- {
- if (dev->name) eina_stringshare_del(dev->name);
- tizen_input_device_release(dev->device);
-
- _eflutil.wl.devmgr.devices = eina_list_remove_list(_eflutil.wl.devmgr.devices, l);
- free(dev);
-
- break;
- }
- }
+ ;
}
static void
}
/* LCOV_EXCL_STOP */
+static void
+_cb_max_touch_count(void *data EINA_UNUSED,
+ struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
+ uint32_t serial EINA_UNUSED,
+ int32_t max_count,
+ struct wl_seat *seat EINA_UNUSED)
+{
+ _eflutil.wl.devmgr.max_touch_count = max_count;
+}
+
static efl_util_error_e
_efl_util_input_convert_input_generator_error(int ret)
{
return EFL_UTIL_ERROR_OUT_OF_MEMORY;
case TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER:
return EFL_UTIL_ERROR_INVALID_PARAMETER;
+ case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NOT_ALLOWED:
+ return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
default :
return EFL_UTIL_ERROR_NONE;
}
}
-/* LCOV_EXCL_START */
-static int
-_timer_wait(void *data)
-{
- Efl_Util_Device_Info *dev;
-
- _eflutil.wl.devmgr.request_notified = TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES;
-
- if (eina_list_count(_eflutil.wl.devmgr.wait_devices) > 0)
- {
- EINA_LIST_FREE(_eflutil.wl.devmgr.wait_devices, dev)
- {
- eina_stringshare_del(dev->name);
- dev->name = NULL;
- }
- }
-
- wl_event_source_remove(_eflutil.wl.devmgr.wait_timer);
- _eflutil.wl.devmgr.wait_timer = NULL;
-
- return 1;
-}
-/* LCOV_EXCL_STOP */
-
-static void
-_efl_util_input_initialize_wait_device(void)
-{
- struct wl_event_loop *loop;
- int ret = -1;
-
- if (_efl_util_input_check_wait_device_full()) return;
-
- loop = wl_event_loop_create();
- _eflutil.wl.devmgr.wait_timer = wl_event_loop_add_timer(loop, _timer_wait, NULL);
- if (_eflutil.wl.devmgr.wait_timer)
- {
- ret = wl_event_source_timer_update(_eflutil.wl.devmgr.wait_timer,
- EFL_UTIL_INPUT_GENERATOR_DEFAULT_TIME_OUT);
- if (ret != 0) _timer_wait(NULL);
- return;
- }
-
- while (_eflutil.wl.devmgr.wait_timer)
- {
- wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
- ret = wl_event_loop_dispatch(loop, EFL_UTIL_INPUT_GENERATOR_DEFAULT_DISPATCH_TIME_OUT);
- if (ret != 0) _timer_wait(NULL);
- }
-}
-
-static void
-_efl_util_input_initialize_append_device(const char *name, Ecore_Device_Class clas)
-{
- Efl_Util_Device_Info *dev;
-
- dev = (Efl_Util_Device_Info *)calloc(1, sizeof(Efl_Util_Device_Info));
- EINA_SAFETY_ON_NULL_RETURN(dev);
-
- dev->name = eina_stringshare_add(name);
- dev->clas = clas;
-
- _eflutil.wl.devmgr.wait_devices = eina_list_append(_eflutil.wl.devmgr.wait_devices, dev);
-}
-
-static void
-_efl_util_input_initialize_add_wait_device(const char *name, unsigned int dev_type)
-{
- EINA_SAFETY_ON_NULL_RETURN(name);
-
- if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
- _efl_util_input_initialize_append_device(name, ECORE_DEVICE_CLASS_TOUCH);
-
- if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
- _efl_util_input_initialize_append_device(name, ECORE_DEVICE_CLASS_KEYBOARD);
-
- if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
- _efl_util_input_initialize_append_device(name, ECORE_DEVICE_CLASS_MOUSE);
-}
-
-API efl_util_inputgen_h
-efl_util_input_initialize_generator(unsigned int dev_type)
+static efl_util_inputgen_h
+_efl_util_input_create_inputgen(unsigned int dev_type, const char *name, int *ret, int with_name)
{
- int ret = EFL_UTIL_ERROR_NONE;
efl_util_inputgen_h inputgen_h = NULL;
unsigned int clas = 0x0;
}
inputgen_h->init_type |= dev_type;
+ if (with_name)
+ {
+ if (name) strncpy(inputgen_h->name, name, 31);
+ else strncpy(inputgen_h->name, "Input Generator", 31);
+ }
- ret = _wl_init();
- if (ret == (int)EINA_FALSE)
+ *ret = _wl_init();
+ if (*ret == (int)EINA_FALSE)
{
set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
goto out;
while (!_eflutil.wl.devmgr.devicemgr)
wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
- tizen_input_device_manager_init_generator(_eflutil.wl.devmgr.devicemgr, clas);
+ if (with_name == 2)
+ tizen_input_device_manager_init_generator_with_sync(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
+ else if (with_name == 1)
+ tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
+ else
+ tizen_input_device_manager_init_generator(_eflutil.wl.devmgr.devicemgr, clas);
+
while (_eflutil.wl.devmgr.request_notified == -1)
wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
- ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
+ *ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
_eflutil.wl.devmgr.request_notified = -1;
- set_last_result(ret);
- if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
+ set_last_result(*ret);
+ if (*ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
goto out;
return inputgen_h;
}
API efl_util_inputgen_h
-efl_util_input_initialize_generator_with_name(unsigned int dev_type, const char *name)
+efl_util_input_initialize_generator(unsigned int dev_type)
{
int ret = EFL_UTIL_ERROR_NONE;
efl_util_inputgen_h inputgen_h = NULL;
- unsigned int clas = 0x0;
-
- if (!dev_type ||
- dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
- | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
- | EFL_UTIL_INPUT_DEVTYPE_POINTER))
- {
- set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
- goto out;
- }
- inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
+ inputgen_h = _efl_util_input_create_inputgen(dev_type, NULL, &ret, 0);
if (!inputgen_h)
- {
- set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
- goto out;
- }
-
- inputgen_h->init_type |= dev_type;
- strncpy(inputgen_h->name, name, 31);
-
- ret = _wl_init();
- if (ret == (int)EINA_FALSE)
- {
- set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
- goto out;
- }
-
- if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
- clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
- if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
- clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
- if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
- clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
-
- while (!_eflutil.wl.devmgr.devicemgr)
- wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+ return NULL;
- tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
-
- while (_eflutil.wl.devmgr.request_notified == -1)
- wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+ return inputgen_h;
+}
- ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
- _eflutil.wl.devmgr.request_notified = -1;
+API efl_util_inputgen_h
+efl_util_input_initialize_generator_with_name(unsigned int dev_type, const char *name)
+{
+ int ret = EFL_UTIL_ERROR_NONE;
+ efl_util_inputgen_h inputgen_h = NULL;
- set_last_result(ret);
- if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
- goto out;
+ inputgen_h = _efl_util_input_create_inputgen(dev_type, name, &ret, 1);
+ if (!inputgen_h)
+ return NULL;
return inputgen_h;
-
-out:
- if (inputgen_h)
- {
- free(inputgen_h);
- inputgen_h = NULL;
- }
- return NULL;
}
API efl_util_inputgen_h
{
int ret = EFL_UTIL_ERROR_NONE;
efl_util_inputgen_h inputgen_h = NULL;
- unsigned int clas = 0x0;
-
- if (!dev_type ||
- dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
- | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
- | EFL_UTIL_INPUT_DEVTYPE_POINTER))
- {
- set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
- goto out;
- }
- inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
+ inputgen_h = _efl_util_input_create_inputgen(dev_type, name, &ret, 2);
if (!inputgen_h)
- {
- set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
- goto out;
- }
+ return NULL;
- inputgen_h->init_type |= dev_type;
- if (name) strncpy(inputgen_h->name, name, 31);
- else strncpy(inputgen_h->name, "Input Generator", 31);
+ return inputgen_h;
+}
+
+API int
+efl_util_input_set_touch_count(int max_count)
+{
+ int ret = EFL_UTIL_ERROR_NONE;
ret = _wl_init();
if (ret == (int)EINA_FALSE)
{
- set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
- goto out;
+ return EFL_UTIL_ERROR_INVALID_PARAMETER;
}
- if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
- clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
- if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
- clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
- if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
- clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
-
while (!_eflutil.wl.devmgr.devicemgr)
wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
- tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
+ if (_eflutil.wl.devmgr.max_touch_count >= max_count)
+ return EFL_UTIL_ERROR_NONE;
+
+ tizen_input_device_manager_set_touch_count(_eflutil.wl.devmgr.devicemgr, max_count);
while (_eflutil.wl.devmgr.request_notified == -1)
wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
if (ret == EFL_UTIL_ERROR_NONE)
{
- _efl_util_input_initialize_add_wait_device(inputgen_h->name, dev_type);
- _efl_util_input_initialize_wait_device();
- if (_eflutil.wl.devmgr.request_notified != -1)
- {
- ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
- _eflutil.wl.devmgr.request_notified = -1;
- }
+ _eflutil.wl.devmgr.request_touch_count = max_count;
}
- set_last_result(ret);
- if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
- goto out;
-
- return inputgen_h;
-
-out:
- if (inputgen_h)
- {
- free(inputgen_h);
- inputgen_h = NULL;
- }
- return NULL;
-}
+ return ret;
+}
API int
efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h)
EINA_SAFETY_ON_FALSE_RETURN_VAL((x > 0 && y > 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
+ if (_eflutil.wl.devmgr.request_touch_count != 0 &&
+ _eflutil.wl.devmgr.max_touch_count != _eflutil.wl.devmgr.request_touch_count)
+ wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+
+ if (idx >= _eflutil.wl.devmgr.max_touch_count)
+ return EFL_UTIL_ERROR_INVALID_PARAMETER;
+
EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
switch(touch_type)
pthread_mutex_unlock(&shot_lock);
}
-API efl_util_screenshot_h
-efl_util_screenshot_initialize(int width, int height)
+static Eina_Bool
+_efl_util_wl_screenshooter_init()
{
- efl_util_screenshot_h screenshot = NULL;
struct wl_display *display_wrapper = NULL;
- struct wl_registry *reg = NULL;
+ struct wl_registry *registry = NULL;
int ret = 0;
- if (width <= 0 || height <= 0)
- {
- set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
- return NULL;
- }
+ if (_wl_init() == EINA_FALSE)
+ return EINA_FALSE;
- _screenshot_mutex_lock();
+ wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
- if (!g_screenshot)
- {
- screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
- EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_memory);
- }
+ display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(display_wrapper, EINA_FALSE);
- if (!_eflutil.wl.shot.screenshooter)
- {
- ret = _wl_init();
- if (ret == (int)EINA_FALSE)
- {
- set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
- _screenshot_mutex_unlock();
- return NULL;
- }
- wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+ _eflutil.wl.shot.queue = wl_display_create_queue(_eflutil.wl.dpy);
+ EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.queue, fail_create_queue);
- display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
- EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail_memory);
+ wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.shot.queue);
- _eflutil.wl.shot.queue = wl_display_create_queue(_eflutil.wl.dpy);
- EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.queue, fail_memory);
+ registry = wl_display_get_registry(display_wrapper);
+ EINA_SAFETY_ON_NULL_GOTO(registry, fail_get_registry);
- wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.shot.queue);
+ wl_registry_add_listener(registry, &_wl_reg_screenshooter_listener, NULL);
- reg = wl_display_get_registry(display_wrapper);
- wl_proxy_wrapper_destroy(display_wrapper);
- display_wrapper = NULL;
- EINA_SAFETY_ON_NULL_GOTO(reg, fail_init);
+ ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
+ EINA_SAFETY_ON_TRUE_GOTO(ret == -1, fail_roundtrip);
+ EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tz_screenshooter, fail_roundtrip);
- wl_registry_add_listener(reg, &_wl_reg_screenshooter_listener, NULL);
+ _eflutil.wl.shot.tbm_client = wayland_tbm_client_init(_eflutil.wl.dpy);
+ EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail_tbm_client_init);
- 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);
+ wl_registry_destroy(registry);
+ wl_proxy_wrapper_destroy(display_wrapper);
- _eflutil.wl.shot.tbm_client = wayland_tbm_client_init(_eflutil.wl.dpy);
- EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail_init);
+ if (_eflutil.wl.shot.noti == 0)
+ {
+ fprintf(stderr, "[screenshot] fail: privilege error\n"); /* LCOV_EXCL_LINE */
+ return EINA_FALSE;
+ }
+
+ return EINA_TRUE;
+
+fail_tbm_client_init:
+ tizen_screenshooter_destroy(_eflutil.wl.shot.tz_screenshooter);
+ _eflutil.wl.shot.tz_screenshooter = NULL;
+fail_roundtrip:
+ wl_registry_destroy(registry);
+fail_get_registry:
+ wl_event_queue_destroy(_eflutil.wl.shot.queue);
+ _eflutil.wl.shot.queue = NULL;
+fail_create_queue:
+ wl_proxy_wrapper_destroy(display_wrapper);
+
+ return EINA_FALSE;
+}
- wl_registry_destroy(reg);
- reg = NULL;
+static void
+_efl_util_wl_screenshooter_deinit()
+{
+ if (_eflutil.wl.shot.tbm_client)
+ {
+ wayland_tbm_client_deinit(_eflutil.wl.shot.tbm_client);
+ _eflutil.wl.shot.tbm_client = NULL;
}
- if (_eflutil.wl.shot.noti == 0)
+ if (_eflutil.wl.shot.tz_screenshooter)
{
- fprintf(stderr, "[screenshot] fail: privilege error\n"); /* LCOV_EXCL_LINE */
- goto fail_init;
+ tizen_screenshooter_destroy(_eflutil.wl.shot.tz_screenshooter);
+ _eflutil.wl.shot.tz_screenshooter = NULL;
+ }
+
+ if (_eflutil.wl.shot.queue)
+ {
+ wl_event_queue_destroy(_eflutil.wl.shot.queue);
+ _eflutil.wl.shot.queue = NULL;
+ }
+}
+
+API efl_util_screenshot_h
+efl_util_screenshot_initialize(int width, int height)
+{
+ efl_util_screenshot_h screenshot = NULL;
+
+ if (width <= 0 || height <= 0)
+ {
+ set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
+ return NULL;
}
+ _screenshot_mutex_lock();
+
if (g_screenshot)
{
if (g_screenshot->width != width || g_screenshot->height != height)
return g_screenshot;
}
+ screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
+ if (screenshot == NULL)
+ {
+ set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
+
+ _screenshot_mutex_unlock();
+
+ return NULL;
+ }
+
+ if (!_eflutil.wl.shot.tz_screenshooter)
+ {
+ if (_efl_util_wl_screenshooter_init() == EINA_FALSE)
+ {
+ if (_eflutil.wl.shot.noti == 0)
+ set_last_result(EFL_UTIL_ERROR_PERMISSION_DENIED);
+ else
+ set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
+
+ free(screenshot);
+
+ _screenshot_mutex_unlock();
+
+ return NULL;
+ }
+ }
+
screenshot->width = width;
screenshot->height = height;
screenshot->auto_rotation = EINA_TRUE;
screenshot->bufmgr = wayland_tbm_client_get_bufmgr(_eflutil.wl.shot.tbm_client);
- EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_init);
+ EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_get_bufmgr);
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();
return g_screenshot;
/* LCOV_EXCL_START */
-fail_memory:
- if (display_wrapper)
- wl_proxy_wrapper_destroy(display_wrapper);
- set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
+fail_get_bufmgr:
+ set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
_screenshot_mutex_unlock();
- return NULL;
+ efl_util_screenshot_deinitialize(screenshot);
-fail_init:
- if (reg)
- wl_registry_destroy(reg);
- if (screenshot)
- {
- _screenshot_mutex_unlock();
- efl_util_screenshot_deinitialize(screenshot);
- }
- if (_eflutil.wl.shot.noti == 0)
- set_last_result(EFL_UTIL_ERROR_PERMISSION_DENIED);
- else
- set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
return NULL;
/* LCOV_EXCL_STOP */
}
free(screenshot);
g_screenshot = NULL;
- if (_eflutil.wl.shot.tbm_client)
- {
- wayland_tbm_client_deinit(_eflutil.wl.shot.tbm_client);
- _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);
- _eflutil.wl.shot.tz_screenshooter = NULL;
- }
-
- if (_eflutil.wl.shot.queue)
- {
- wl_event_queue_destroy(_eflutil.wl.shot.queue);
- _eflutil.wl.shot.queue = NULL;
- }
+ _efl_util_wl_screenshooter_deinit();
_screenshot_mutex_unlock();
_screenshot_mutex_destory();
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;
}
return EFL_UTIL_ERROR_NONE;
}
+/* LCOV_EXCL_START */
+struct _efl_util_screenmirror_h
+{
+ struct tizen_screenmirror *tz_screenmirror;
+ pthread_t thread;
+ int width;
+ int height;
+
+ tbm_bufmgr bufmgr;
+ Eina_List *buffer_list;
+
+ Eina_Bool mirror_working;
+ Eina_Bool cb_start;
+ Eina_Bool cb_stop;
+ Eina_Bool cb_content;
+ efl_util_screenmirror_handler user_func;
+ void *user_data;
+};
+
+typedef struct _efl_util_mirror_buffer efl_util_mirror_buffer;
+struct _efl_util_mirror_buffer
+{
+ struct wl_buffer *buffer;
+ int w, h;
+ tbm_surface_h t_surface;
+};
+
+static efl_util_screenmirror_h g_screenmirror;
+
+static void *
+_efl_util_screenmirror_loop(void *data)
+{
+ efl_util_screenmirror_h screenmirror;
+ int ret = 0;
+
+ screenmirror = (efl_util_screenmirror_h)data;
+
+ while (1)
+ {
+ if (!screenmirror->mirror_working)
+ break;
+
+ ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
+ if (ret == -1)
+ {
+ fprintf(stderr, "[screenmirror] fail: dispatch_queue\n");
+ break;
+ }
+ }
+
+ return NULL;
+}
+
+static efl_util_mirror_buffer *
+_efl_util_create_mirror_buffer(efl_util_screenmirror_h screenmirror)
+{
+ efl_util_mirror_buffer *mbuffer;
+
+ mbuffer = calloc(1, sizeof(struct _efl_util_mirror_buffer));
+ EINA_SAFETY_ON_NULL_RETURN_VAL(mbuffer, NULL);
+
+ mbuffer->w = screenmirror->width;
+ mbuffer->h = screenmirror->height;
+
+ mbuffer->t_surface = tbm_surface_internal_create_with_flags(mbuffer->w,
+ mbuffer->h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+ EINA_SAFETY_ON_NULL_GOTO(mbuffer->t_surface, fail_create_surface);
+
+ mbuffer->buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, mbuffer->t_surface);
+ EINA_SAFETY_ON_NULL_GOTO(mbuffer->buffer, fail_create_buffer);
+
+ return mbuffer;
+
+fail_create_buffer:
+ tbm_surface_destroy(mbuffer->t_surface);
+fail_create_surface:
+ free(mbuffer);
+
+ return NULL;
+}
+
+static void
+_efl_util_destroy_mirror_buffer(efl_util_mirror_buffer *mbuffer)
+{
+ EINA_SAFETY_ON_NULL_RETURN(mbuffer);
+
+ if (mbuffer->buffer)
+ wl_buffer_destroy(mbuffer->buffer);
+
+ free(mbuffer);
+}
+
+static void
+_efl_util_screenmirror_handle_dequeued(void *data,
+ struct tizen_screenmirror *tz_screenmirror, struct wl_buffer *buffer)
+{
+ efl_util_screenmirror_h screenmirror;
+ efl_util_mirror_buffer *mbuffer;
+ Eina_List *l, *ll;
+
+ screenmirror = (efl_util_screenmirror_h)data;
+ screenmirror->cb_start = EINA_TRUE;
+
+ EINA_LIST_FOREACH_SAFE(screenmirror->buffer_list, l, ll, mbuffer)
+ {
+ if (mbuffer->buffer == buffer)
+ {
+ if (mbuffer->w != screenmirror->width || mbuffer->h != screenmirror->height ||
+ !screenmirror->mirror_working)
+ tbm_surface_destroy(mbuffer->t_surface);
+ else
+ screenmirror->user_func(screenmirror, mbuffer->t_surface, screenmirror->user_data);
+
+ screenmirror->buffer_list = eina_list_remove_list(screenmirror->buffer_list, l);
+ _efl_util_destroy_mirror_buffer(mbuffer);
+
+ break;
+ }
+ }
+
+ mbuffer = _efl_util_create_mirror_buffer(screenmirror);
+ if (mbuffer == NULL)
+ {
+ fprintf(stderr, "[screenmirror] fail: buffer create\n");
+ return;
+ }
+ screenmirror->buffer_list = eina_list_append(screenmirror->buffer_list, mbuffer);
+ tizen_screenmirror_queue(screenmirror->tz_screenmirror, mbuffer->buffer);
+}
+
+static void
+_efl_util_screenmirror_handle_content(void *data,
+ struct tizen_screenmirror *tz_screenmirror, uint32_t content)
+{
+ efl_util_screenmirror_h screenmirror = NULL;
+
+ screenmirror = (efl_util_screenmirror_h)data;
+ screenmirror->cb_content = EINA_TRUE;
+}
+
+static void
+_efl_util_screenmirror_handle_stop(void *data, struct tizen_screenmirror *tz_screenmirror)
+{
+ efl_util_screenmirror_h screenmirror = NULL;
+
+ screenmirror = (efl_util_screenmirror_h)data;
+ screenmirror->cb_stop = EINA_TRUE;
+}
+
+static const struct tizen_screenmirror_listener efl_util_screenmirror_listener = {
+ _efl_util_screenmirror_handle_dequeued,
+ _efl_util_screenmirror_handle_content,
+ _efl_util_screenmirror_handle_stop
+};
+
+API efl_util_screenmirror_h
+efl_util_screenmirror_initialize(int width, int height)
+{
+ efl_util_screenmirror_h screenmirror = NULL;
+ efl_util_mirror_buffer *mbuffer;
+ Efl_Util_Wl_Output_Info *output;
+ int ret = 0, i;
+
+ if (width <= 0 || height <= 0)
+ {
+ set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ _screenshot_mutex_lock();
+
+ if (g_screenmirror)
+ {
+ if (g_screenmirror->mirror_working)
+ {
+ set_last_result(EFL_UTIL_ERROR_INVALID_OPERATION);
+ _screenshot_mutex_unlock();
+ return NULL;
+ }
+ else
+ {
+ g_screenmirror->width = width;
+ g_screenmirror->height = height;
+ set_last_result(EFL_UTIL_ERROR_NONE);
+ _screenshot_mutex_unlock();
+ return g_screenmirror;
+ }
+ }
+
+ screenmirror = calloc(1, sizeof(struct _efl_util_screenmirror_h));
+ if (screenmirror == NULL)
+ {
+ set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
+ _screenshot_mutex_unlock();
+ return NULL;
+ }
+
+ if (!_eflutil.wl.shot.tz_screenshooter)
+ {
+ if (_efl_util_wl_screenshooter_init() == EINA_FALSE)
+ {
+ if (_eflutil.wl.shot.noti == 0)
+ set_last_result(EFL_UTIL_ERROR_PERMISSION_DENIED);
+ else
+ set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
+
+ goto fail_wl_init;
+ }
+ }
+
+ output = eina_list_nth(_eflutil.wl.shot.output_list, 0);
+ if (!output)
+ {
+ set_last_result(EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE);
+ fprintf(stderr, "[screenmirror] fail: no output for screenmirror\n");
+ goto fail_get_output;
+ }
+
+ screenmirror->tz_screenmirror = tizen_screenshooter_get_screenmirror(_eflutil.wl.shot.tz_screenshooter, output->output);
+ wl_proxy_set_queue((struct wl_proxy *)screenmirror->tz_screenmirror, _eflutil.wl.shot.queue);
+ tizen_screenmirror_add_listener(screenmirror->tz_screenmirror, &efl_util_screenmirror_listener, screenmirror);
+ tizen_screenmirror_set_stretch(screenmirror->tz_screenmirror, TIZEN_SCREENMIRROR_STRETCH_KEEP_RATIO);
+ screenmirror->width = width;
+ screenmirror->height = height;
+
+ g_screenmirror = screenmirror;
+
+ for (i = 0; i < 1; i++)
+ {
+ mbuffer = _efl_util_create_mirror_buffer(screenmirror);
+ if (mbuffer)
+ {
+ screenmirror->buffer_list = eina_list_append(screenmirror->buffer_list, mbuffer);
+ tizen_screenmirror_queue(screenmirror->tz_screenmirror, mbuffer->buffer);
+ }
+ else
+ fprintf(stderr, "[screenmirror] fail: buffer create %d\n", i);
+ }
+ while (!screenmirror->cb_content && ret != -1)
+ ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
+
+ _screenshot_mutex_unlock();
+
+ return screenmirror;
+
+fail_get_output:
+fail_wl_init:
+ free(screenmirror);
+ _screenshot_mutex_unlock();
+ return NULL;
+}
+
+API int
+efl_util_screenmirror_deinitialize(efl_util_screenmirror_h screenmirror)
+{
+ efl_util_mirror_buffer *mbuffer;
+ Eina_List *l;
+
+ _screenshot_mutex_lock();
+
+ if (!screenmirror || (screenmirror != g_screenmirror))
+ {
+ _screenshot_mutex_unlock();
+ _screenshot_mutex_destory();
+ return EFL_UTIL_ERROR_INVALID_PARAMETER;
+ }
+
+ if (screenmirror->mirror_working)
+ {
+ fprintf(stderr, "[screenmirror] fail: execute stop before deinit\n");
+ _screenshot_mutex_unlock();
+ _screenshot_mutex_destory();
+ return EFL_UTIL_ERROR_INVALID_OPERATION;
+ }
+
+ EINA_LIST_FOREACH(screenmirror->buffer_list, l, mbuffer)
+ {
+ tbm_surface_destroy(mbuffer->t_surface);
+ _efl_util_destroy_mirror_buffer(mbuffer);
+ }
+ eina_list_free(screenmirror->buffer_list);
+
+ tizen_screenmirror_destroy(screenmirror->tz_screenmirror);
+ free(screenmirror);
+ g_screenmirror = NULL;
+
+ _efl_util_wl_screenshooter_deinit();
+
+ _screenshot_mutex_unlock();
+ _screenshot_mutex_destory();
+
+ return EFL_UTIL_ERROR_NONE;
+}
+
+API int
+efl_util_screenmirror_set_handler(efl_util_screenmirror_h screenmirror,
+ efl_util_screenmirror_handler func, void *data)
+{
+ _screenshot_mutex_lock();
+
+ if (!screenmirror || (screenmirror != g_screenmirror) || !func)
+ {
+ _screenshot_mutex_unlock();
+ return EFL_UTIL_ERROR_INVALID_PARAMETER;
+ }
+ screenmirror->user_func = func;
+ screenmirror->user_data = data;
+
+ _screenshot_mutex_unlock();
+
+ return EFL_UTIL_ERROR_NONE;
+}
+
+API int
+efl_util_screenmirror_start(efl_util_screenmirror_h screenmirror)
+{
+ int ret = 0;
+
+ _screenshot_mutex_lock();
+
+ if (!screenmirror || (screenmirror != g_screenmirror))
+ {
+ _screenshot_mutex_unlock();
+ return EFL_UTIL_ERROR_INVALID_PARAMETER;
+ }
+ else if (!screenmirror->user_func)
+ {
+ _screenshot_mutex_unlock();
+ return EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL;
+ }
+ else if (screenmirror->mirror_working)
+ {
+ _screenshot_mutex_unlock();
+ return EFL_UTIL_ERROR_NONE;
+ }
+
+ screenmirror->cb_start = EINA_FALSE;
+ screenmirror->mirror_working = EINA_TRUE;
+ tizen_screenmirror_start(screenmirror->tz_screenmirror);
+ while (!screenmirror->cb_start && ret != -1)
+ ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
+ if (ret == -1)
+ {
+ fprintf(stderr, "[screenmirror] fail: tizen_screenmirror_start\n");
+ _screenshot_mutex_unlock();
+ return EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL;
+ }
+
+ ret = pthread_create(&screenmirror->thread, NULL, _efl_util_screenmirror_loop, screenmirror);
+ if (ret < 0)
+ {
+ fprintf(stderr, "[screenmirror] fail: thread create fail\n");
+ _screenshot_mutex_unlock();
+ return EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL;
+ }
+
+ pthread_setname_np(screenmirror->thread, "e_util_mirror");
+
+ _screenshot_mutex_unlock();
+
+ return EFL_UTIL_ERROR_NONE;
+}
+
+API int
+efl_util_screenmirror_stop(efl_util_screenmirror_h screenmirror)
+{
+ int ret = 0;
+
+ _screenshot_mutex_lock();
+
+ if (!screenmirror || (screenmirror != g_screenmirror))
+ {
+ _screenshot_mutex_unlock();
+ return EFL_UTIL_ERROR_INVALID_PARAMETER;
+ }
+ else if (!screenmirror->mirror_working)
+ {
+ _screenshot_mutex_unlock();
+ return EFL_UTIL_ERROR_NONE;
+ }
+ screenmirror->mirror_working = EINA_FALSE;
+ pthread_join(screenmirror->thread, NULL);
+ tizen_screenmirror_stop(screenmirror->tz_screenmirror);
+ screenmirror->cb_stop = EINA_FALSE;
+
+ while (!screenmirror->cb_stop && ret != -1)
+ ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
+ if (ret == -1)
+ {
+ fprintf(stderr, "[screenmirror] fail: tizen_screenmirror_stop\n");
+ _screenshot_mutex_unlock();
+ return EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL;
+ }
+
+ _screenshot_mutex_unlock();
+
+ return EFL_UTIL_ERROR_NONE;
+}
+/* LCOV_EXCL_STOP */
+
struct _efl_util_gesture_h
{
Eina_Bool init;
}
/* LCOV_EXCL_START */
-static int
-_efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data)
+static efl_util_error_e
+_efl_util_gesture_verify_request_notified()
{
int ret = EFL_UTIL_ERROR_NONE;
- Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
- Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
- unsigned int fingers = 0;
- unsigned int edge = 0;
- unsigned int edge_size = 0;
- unsigned int start_point = 0;
- unsigned int end_point = 0;
-
- base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
- EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
- EFL_UTIL_ERROR_INVALID_PARAMETER);
-
- edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
-
- fingers = edge_swipe_data->fingers;
- edge = edge_swipe_data->edge;
- edge_size = edge_swipe_data->edge_size;
- start_point = edge_swipe_data->start_point;
- end_point = edge_swipe_data->end_point;
-
- tizen_gesture_grab_edge_swipe(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
}
static int
-_efl_util_gesture_ungrab_edge_swipe(efl_util_gesture_data data)
+_efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data, Eina_Bool grabbed)
{
int ret = EFL_UTIL_ERROR_NONE;
Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
start_point = edge_swipe_data->start_point;
end_point = edge_swipe_data->end_point;
- tizen_gesture_ungrab_edge_swipe(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
-
- while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
- wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
-
- ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
- _eflutil_defaultqueue.wl.gesture.request_notified = -1;
-
- return ret;
-}
-
-static int
-_efl_util_gesture_grab_edge_drag(efl_util_gesture_data data)
-{
- int ret = EFL_UTIL_ERROR_NONE;
- Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
- Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
- unsigned int fingers = 0;
- unsigned int edge = 0;
- unsigned int edge_size = 0;
- unsigned int start_point = 0;
- unsigned int end_point = 0;
-
- base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
- EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
- EFL_UTIL_ERROR_INVALID_PARAMETER);
-
- edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
-
- fingers = edge_drag_data->fingers;
- edge = edge_drag_data->edge;
- edge_size = edge_drag_data->edge_size;
- start_point = edge_drag_data->start_point;
- end_point = edge_drag_data->end_point;
-
- tizen_gesture_grab_edge_drag(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
-
- while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
- wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
+ if (grabbed)
+ tizen_gesture_grab_edge_swipe(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
+ else
+ tizen_gesture_ungrab_edge_swipe(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
- ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
- _eflutil_defaultqueue.wl.gesture.request_notified = -1;
+ ret = _efl_util_gesture_verify_request_notified();
return ret;
}
static int
-_efl_util_gesture_ungrab_edge_drag(efl_util_gesture_data data)
+_efl_util_gesture_grab_edge_drag(efl_util_gesture_data data, Eina_Bool grabbed)
{
int ret = EFL_UTIL_ERROR_NONE;
Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
start_point = edge_drag_data->start_point;
end_point = edge_drag_data->end_point;
- tizen_gesture_ungrab_edge_drag(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
-
- while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
- wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
-
- ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
- _eflutil_defaultqueue.wl.gesture.request_notified = -1;
-
- return ret;
-}
-
-
-static int
-_efl_util_gesture_grab_tap(efl_util_gesture_data data)
-{
- int ret = EFL_UTIL_ERROR_NONE;
- Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
- Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
- unsigned int fingers = 0;
- unsigned int repeats = 0;
-
- base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
- EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
- EFL_UTIL_ERROR_INVALID_PARAMETER);
-
- tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
-
- fingers = tap_data->fingers;
- repeats = tap_data->repeats;
-
- tizen_gesture_grab_tap(_eflutil_defaultqueue.wl.gesture.proto, fingers, repeats);
-
- while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
- wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
+ if (grabbed)
+ tizen_gesture_grab_edge_drag(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
+ else
+ tizen_gesture_ungrab_edge_drag(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
- ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
- _eflutil_defaultqueue.wl.gesture.request_notified = -1;
+ ret = _efl_util_gesture_verify_request_notified();
return ret;
}
static int
-_efl_util_gesture_ungrab_tap(efl_util_gesture_data data)
+_efl_util_gesture_grab_tap(efl_util_gesture_data data, Eina_Bool grabbed)
{
int ret = EFL_UTIL_ERROR_NONE;
Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
fingers = tap_data->fingers;
repeats = tap_data->repeats;
- tizen_gesture_ungrab_tap(_eflutil_defaultqueue.wl.gesture.proto, fingers, repeats);
-
- while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
- wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
-
- ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
- _eflutil_defaultqueue.wl.gesture.request_notified = -1;
-
- return ret;
-}
-
-static int
-_efl_util_gesture_grab_palm_cover(efl_util_gesture_data data)
-{
- int ret = EFL_UTIL_ERROR_NONE;
- Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
-
- base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
-
- EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
- EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
- EFL_UTIL_ERROR_INVALID_PARAMETER);
-
- tizen_gesture_grab_palm_cover(_eflutil_defaultqueue.wl.gesture.proto);
-
- while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
- wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
+ if (grabbed)
+ tizen_gesture_grab_tap(_eflutil_defaultqueue.wl.gesture.proto, fingers, repeats);
+ else
+ tizen_gesture_ungrab_tap(_eflutil_defaultqueue.wl.gesture.proto, fingers, repeats);
- ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
- _eflutil_defaultqueue.wl.gesture.request_notified = -1;
+ ret = _efl_util_gesture_verify_request_notified();
return ret;
}
static int
-_efl_util_gesture_ungrab_palm_cover(efl_util_gesture_data data)
+_efl_util_gesture_grab_palm_cover(efl_util_gesture_data data, Eina_Bool grabbed)
{
int ret = EFL_UTIL_ERROR_NONE;
Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
EFL_UTIL_ERROR_INVALID_PARAMETER);
- tizen_gesture_ungrab_palm_cover(_eflutil_defaultqueue.wl.gesture.proto);
-
- while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
- wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
+ if (grabbed)
+ tizen_gesture_grab_palm_cover(_eflutil_defaultqueue.wl.gesture.proto);
+ else
+ tizen_gesture_ungrab_palm_cover(_eflutil_defaultqueue.wl.gesture.proto);
- ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
- _eflutil_defaultqueue.wl.gesture.request_notified = -1;
+ ret = _efl_util_gesture_verify_request_notified();
return ret;
}
switch (base_data->type)
{
case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
- ret = _efl_util_gesture_grab_edge_swipe(data);
+ ret = _efl_util_gesture_grab_edge_swipe(data, EINA_TRUE);
break;
case TIZEN_GESTURE_TYPE_EDGE_DRAG:
- ret = _efl_util_gesture_grab_edge_drag(data);
+ ret = _efl_util_gesture_grab_edge_drag(data, EINA_TRUE);
break;
case TIZEN_GESTURE_TYPE_TAP:
- ret = _efl_util_gesture_grab_tap(data);
+ ret = _efl_util_gesture_grab_tap(data, EINA_TRUE);
break;
case TIZEN_GESTURE_TYPE_PALM_COVER:
- ret = _efl_util_gesture_grab_palm_cover(data);
+ ret = _efl_util_gesture_grab_palm_cover(data, EINA_TRUE);
break;
default:
return EFL_UTIL_ERROR_INVALID_PARAMETER;
switch (base_data->type)
{
case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
- ret = _efl_util_gesture_ungrab_edge_swipe(data);
+ ret = _efl_util_gesture_grab_edge_swipe(data, EINA_FALSE);
break;
case TIZEN_GESTURE_TYPE_EDGE_DRAG:
- ret = _efl_util_gesture_ungrab_edge_drag(data);
+ ret = _efl_util_gesture_grab_edge_drag(data, EINA_FALSE);
break;
case TIZEN_GESTURE_TYPE_TAP:
- ret = _efl_util_gesture_ungrab_tap(data);
+ ret = _efl_util_gesture_grab_tap(data, EINA_FALSE);
break;
case TIZEN_GESTURE_TYPE_PALM_COVER:
- ret = _efl_util_gesture_ungrab_palm_cover(data);
+ ret = _efl_util_gesture_grab_palm_cover(data, EINA_FALSE);
break;
default:
return EFL_UTIL_ERROR_INVALID_PARAMETER;
tizen_gesture_select_palm_cover(_eflutil_defaultqueue.wl.gesture.proto, surface);
- while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
- wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
-
- ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
- _eflutil_defaultqueue.wl.gesture.request_notified = -1;
+ ret = _efl_util_gesture_verify_request_notified();
return ret;
}
tizen_gesture_deselect_palm_cover(_eflutil_defaultqueue.wl.gesture.proto, surface);
- while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
- wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
-
- ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
- _eflutil_defaultqueue.wl.gesture.request_notified = -1;
+ ret = _efl_util_gesture_verify_request_notified();
return ret;
}
tizen_gesture_activate_set(_eflutil_defaultqueue.wl.gesture.proto, NULL, type, active);
- while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
- wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
-
- ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
- _eflutil_defaultqueue.wl.gesture.request_notified = -1;
+ ret = _efl_util_gesture_verify_request_notified();
return ret;
}
tizen_gesture_activate_set(_eflutil_defaultqueue.wl.gesture.proto, surface, type, active);
- while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
- wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
-
- ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
- _eflutil_defaultqueue.wl.gesture.request_notified = -1;
+ ret = _efl_util_gesture_verify_request_notified();
return ret;
}