forked from enlightenment/efl
efl_loop: remove message_handler_get
it appears that this could be emulated with other functions. Plus the function had the limitation, that no constructors could be used. ref T7597 Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D7985
This commit is contained in:
parent
a9f6e7ac42
commit
cc9f236a29
|
@ -86,10 +86,12 @@ _ecore_event_filters_call(Eo *obj, Efl_Loop_Data *pd)
|
||||||
{
|
{
|
||||||
Filter *f;
|
Filter *f;
|
||||||
Ecore_Event_Message_Handler_Data *eemhd;
|
Ecore_Event_Message_Handler_Data *eemhd;
|
||||||
Eo *ecore_event_handler = efl_loop_message_handler_get
|
Eo *ecore_event_handler = efl_provider_find(obj, ECORE_EVENT_MESSAGE_HANDLER_CLASS);
|
||||||
(obj, ECORE_EVENT_MESSAGE_HANDLER_CLASS);
|
/* If this is not != NULL, then _ecore_event_init was not called yet, which means,
|
||||||
|
there cannot be any registered events yet
|
||||||
|
*/
|
||||||
if (!ecore_event_handler) return;
|
if (!ecore_event_handler) return;
|
||||||
|
|
||||||
eemhd = efl_data_scope_get(ecore_event_handler, MY_CLASS);
|
eemhd = efl_data_scope_get(ecore_event_handler, MY_CLASS);
|
||||||
if (!eemhd) return;
|
if (!eemhd) return;
|
||||||
if (!eemhd->filters) return;
|
if (!eemhd->filters) return;
|
||||||
|
|
|
@ -245,9 +245,9 @@ _ecore_event_init(void)
|
||||||
const char *choice = getenv("EINA_MEMPOOL");
|
const char *choice = getenv("EINA_MEMPOOL");
|
||||||
if ((!choice) || (!choice[0])) choice = "chained_mempool";
|
if ((!choice) || (!choice[0])) choice = "chained_mempool";
|
||||||
|
|
||||||
_event_msg_handler =
|
_event_msg_handler = efl_add(ECORE_EVENT_MESSAGE_HANDLER_CLASS, _mainloop_singleton);
|
||||||
efl_loop_message_handler_get(_mainloop_singleton,
|
efl_loop_register(_mainloop_singleton, ECORE_EVENT_MESSAGE_HANDLER_CLASS, _event_msg_handler);
|
||||||
ECORE_EVENT_MESSAGE_HANDLER_CLASS);
|
|
||||||
if (!_event_msg_handler)
|
if (!_event_msg_handler)
|
||||||
{
|
{
|
||||||
ERR("Cannot create legacy ecore event message handler");
|
ERR("Cannot create legacy ecore event message handler");
|
||||||
|
|
|
@ -94,15 +94,8 @@ typedef struct _Efl_Loop_Data Efl_Loop_Data;
|
||||||
typedef struct _Efl_Task_Data Efl_Task_Data;
|
typedef struct _Efl_Task_Data Efl_Task_Data;
|
||||||
typedef struct _Efl_Appthread_Data Efl_Appthread_Data;
|
typedef struct _Efl_Appthread_Data Efl_Appthread_Data;
|
||||||
|
|
||||||
typedef struct _Message_Handler Message_Handler;
|
|
||||||
typedef struct _Message Message;
|
typedef struct _Message Message;
|
||||||
|
|
||||||
struct _Message_Handler
|
|
||||||
{
|
|
||||||
Eo *handler;
|
|
||||||
const Eo *klass;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _Message
|
struct _Message
|
||||||
{
|
{
|
||||||
EINA_INLIST;
|
EINA_INLIST;
|
||||||
|
@ -150,7 +143,6 @@ struct _Efl_Loop_Data
|
||||||
Eina_List *win32_handlers_to_delete;
|
Eina_List *win32_handlers_to_delete;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
Eina_Inarray *message_handlers;
|
|
||||||
Eina_Inlist *message_queue;
|
Eina_Inlist *message_queue;
|
||||||
unsigned int message_walking;
|
unsigned int message_walking;
|
||||||
|
|
||||||
|
|
|
@ -30,24 +30,6 @@ struct _Efl_Loop_Promise_Simple_Data
|
||||||
};
|
};
|
||||||
GENERIC_ALLOC_SIZE_DECLARE(Efl_Loop_Promise_Simple_Data);
|
GENERIC_ALLOC_SIZE_DECLARE(Efl_Loop_Promise_Simple_Data);
|
||||||
|
|
||||||
EOLIAN static Efl_Loop_Message_Handler *
|
|
||||||
_efl_loop_message_handler_get(Eo *obj, Efl_Loop_Data *pd EINA_UNUSED, const Efl_Class *klass)
|
|
||||||
{
|
|
||||||
Message_Handler mh = { 0 }, *mh2;
|
|
||||||
unsigned int i, n;
|
|
||||||
|
|
||||||
n = eina_inarray_count(pd->message_handlers);
|
|
||||||
for (i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
mh2 = eina_inarray_nth(pd->message_handlers, i);
|
|
||||||
if (mh2->klass == klass) return mh2->handler;
|
|
||||||
}
|
|
||||||
mh.klass = klass;
|
|
||||||
mh.handler = efl_add(klass, obj);
|
|
||||||
eina_inarray_push(pd->message_handlers, &mh);
|
|
||||||
return mh.handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
Eo *_mainloop_singleton = NULL;
|
Eo *_mainloop_singleton = NULL;
|
||||||
Efl_Loop_Data *_mainloop_singleton_data = NULL;
|
Efl_Loop_Data *_mainloop_singleton_data = NULL;
|
||||||
|
|
||||||
|
@ -305,11 +287,11 @@ _efl_loop_efl_object_constructor(Eo *obj, Efl_Loop_Data *pd)
|
||||||
|
|
||||||
pd->loop_time = ecore_time_get();
|
pd->loop_time = ecore_time_get();
|
||||||
pd->providers = eina_hash_pointer_new(EINA_FREE_CB(efl_unref));
|
pd->providers = eina_hash_pointer_new(EINA_FREE_CB(efl_unref));
|
||||||
pd->message_handlers = eina_inarray_new(sizeof(Message_Handler), 32);
|
|
||||||
pd->epoll_fd = -1;
|
pd->epoll_fd = -1;
|
||||||
pd->timer_fd = -1;
|
pd->timer_fd = -1;
|
||||||
pd->future_message_handler = efl_loop_message_handler_get
|
pd->future_message_handler = efl_add(EFL_LOOP_MESSAGE_FUTURE_HANDLER_CLASS, obj);
|
||||||
(obj, EFL_LOOP_MESSAGE_FUTURE_HANDLER_CLASS);
|
efl_loop_register(obj, EFL_LOOP_MESSAGE_FUTURE_HANDLER_CLASS, pd->future_message_handler);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,12 +310,6 @@ _efl_loop_efl_object_invalidate(Eo *obj, Efl_Loop_Data *pd)
|
||||||
pd->poll_medium = NULL;
|
pd->poll_medium = NULL;
|
||||||
pd->poll_high = NULL;
|
pd->poll_high = NULL;
|
||||||
|
|
||||||
if (pd->message_handlers)
|
|
||||||
{
|
|
||||||
eina_inarray_free(pd->message_handlers);
|
|
||||||
pd->message_handlers = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// After invalidate, it won't be possible to parent to the singleton anymore
|
// After invalidate, it won't be possible to parent to the singleton anymore
|
||||||
if (obj == _mainloop_singleton)
|
if (obj == _mainloop_singleton)
|
||||||
{
|
{
|
||||||
|
|
|
@ -113,16 +113,6 @@ abstract @beta Efl.Loop extends Efl.Task
|
||||||
}
|
}
|
||||||
return: bool; [[$true if successfully unregistered, $false otherwise.]]
|
return: bool; [[$true if successfully unregistered, $false otherwise.]]
|
||||||
}
|
}
|
||||||
message_handler_get {
|
|
||||||
[[Get a message handler object that is created by and owned by
|
|
||||||
the Efl.Loop object, so you can listen to this message type by
|
|
||||||
listening to message events on the handler as well as send
|
|
||||||
objects as events.]]
|
|
||||||
params {
|
|
||||||
@in klass: const(Efl.Class); [[The class of the message object.]]
|
|
||||||
}
|
|
||||||
return: Efl.Loop_Message_Handler; [[The message handler to use.]]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
events {
|
events {
|
||||||
idle,enter @restart: void; [[Event occurs once the main loop enters the idle state.]]
|
idle,enter @restart: void; [[Event occurs once the main loop enters the idle state.]]
|
||||||
|
|
Loading…
Reference in New Issue