wayland: use eina array for ecore-evas event handlers

thx to @jpeg for reporting how dumb this was
This commit is contained in:
Mike Blumenkrantz 2017-10-17 11:32:57 -04:00
parent fd00e3de1a
commit f375661e0b
1 changed files with 42 additions and 27 deletions

View File

@ -28,7 +28,7 @@ struct _EE_Wl_Device
/* local variables */ /* local variables */
static int _ecore_evas_wl_init_count = 0; static int _ecore_evas_wl_init_count = 0;
static Ecore_Event_Handler *_ecore_evas_wl_event_hdls[17]; static Eina_Array *_ecore_evas_wl_event_hdls;
static void _ecore_evas_wayland_resize(Ecore_Evas *ee, int location); static void _ecore_evas_wayland_resize(Ecore_Evas *ee, int location);
static void _ecore_evas_wl_common_rotation_set(Ecore_Evas *ee, int rotation, int resize); static void _ecore_evas_wl_common_rotation_set(Ecore_Evas *ee, int rotation, int resize);
@ -1189,65 +1189,83 @@ _ecore_evas_wl_common_cb_iconify_state_change(void *data EINA_UNUSED, int type E
static int static int
_ecore_evas_wl_common_init(void) _ecore_evas_wl_common_init(void)
{ {
Ecore_Event_Handler *h;
LOGFN(__FILE__, __LINE__, __FUNCTION__); LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (++_ecore_evas_wl_init_count != 1) if (++_ecore_evas_wl_init_count != 1)
return _ecore_evas_wl_init_count; return _ecore_evas_wl_init_count;
_ecore_evas_wl_event_hdls[0] = _ecore_evas_wl_event_hdls = eina_array_new(10);
ecore_event_handler_add(ECORE_EVENT_MOUSE_IN, h = ecore_event_handler_add(ECORE_EVENT_MOUSE_IN,
_ecore_evas_wl_common_cb_mouse_in, NULL); _ecore_evas_wl_common_cb_mouse_in, NULL);
_ecore_evas_wl_event_hdls[1] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT, ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT,
_ecore_evas_wl_common_cb_mouse_out, NULL); _ecore_evas_wl_common_cb_mouse_out, NULL);
_ecore_evas_wl_event_hdls[2] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN,
_ecore_evas_wl_common_cb_focus_in, NULL); _ecore_evas_wl_common_cb_focus_in, NULL);
_ecore_evas_wl_event_hdls[3] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT,
_ecore_evas_wl_common_cb_focus_out, NULL); _ecore_evas_wl_common_cb_focus_out, NULL);
_ecore_evas_wl_event_hdls[4] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE,
_ecore_evas_wl_common_cb_window_configure, NULL); _ecore_evas_wl_common_cb_window_configure, NULL);
_ecore_evas_wl_event_hdls[5] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(_ecore_wl2_event_window_www, ecore_event_handler_add(_ecore_wl2_event_window_www,
_ecore_evas_wl_common_cb_www, NULL); _ecore_evas_wl_common_cb_www, NULL);
_ecore_evas_wl_event_hdls[6] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(_ecore_wl2_event_window_www_drag, ecore_event_handler_add(_ecore_wl2_event_window_www_drag,
_ecore_evas_wl_common_cb_www_drag, NULL); _ecore_evas_wl_common_cb_www_drag, NULL);
_ecore_evas_wl_event_hdls[7] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(ECORE_WL2_EVENT_DISCONNECT, ecore_event_handler_add(ECORE_WL2_EVENT_DISCONNECT,
_ecore_evas_wl_common_cb_disconnect, NULL); _ecore_evas_wl_common_cb_disconnect, NULL);
_ecore_evas_wl_event_hdls[8] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(ECORE_WL2_EVENT_GLOBAL_ADDED, ecore_event_handler_add(ECORE_WL2_EVENT_GLOBAL_ADDED,
_ecore_evas_wl_common_cb_global_added, NULL); _ecore_evas_wl_common_cb_global_added, NULL);
_ecore_evas_wl_event_hdls[9] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(ECORE_WL2_EVENT_GLOBAL_REMOVED, ecore_event_handler_add(ECORE_WL2_EVENT_GLOBAL_REMOVED,
_ecore_evas_wl_common_cb_global_removed, NULL); _ecore_evas_wl_common_cb_global_removed, NULL);
_ecore_evas_wl_event_hdls[10] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_NAME_CHANGED, ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_NAME_CHANGED,
_ecore_evas_wl_common_cb_seat_name_changed, NULL); _ecore_evas_wl_common_cb_seat_name_changed, NULL);
_ecore_evas_wl_event_hdls[11] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_CAPABILITIES_CHANGED, ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_CAPABILITIES_CHANGED,
_ecore_evas_wl_common_cb_seat_capabilities_changed, _ecore_evas_wl_common_cb_seat_capabilities_changed,
NULL); NULL);
_ecore_evas_wl_event_hdls[12] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE, ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE,
_ecore_evas_wl_common_cb_window_configure_complete, _ecore_evas_wl_common_cb_window_configure_complete,
NULL); NULL);
_ecore_evas_wl_event_hdls[13] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE,
_ecore_evas_wl_common_cb_window_rotate, NULL); _ecore_evas_wl_common_cb_window_rotate, NULL);
_ecore_evas_wl_event_hdls[14] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(ECORE_WL2_EVENT_AUX_HINT_ALLOWED, ecore_event_handler_add(ECORE_WL2_EVENT_AUX_HINT_ALLOWED,
_ecore_evas_wl_common_cb_aux_hint_allowed, NULL); _ecore_evas_wl_common_cb_aux_hint_allowed, NULL);
_ecore_evas_wl_event_hdls[15] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(ECORE_WL2_EVENT_AUX_HINT_SUPPORTED, ecore_event_handler_add(ECORE_WL2_EVENT_AUX_HINT_SUPPORTED,
_ecore_evas_wl_common_cb_aux_hint_supported, NULL); _ecore_evas_wl_common_cb_aux_hint_supported, NULL);
_ecore_evas_wl_event_hdls[16] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE,
_ecore_evas_wl_common_cb_iconify_state_change, NULL); _ecore_evas_wl_common_cb_iconify_state_change, NULL);
_ecore_evas_wl_event_hdls[15] = eina_array_push(_ecore_evas_wl_event_hdls, h);
h =
ecore_event_handler_add(ECORE_WL2_EVENT_AUX_MESSAGE, ecore_event_handler_add(ECORE_WL2_EVENT_AUX_MESSAGE,
_ecore_evas_wl_common_cb_aux_message, NULL); _ecore_evas_wl_common_cb_aux_message, NULL);
@ -1259,18 +1277,15 @@ _ecore_evas_wl_common_init(void)
static int static int
_ecore_evas_wl_common_shutdown(void) _ecore_evas_wl_common_shutdown(void)
{ {
unsigned int i = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__); LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (--_ecore_evas_wl_init_count != 0) if (--_ecore_evas_wl_init_count != 0)
return _ecore_evas_wl_init_count; return _ecore_evas_wl_init_count;
for (i = 0; i < EINA_C_ARRAY_LENGTH(_ecore_evas_wl_event_hdls); i++) while (eina_array_count(_ecore_evas_wl_event_hdls))
{ ecore_event_handler_del(eina_array_pop(_ecore_evas_wl_event_hdls));
if (_ecore_evas_wl_event_hdls[i]) eina_array_free(_ecore_evas_wl_event_hdls);
ecore_event_handler_del(_ecore_evas_wl_event_hdls[i]); _ecore_evas_wl_event_hdls = NULL;
}
ecore_event_evas_shutdown(); ecore_event_evas_shutdown();