* limitations under the License.
*/
+#define _GNU_SOURCE
+
#define LOG_TAG "TIZEN_N_EFL_UTIL"
#include <efl_util.h>
#endif
#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;
int max_touch_count;
int request_touch_count;
} devmgr;
- struct wl_seat *seat;
struct
{
unsigned int id;
{ 0, NULL, NULL, NULL }, /* tizen_policy 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 */
},
};
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);
_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,
};
static void
-_cb_seat_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps)
-{
-}
-
-static void
-_cb_seat_name(void *data, struct wl_seat *seat EINA_UNUSED, const char *name)
-{
-}
-
-static const struct wl_seat_listener _seat_listener =
-{
- _cb_seat_capabilities,
- _cb_seat_name,
-};
-
-static void
_cb_wl_reg_global(void *data,
struct wl_registry *reg,
unsigned int id,
output->output = wl_registry_bind(reg, id, &wl_output_interface, version);
wl_output_add_listener(output->output, &output_listener, output);
}
- else if(strcmp(interface, "wl_seat") == 0)
- {
- _eflutil.wl.seat = wl_registry_bind(reg, id, &wl_seat_interface, version);
- wl_seat_add_listener(_eflutil.wl.seat, &_seat_listener, NULL);
- }
else if (strcmp(interface, "tizen_input_device_manager") == 0)
{
_eflutil.wl.devmgr.devicemgr = wl_registry_bind(reg, id, &tizen_input_device_manager_interface, version);
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_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);
-}
-
static efl_util_inputgen_h
_efl_util_input_create_inputgen(unsigned int dev_type, const char *name, int *ret, int with_name)
{
while (!_eflutil.wl.devmgr.devicemgr)
wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
- if (with_name)
+ 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);
int ret = EFL_UTIL_ERROR_NONE;
efl_util_inputgen_h inputgen_h = NULL;
- inputgen_h = efl_util_input_initialize_generator_with_name(dev_type, name);
+ inputgen_h = _efl_util_input_create_inputgen(dev_type, name, &ret, 2);
if (!inputgen_h)
return NULL;
- _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;
- }
-
- 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;
}
API int
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;
ret = pthread_create(&screenmirror->thread, NULL, _efl_util_screenmirror_loop, screenmirror);
if (ret < 0)
- fprintf(stderr, "[screenmirror] fail: thread create fail\n");
+ {
+ 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();