Eina_Bool init;
Ecore_Wl2_Display *wl2_display;
struct wl_display *dpy;
- struct wl_event_queue *queue;
struct
{
- unsigned int id;
- struct tizen_policy *proto;
+ Eina_Bool init;
+ struct wl_event_queue *queue;
+ struct tizen_policy *tz_policy;
+ struct tizen_display_policy *tz_display_policy;
+ Eina_Hash *hash_brightness;
Eina_Hash *hash_noti_lv;
Eina_Hash *hash_scr_mode;
} policy;
struct
{
+ Eina_Bool init;
struct wl_event_queue *queue;
struct tizen_screenshooter *tz_screenshooter;
struct wayland_tbm_client *tbm_client;
} shot;
struct
{
+ Eina_Bool init;
struct wl_event_queue *queue;
Eina_List *seat_list;
+ Eina_List *input_device_list;
struct tizen_input_device_manager *devicemgr;
int request_notified;
int max_touch_count;
int request_touch_count;
} devmgr;
- struct
- {
- unsigned int id;
- struct tizen_display_policy *proto;
- Eina_Hash *hash_brightness;
- } display_policy;
} wl;
} Efl_Util_Data;
{
{
EINA_FALSE,
- NULL, NULL, NULL,
- { 0, NULL, NULL, NULL }, /* tizen_policy protocol */
- { NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
- { NULL, NULL, NULL, -1, 0, 0 }, /* tizen_input_device_manager protocol */
- { 0, NULL, NULL } /* display_policy protocol */
+ NULL, NULL,
+ { EINA_FALSE, NULL, NULL, NULL, NULL, NULL, NULL }, /* tizen_policy protocol */
+ { EINA_FALSE, NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
+ { EINA_FALSE, NULL, NULL, NULL, NULL, -1, 0, 0 }, /* tizen_input_device_manager protocol */
},
};
static Eina_Bool
_wl_init(void)
{
- struct wl_display *display_wrapper = NULL;
- struct wl_registry *reg = NULL;
- int ret = 0;
-
if (_eflutil.wl.init) return EINA_TRUE;
if (ecore_wl2_init() <= 0) return EINA_FALSE;
_eflutil.wl.dpy = ecore_wl2_display_get(_eflutil.wl.wl2_display);
EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.dpy, fail);
+ _eflutil.wl.init = EINA_TRUE;
+
+ return EINA_TRUE;
+
+fail:
+ ecore_wl2_shutdown();
+ return EINA_FALSE;
+}
+
+static Eina_Bool
+_handle_registry_events(struct wl_event_queue *queue, const struct wl_registry_listener *listener, void *data)
+{
+ struct wl_display *display_wrapper = NULL;
+ struct wl_registry *registry = NULL;
+ int ret;
+
display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail);
- _eflutil.wl.queue = wl_display_create_queue(_eflutil.wl.dpy);
- EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.queue, fail);
-
- wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.queue);
+ wl_proxy_set_queue((struct wl_proxy *)display_wrapper, queue);
- reg = wl_display_get_registry(display_wrapper);
+ registry = wl_display_get_registry(display_wrapper);
wl_proxy_wrapper_destroy(display_wrapper);
display_wrapper = NULL;
- EINA_SAFETY_ON_NULL_GOTO(reg, fail);
+ EINA_SAFETY_ON_NULL_GOTO(registry, fail);
- wl_registry_add_listener(reg, &_wl_reg_listener, NULL);
+ wl_registry_add_listener(registry, listener, data);
- ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+ ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, queue);
EINA_SAFETY_ON_TRUE_GOTO(ret < 0, fail);
- wl_registry_destroy(reg);
-
- _eflutil.wl.init = EINA_TRUE;
+ wl_registry_destroy(registry);
return EINA_TRUE;
+
fail:
- if (display_wrapper)
- wl_proxy_wrapper_destroy(display_wrapper);
+ if (registry) wl_registry_destroy(registry);
+
+ return EINA_FALSE;
+}
+
+static Eina_Bool
+_policy_init(void)
+{
+ Eina_Bool res;
+
+ if (_eflutil.wl.policy.init) return EINA_TRUE;
+
+ if (_wl_init() == EINA_FALSE)
+ return EINA_FALSE;
- if (_eflutil.wl.queue)
+ _eflutil.wl.policy.queue = wl_display_create_queue(_eflutil.wl.dpy);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.queue, EINA_FALSE);
+
+ res = _handle_registry_events(_eflutil.wl.policy.queue, &_wl_reg_listener, NULL);
+ EINA_SAFETY_ON_FALSE_GOTO(res, fail);
+
+ _eflutil.wl.policy.init = EINA_TRUE;
+
+ return EINA_TRUE;
+
+fail:
+ if (_eflutil.wl.policy.queue)
{
- wl_event_queue_destroy(_eflutil.wl.queue);
- _eflutil.wl.queue = NULL;
+ wl_event_queue_destroy(_eflutil.wl.policy.queue);
+ _eflutil.wl.policy.queue = NULL;
}
- if (reg)
- wl_registry_destroy(reg);
-
- ecore_wl2_shutdown();
return EINA_FALSE;
}
_eflutil.wl.policy.hash_noti_lv = eina_hash_pointer_new(free);
_eflutil.wl.policy.hash_scr_mode = eina_hash_pointer_new(free);
- _eflutil.wl.policy.proto = proto;
- _eflutil.wl.policy.id = id;
- }
- else if (!strcmp(interface, "wl_output"))
- {
- Efl_Util_Wl_Output_Info *output = calloc(1, sizeof(Efl_Util_Wl_Output_Info));
- EINA_SAFETY_ON_NULL_RETURN(output);
-
- _eflutil.wl.shot.output_list = eina_list_append(_eflutil.wl.shot.output_list, output);
-
- output->output = wl_registry_bind(reg, id, &wl_output_interface, version);
- wl_output_add_listener(output->output, &output_listener, output);
+ _eflutil.wl.policy.tz_policy = proto;
}
else if (!strcmp(interface, "tizen_display_policy"))
{
- _eflutil.wl.display_policy.proto = wl_registry_bind(reg, id, &tizen_display_policy_interface, version);
- if (!_eflutil.wl.display_policy.proto) return;
+ _eflutil.wl.policy.tz_display_policy = wl_registry_bind(reg, id, &tizen_display_policy_interface, version);
+ if (!_eflutil.wl.policy.tz_display_policy) return;
- tizen_display_policy_add_listener(_eflutil.wl.display_policy.proto,
+ tizen_display_policy_add_listener(_eflutil.wl.policy.tz_display_policy,
&_wl_tz_display_policy_listener,
NULL);
- _eflutil.wl.display_policy.hash_brightness = eina_hash_pointer_new(free);
- _eflutil.wl.display_policy.id = id;
+ _eflutil.wl.policy.hash_brightness = eina_hash_pointer_new(free);
}
}
/* LCOV_EXCL_START */
struct wl_registry *reg,
unsigned int id)
{
- /* unset each global id number to 0 since global id is started
- * from number 1 on server side display structure
- */
- if (id == _eflutil.wl.policy.id)
+ if (_eflutil.wl.policy.tz_policy)
{
- _eflutil.wl.policy.id = 0;
- _eflutil.wl.policy.proto = NULL;
- eina_hash_free(_eflutil.wl.policy.hash_noti_lv);
- eina_hash_free(_eflutil.wl.policy.hash_scr_mode);
+ tizen_policy_destroy(_eflutil.wl.policy.tz_policy);
+ _eflutil.wl.policy.tz_policy = NULL;
}
- else if (id == _eflutil.wl.display_policy.id)
+
+ if (_eflutil.wl.policy.tz_display_policy)
{
- _eflutil.wl.display_policy.id = 0;
- _eflutil.wl.display_policy.proto = NULL;
- eina_hash_free(_eflutil.wl.display_policy.hash_brightness);
+ tizen_display_policy_destroy( _eflutil.wl.policy.tz_display_policy);
+ _eflutil.wl.policy.tz_display_policy = NULL;
}
+
+ eina_hash_free(_eflutil.wl.policy.hash_noti_lv);
+ eina_hash_free(_eflutil.wl.policy.hash_scr_mode);
+ eina_hash_free(_eflutil.wl.policy.hash_brightness);
}
/* LCOV_EXCL_STOP */
{
_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);
+ }
+ else if (!strcmp(interface, "wl_output"))
+ {
+ Efl_Util_Wl_Output_Info *output = calloc(1, sizeof(Efl_Util_Wl_Output_Info));
+ EINA_SAFETY_ON_NULL_RETURN(output);
+
+ _eflutil.wl.shot.output_list = eina_list_append(_eflutil.wl.shot.output_list, output);
- wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
+ output->output = wl_registry_bind(reg, name, &wl_output_interface, version);
+ wl_output_add_listener(output->output, &output_listener, output);
}
}
{
Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
- brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
+ brightness_info = eina_hash_find(_eflutil.wl.policy.hash_brightness, &surface);
if (brightness_info)
{
brightness_info->brightness = brightness;
Ecore_Wl2_Window_Type wl_type;
int ret_dispatch = 0;
- res = _wl_init();
+ res = _policy_init();
EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
}
- EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_NOT_SUPPORTED);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.tz_policy, EFL_UTIL_ERROR_NOT_SUPPORTED);
surface = ecore_wl2_window_surface_get(wlwin);
EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
}
- tizen_policy_set_notification_level(_eflutil.wl.policy.proto,
+ tizen_policy_set_notification_level(_eflutil.wl.policy.tz_policy,
surface, (int)level);
if (lv_info->wait_for_done)
ret_dispatch = 0;
while (lv_info->wait_for_done && (count < NUM_EVENT_WAIT_DONE_COUNT) && (ret_dispatch != -1))
{
- ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+ ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.policy.queue);
count++;
}
Ecore_Wl2_Window_Type wl_type;
int ret_dispatch = 0;
- res = _wl_init();
+ res = _policy_init();
EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
- EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_NOT_SUPPORTED);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.tz_policy, EFL_UTIL_ERROR_NOT_SUPPORTED);
wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
ret_dispatch = 0;
while ((lv_info->wait_for_done) && (count < NUM_EVENT_WAIT_DONE_COUNT) && (ret_dispatch != -1))
{
- ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+ ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.policy.queue);
count++;
}
Ecore_Wl2_Window *wlwin;
struct wl_surface *surface;
- if (!_eflutil.wl.policy.proto)
+ if (!_eflutil.wl.policy.tz_policy)
{
- res = _wl_init();
+ res = _policy_init();
EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
- EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_NOT_SUPPORTED);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.tz_policy, EFL_UTIL_ERROR_NOT_SUPPORTED);
}
wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
if (!surface)
return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
- tizen_policy_set_opaque_state(_eflutil.wl.policy.proto, surface, opaque);
+ tizen_policy_set_opaque_state(_eflutil.wl.policy.tz_policy, surface, opaque);
return EFL_UTIL_ERROR_NONE;
}
Eina_Bool res;
int ret_dispatch = 0;
- res = _wl_init();
+ res = _policy_init();
EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
- EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_NOT_SUPPORTED);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.tz_policy, EFL_UTIL_ERROR_NOT_SUPPORTED);
wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
if (wlwin)
scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
}
- tizen_policy_set_window_screen_mode(_eflutil.wl.policy.proto,
+ tizen_policy_set_window_screen_mode(_eflutil.wl.policy.tz_policy,
surface, (unsigned int)mode);
if (scr_mode_info->wait_for_done)
{
ret_dispatch = 0;
while (scr_mode_info->wait_for_done && (count < NUM_EVENT_WAIT_DONE_COUNT) && (ret_dispatch != -1))
{
- ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+ ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.policy.queue);
count++;
}
Eina_Bool res;
int ret_dispatch = 0;
- res = _wl_init();
+ res = _policy_init();
EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
- EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_NOT_SUPPORTED);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.tz_policy, EFL_UTIL_ERROR_NOT_SUPPORTED);
wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
if (wlwin)
ret_dispatch = 0;
while (scr_mode_info->wait_for_done && (ret_dispatch != -1))
{
- ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+ ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.policy.queue);
}
}
EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
EINA_SAFETY_ON_FALSE_RETURN_VAL(brightness <= 100, EFL_UTIL_ERROR_INVALID_PARAMETER);
- res = _wl_init();
+ res = _policy_init();
EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
- EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_NOT_SUPPORTED);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.tz_policy, EFL_UTIL_ERROR_NOT_SUPPORTED);
wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
if (wlwin)
EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
EFL_UTIL_ERROR_INVALID_PARAMETER);
- brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
+ brightness_info = eina_hash_find(_eflutil.wl.policy.hash_brightness, &surface);
if (!brightness_info)
{
brightness_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Brightness_Info));
brightness_info->wait_for_done = EINA_TRUE;
brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
- eina_hash_add(_eflutil.wl.display_policy.hash_brightness,
+ eina_hash_add(_eflutil.wl.policy.hash_brightness,
&surface,
brightness_info);
}
brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
}
- tizen_display_policy_set_window_brightness(_eflutil.wl.display_policy.proto,
+ tizen_display_policy_set_window_brightness(_eflutil.wl.policy.tz_display_policy,
surface, brightness);
if (brightness_info->wait_for_done)
{
ret_dispatch = 0;
while (brightness_info->wait_for_done && (count < NUM_EVENT_WAIT_DONE_COUNT) && (ret_dispatch != -1))
{
- ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+ ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.policy.queue);
count++;
}
EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
EINA_SAFETY_ON_NULL_RETURN_VAL(brightness, EFL_UTIL_ERROR_INVALID_PARAMETER);
- res = _wl_init();
+ res = _policy_init();
EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
- EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.display_policy.proto, EFL_UTIL_ERROR_NOT_SUPPORTED);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.tz_display_policy, EFL_UTIL_ERROR_NOT_SUPPORTED);
wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
EFL_UTIL_ERROR_INVALID_PARAMETER);
- brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
+ brightness_info = eina_hash_find(_eflutil.wl.policy.hash_brightness, &surface);
if (brightness_info)
{
if (brightness_info->wait_for_done)
ret_dispatch = 0;
while (brightness_info->wait_for_done && (ret_dispatch != -1))
{
- ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+ ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.policy.queue);
}
}
*brightness = brightness_info->brightness;
(unsigned int)wl_proxy_get_id((struct wl_proxy *)tizen_input_device_manager),
(unsigned int)wl_proxy_get_id((struct wl_proxy *)device),
identifier);
+ _eflutil.wl.devmgr.input_device_list = eina_list_append(_eflutil.wl.devmgr.input_device_list, device);
}
static void
(unsigned int)wl_proxy_get_id((struct wl_proxy *)tizen_input_device_manager),
(unsigned int)wl_proxy_get_id((struct wl_proxy *)device),
identifier);
+
+ _eflutil.wl.devmgr.input_device_list = eina_list_remove(_eflutil.wl.devmgr.input_device_list, device);
tizen_input_device_release(device);
}
static Eina_Bool
_efl_util_wl_inputgen_init()
{
- struct wl_display *display_wrapper = NULL;
- struct wl_registry *registry = NULL;
- int ret = 0;
+ Eina_Bool res;
+
+ if (_eflutil.wl.devmgr.init) return EINA_TRUE;
if (_wl_init() == EINA_FALSE)
return EINA_FALSE;
- display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
- EINA_SAFETY_ON_NULL_RETURN_VAL(display_wrapper, EINA_FALSE);
-
_eflutil.wl.devmgr.queue = wl_display_create_queue(_eflutil.wl.dpy);
- EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.devmgr.queue, fail_create_queue);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.queue, EINA_FALSE);
- wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.devmgr.queue);
+ res = _handle_registry_events(_eflutil.wl.devmgr.queue, &_wl_reg_devicemgr_listener, NULL);
+ EINA_SAFETY_ON_FALSE_GOTO(res, fail);
- registry = wl_display_get_registry(display_wrapper);
- EINA_SAFETY_ON_NULL_GOTO(registry, fail_get_registry);
-
- wl_registry_add_listener(registry, &_wl_reg_devicemgr_listener, NULL);
-
- ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.devmgr.queue);
- EINA_SAFETY_ON_TRUE_GOTO(ret == -1, fail_roundtrip);
- EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.devmgr.devicemgr, fail_roundtrip);
-
- wl_registry_destroy(registry);
- wl_proxy_wrapper_destroy(display_wrapper);
+ _eflutil.wl.devmgr.init = EINA_TRUE;
return EINA_TRUE;
-fail_roundtrip:
- wl_registry_destroy(registry);
-fail_get_registry:
- wl_event_queue_destroy(_eflutil.wl.devmgr.queue);
- _eflutil.wl.devmgr.queue = NULL;
-fail_create_queue:
- wl_proxy_wrapper_destroy(display_wrapper);
+fail:
+ if (_eflutil.wl.devmgr.queue)
+ {
+ wl_event_queue_destroy(_eflutil.wl.devmgr.queue);
+ _eflutil.wl.devmgr.queue = NULL;
+ }
return EINA_FALSE;
-
}
+
static efl_util_inputgen_h
_efl_util_input_create_inputgen(unsigned int dev_type, const char *name, int *ret, int with_name)
{
_efl_util_wl_inputgen_deinit()
{
struct wl_seat *seat;
+ struct tizen_input_device *device;
Eina_List *l;
EINA_LIST_FOREACH (_eflutil.wl.devmgr.seat_list, l, seat)
}
_eflutil.wl.devmgr.seat_list = eina_list_free(_eflutil.wl.devmgr.seat_list);
+ EINA_LIST_FOREACH (_eflutil.wl.devmgr.input_device_list, l, device)
+ {
+ tizen_input_device_release(device);
+ }
+ _eflutil.wl.devmgr.input_device_list = eina_list_free(_eflutil.wl.devmgr.input_device_list);
+
+ wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.devmgr.queue);
+
if (_eflutil.wl.devmgr.devicemgr)
{
tizen_input_device_manager_destroy(_eflutil.wl.devmgr.devicemgr);
_eflutil.wl.devmgr.devicemgr = NULL;
}
- wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.devmgr.queue);
-
if (_eflutil.wl.devmgr.queue)
{
wl_event_queue_destroy(_eflutil.wl.devmgr.queue);
_eflutil.wl.devmgr.queue = NULL;
}
+
+ _eflutil.wl.devmgr.init = EINA_FALSE;
}
API int
static Eina_Bool
_efl_util_wl_screenshooter_init()
{
- struct wl_display *display_wrapper = NULL;
- struct wl_registry *registry = NULL;
- int ret = 0;
+ Eina_Bool res;
+ int ret;
+
+ if (_eflutil.wl.shot.init) return EINA_TRUE;
if (_wl_init() == EINA_FALSE)
return EINA_FALSE;
- display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
- EINA_SAFETY_ON_NULL_RETURN_VAL(display_wrapper, EINA_FALSE);
-
_eflutil.wl.shot.queue = wl_display_create_queue(_eflutil.wl.dpy);
- EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.queue, fail_create_queue);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.shot.queue, EINA_FALSE);
- wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.shot.queue);
-
- registry = wl_display_get_registry(display_wrapper);
- EINA_SAFETY_ON_NULL_GOTO(registry, fail_get_registry);
-
- wl_registry_add_listener(registry, &_wl_reg_screenshooter_listener, NULL);
-
- 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);
+ res = _handle_registry_events(_eflutil.wl.shot.queue, &_wl_reg_screenshooter_listener, NULL);
+ EINA_SAFETY_ON_FALSE_GOTO(res, fail);
+ EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tz_screenshooter, fail);
_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);
+ EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail);
- wl_registry_destroy(registry);
- wl_proxy_wrapper_destroy(display_wrapper);
+ ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
+ EINA_SAFETY_ON_TRUE_GOTO(ret < 0, fail);
if (_eflutil.wl.shot.noti == 0)
{
fprintf(stderr, "[screenshot] fail: privilege error\n"); /* LCOV_EXCL_LINE */
- return EINA_FALSE;
+ goto fail;
}
+ _eflutil.wl.shot.init = EINA_TRUE;
+
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);
+fail:
+ 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.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;
+ }
return EINA_FALSE;
}
wl_event_queue_destroy(_eflutil.wl.shot.queue);
_eflutil.wl.shot.queue = NULL;
}
+
+ _eflutil.wl.shot.init = EINA_FALSE;
}
API efl_util_screenshot_h