efl_app: introduce app_main for getting the app object
This brings in the possibility to receive the app object from bindings. With the app object you can listen to pause / args / terminate / resume events. fix T7509 Differential Revision: https://phab.enlightenment.org/D7480
This commit is contained in:
parent
7031a8cd7e
commit
20ddd4c679
|
@ -82,7 +82,7 @@ public class Promise : IDisposable
|
|||
/// </summary>
|
||||
public Promise(CancelCb cancelCb=null)
|
||||
{
|
||||
Efl.Loop loop = Efl.App.GetLoopMain();
|
||||
Efl.Loop loop = Efl.App.AppMain;
|
||||
|
||||
// Should we be able to pass different schedulers?
|
||||
IntPtr scheduler = efl_loop_future_scheduler_get(loop.NativeHandle);
|
||||
|
|
|
@ -89,7 +89,6 @@ EAPI Eina_Promise *efl_loop_promise_new(const Eo *obj, Eina_Promise_Cancel_Cb ca
|
|||
|
||||
/* We ue the factory pattern here, so you shouldn't call eo_add directly. */
|
||||
EAPI Eo *efl_main_loop_get(void);
|
||||
EAPI Eo *efl_app_get(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
@ -34,10 +34,13 @@ Efl_Version _app_efl_version = { 0, 0, 0, 0, NULL, NULL };
|
|||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
EAPI Eo *
|
||||
efl_app_get(void)
|
||||
EOLIAN static Efl_App*
|
||||
_efl_app_app_main_get(const Eo *obj EINA_UNUSED, void *pd EINA_UNUSED)
|
||||
{
|
||||
return efl_main_loop_get();
|
||||
if (_mainloop_singleton) return _mainloop_singleton;
|
||||
_mainloop_singleton = efl_add_ref(EFL_APP_CLASS, NULL);
|
||||
_mainloop_singleton_data = efl_data_scope_get(_mainloop_singleton, EFL_LOOP_CLASS);
|
||||
return _mainloop_singleton;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -107,15 +110,6 @@ EFL_CALLBACKS_ARRAY_DEFINE(_event_callback_watch,
|
|||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
EOLIAN static Efl_Loop *
|
||||
_efl_app_loop_main_get(const Eo *obj EINA_UNUSED, void *pd EINA_UNUSED)
|
||||
{
|
||||
if (_mainloop_singleton) return _mainloop_singleton;
|
||||
_mainloop_singleton = efl_add_ref(EFL_APP_CLASS, NULL);
|
||||
_mainloop_singleton_data = efl_data_scope_get(_mainloop_singleton, EFL_LOOP_CLASS);
|
||||
return _mainloop_singleton;
|
||||
}
|
||||
|
||||
EOLIAN static const Efl_Version *
|
||||
_efl_app_build_efl_version_get(const Eo *obj EINA_UNUSED, Efl_App_Data *pd EINA_UNUSED)
|
||||
{
|
||||
|
|
|
@ -4,11 +4,14 @@ class Efl.App (Efl.Loop)
|
|||
{
|
||||
[[ ]]
|
||||
methods {
|
||||
@property loop_main @class {
|
||||
[[ Points to the main loop instance of the application. ]]
|
||||
@property app_main @class {
|
||||
[[ Returns the app object that is representing this process
|
||||
|
||||
Note: This function call only works in the main loop thread of the process.
|
||||
]]
|
||||
get {}
|
||||
values {
|
||||
main_loop: Efl.Loop; [[Application main loop]]
|
||||
app : Efl.App; [[Application for this process]]
|
||||
}
|
||||
}
|
||||
@property build_efl_version {
|
||||
|
|
|
@ -61,7 +61,7 @@ static void _clean_old_environ(void);
|
|||
EAPI Eo *
|
||||
efl_main_loop_get(void)
|
||||
{
|
||||
return efl_app_loop_main_get(EFL_APP_CLASS);
|
||||
return efl_app_main_get(EFL_APP_CLASS);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
|
|
|
@ -11,7 +11,7 @@ class Efl.Loop extends Efl.Task
|
|||
The Efl main loop provides a clean and tiny event loop library with many modules to
|
||||
do lots of convenient things for a programmer, saving time and effort. It's
|
||||
lean and designed to work on anything from embedded systems all the way up to large
|
||||
and powerful multi-cpu workstations. The main loop has a number of primitives you can use.
|
||||
and powerful multi-cpu workstations. The main loop has a number of primitives you can use.
|
||||
It serializes these and allows for
|
||||
greater responsiveness without the need for threads (or any other concurrency). However
|
||||
you can provide these if you need to.
|
||||
|
|
|
@ -25,7 +25,7 @@ Eo*
|
|||
_efl_ui_selection_manager_get(Eo *obj)
|
||||
{
|
||||
if (!efl_isa(obj, EFL_UI_WIDGET_CLASS)) return NULL;
|
||||
Eo *app = efl_app_get();
|
||||
Eo *app = efl_app_main_get(EFL_APP_CLASS);
|
||||
Eo *sel_man = efl_key_data_get(app, "__selection_manager");
|
||||
if (!sel_man)
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ _efl_ui_selection_manager_get(Eo *obj)
|
|||
void
|
||||
_efl_ui_dnd_shutdown(void)
|
||||
{
|
||||
Eo *app = efl_app_get();
|
||||
Eo *app = efl_app_main_get(EFL_APP_CLASS);
|
||||
Eo *sel_man = efl_key_data_get(app, "__selection_manager");
|
||||
|
||||
efl_del(sel_man);
|
||||
|
|
|
@ -17,7 +17,7 @@ EFL_START_TEST(efl_app_test_efl_build_version)
|
|||
|
||||
ecore_init();
|
||||
|
||||
app = efl_app_get();
|
||||
app = efl_app_main_get(EFL_APP_CLASS);
|
||||
fail_if(!efl_isa(app, EFL_APP_CLASS));
|
||||
|
||||
efl_build_version_set(EFL_VERSION_MAJOR, EFL_VERSION_MINOR, 0, 0, NULL, EFL_BUILD_ID);
|
||||
|
|
|
@ -15,24 +15,24 @@ EFL_START_TEST(efl_app_test_efl_loop_register)
|
|||
|
||||
ecore_init();
|
||||
|
||||
t = efl_provider_find(efl_app_get(), EFL_LOOP_CLASS);
|
||||
t = efl_provider_find(efl_app_main_get(EFL_APP_CLASS), EFL_LOOP_CLASS);
|
||||
fail_if(!efl_isa(t, EFL_LOOP_CLASS));
|
||||
fail_if(!efl_isa(t, EFL_APP_CLASS));
|
||||
|
||||
t = efl_provider_find(efl_app_get(), EFL_LOOP_TIMER_CLASS);
|
||||
t = efl_provider_find(efl_app_main_get(EFL_APP_CLASS), EFL_LOOP_TIMER_CLASS);
|
||||
fail_if(t != NULL);
|
||||
|
||||
n = efl_add(EFL_LOOP_TIMER_CLASS, efl_app_get(),
|
||||
n = efl_add(EFL_LOOP_TIMER_CLASS, efl_app_main_get(EFL_APP_CLASS),
|
||||
efl_loop_timer_interval_set(efl_added, 1.0));
|
||||
efl_loop_register(efl_app_get(), EFL_LOOP_TIMER_CLASS, n);
|
||||
efl_loop_register(efl_app_main_get(EFL_APP_CLASS), EFL_LOOP_TIMER_CLASS, n);
|
||||
|
||||
t = efl_provider_find(efl_app_get(), EFL_LOOP_TIMER_CLASS);
|
||||
t = efl_provider_find(efl_app_main_get(EFL_APP_CLASS), EFL_LOOP_TIMER_CLASS);
|
||||
fail_if(!efl_isa(t, EFL_LOOP_TIMER_CLASS));
|
||||
fail_if(t != n);
|
||||
|
||||
efl_loop_unregister(efl_app_get(), EFL_LOOP_TIMER_CLASS, n);
|
||||
efl_loop_unregister(efl_app_main_get(EFL_APP_CLASS), EFL_LOOP_TIMER_CLASS, n);
|
||||
|
||||
t = efl_provider_find(efl_app_get(), EFL_LOOP_TIMER_CLASS);
|
||||
t = efl_provider_find(efl_app_main_get(EFL_APP_CLASS), EFL_LOOP_TIMER_CLASS);
|
||||
fail_if(t != NULL);
|
||||
|
||||
ecore_shutdown();
|
||||
|
|
|
@ -66,7 +66,7 @@ EFL_END_TEST
|
|||
|
||||
EFL_START_TEST(efl_app_test_loop_timer_invalid)
|
||||
{
|
||||
Efl_Object *t = efl_add(EFL_LOOP_TIMER_CLASS, efl_app_get());
|
||||
Efl_Object *t = efl_add(EFL_LOOP_TIMER_CLASS, efl_app_main_get(EFL_APP_CLASS));
|
||||
fail_if(t != NULL);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
|
|
@ -9,7 +9,7 @@ class TestEoPromises
|
|||
{
|
||||
public static void test_simple_task_run()
|
||||
{
|
||||
Efl.Loop loop = Efl.App.GetLoopMain();
|
||||
Efl.Loop loop = Efl.App.AppMain;
|
||||
Eina.Future future = loop.Idle();
|
||||
|
||||
bool callbackCalled = false;
|
||||
|
@ -36,7 +36,7 @@ class TestEoPromises
|
|||
|
||||
public static void test_object_promise()
|
||||
{
|
||||
Efl.Loop loop = Efl.App.GetLoopMain();
|
||||
Efl.Loop loop = Efl.App.AppMain;
|
||||
var obj = new Dummy.TestObject();
|
||||
|
||||
Eina.Future future = obj.GetFuture();
|
||||
|
@ -61,7 +61,7 @@ class TestEoPromises
|
|||
|
||||
public static void test_object_promise_cancel()
|
||||
{
|
||||
Efl.Loop loop = Efl.App.GetLoopMain();
|
||||
Efl.Loop loop = Efl.App.AppMain;
|
||||
var obj = new Dummy.TestObject();
|
||||
|
||||
Eina.Future future = obj.GetFuture();
|
||||
|
@ -100,7 +100,7 @@ class TestLoopEoAsyncMethods
|
|||
{
|
||||
public static void test_simple_async()
|
||||
{
|
||||
Efl.Loop loop = Efl.App.GetLoopMain();
|
||||
Efl.Loop loop = Efl.App.AppMain;
|
||||
Task t = LoopConsumer.Consume(loop);
|
||||
|
||||
loop.Begin();
|
||||
|
@ -113,7 +113,7 @@ class TestEoAsyncMethods
|
|||
|
||||
public static void test_async_fulfill()
|
||||
{
|
||||
Efl.Loop loop = Efl.App.GetLoopMain();
|
||||
Efl.Loop loop = Efl.App.AppMain;
|
||||
var obj = new Dummy.TestObject();
|
||||
|
||||
Task<Eina.Value> task = obj.GetFutureAsync();
|
||||
|
@ -133,7 +133,7 @@ class TestEoAsyncMethods
|
|||
|
||||
public static void test_async_cancel()
|
||||
{
|
||||
Efl.Loop loop = Efl.App.GetLoopMain();
|
||||
Efl.Loop loop = Efl.App.AppMain;
|
||||
var obj = new Dummy.TestObject();
|
||||
|
||||
CancellationTokenSource cancelSrc = new CancellationTokenSource();
|
||||
|
@ -162,7 +162,7 @@ class TestEoAsyncMethods
|
|||
|
||||
public static void test_async_reject()
|
||||
{
|
||||
Efl.Loop loop = Efl.App.GetLoopMain();
|
||||
Efl.Loop loop = Efl.App.AppMain;
|
||||
var obj = new Dummy.TestObject();
|
||||
|
||||
Task<Eina.Value> task = obj.GetFutureAsync();
|
||||
|
|
|
@ -22,7 +22,7 @@ class TestPromises
|
|||
bool callbackCalled = false;
|
||||
Eina.Value received_value = null;
|
||||
|
||||
Efl.Loop loop = Efl.App.GetLoopMain();
|
||||
Efl.Loop loop = Efl.App.AppMain;
|
||||
Eina.Promise promise = new Eina.Promise();
|
||||
Eina.Future future = new Eina.Future(promise);
|
||||
|
||||
|
@ -47,7 +47,7 @@ class TestPromises
|
|||
bool callbackCalled = false;
|
||||
Eina.Error received_error = Eina.Error.NO_ERROR;
|
||||
|
||||
Efl.Loop loop = Efl.App.GetLoopMain();
|
||||
Efl.Loop loop = Efl.App.AppMain;
|
||||
Eina.Promise promise = new Eina.Promise();
|
||||
Eina.Future future = new Eina.Future(promise);
|
||||
|
||||
|
@ -108,7 +108,7 @@ class TestPromises
|
|||
};
|
||||
};
|
||||
|
||||
Efl.Loop loop = Efl.App.GetLoopMain();
|
||||
Efl.Loop loop = Efl.App.AppMain;
|
||||
Eina.Promise promise = new Eina.Promise();
|
||||
Eina.Future future = new Eina.Future(promise);
|
||||
for (int i = 0; i < 4; i++)
|
||||
|
@ -154,7 +154,7 @@ class TestPromises
|
|||
for (int i = 0; i < 4; i++)
|
||||
cbs.Add(genResolvedCb(i));
|
||||
|
||||
Efl.Loop loop = Efl.App.GetLoopMain();
|
||||
Efl.Loop loop = Efl.App.AppMain;
|
||||
Eina.Promise promise = new Eina.Promise();
|
||||
Eina.Future future = new Eina.Future(promise);
|
||||
future = future.Chain(cbs);
|
||||
|
@ -184,7 +184,7 @@ class TestPromises
|
|||
bool callbackCalled = false;
|
||||
Eina.Error received_error = Eina.Error.NO_ERROR;
|
||||
|
||||
Efl.Loop loop = Efl.App.GetLoopMain();
|
||||
Efl.Loop loop = Efl.App.AppMain;
|
||||
Eina.Promise promise = new Eina.Promise();
|
||||
Eina.Future future = new Eina.Future(promise);
|
||||
|
||||
|
@ -211,7 +211,7 @@ class TestPromises
|
|||
bool callbackCalled = false;
|
||||
Eina.Value received_value = null;
|
||||
|
||||
Efl.Loop loop = Efl.App.GetLoopMain();
|
||||
Efl.Loop loop = Efl.App.AppMain;
|
||||
Eina.Promise promise = new Eina.Promise();
|
||||
#pragma warning disable 0219
|
||||
Eina.Future future = new Eina.Future(promise,(Eina.Value value) => {
|
||||
|
@ -236,7 +236,7 @@ class TestPromises
|
|||
bool callbackCalled = false;
|
||||
Eina.Error received_error = Eina.Error.NO_ERROR;
|
||||
|
||||
Efl.Loop loop = Efl.App.GetLoopMain();
|
||||
Efl.Loop loop = Efl.App.AppMain;
|
||||
Eina.Promise promise = new Eina.Promise();
|
||||
Eina.Future future = new Eina.Future(promise);
|
||||
|
||||
|
|
|
@ -3822,7 +3822,7 @@ Eina_Future* _dummy_test_object_get_future(EINA_UNUSED Eo *obj, Dummy_Test_Objec
|
|||
{
|
||||
if (pd->promise == NULL)
|
||||
{
|
||||
Eo *loop = efl_app_loop_main_get(EFL_APP_CLASS);
|
||||
Eo *loop = efl_app_main_get(EFL_APP_CLASS);
|
||||
Eina_Future_Scheduler *scheduler = efl_loop_future_scheduler_get(loop);
|
||||
pd->promise = eina_promise_new(scheduler, _promise_cancelled, pd);
|
||||
}
|
||||
|
|
|
@ -32,10 +32,10 @@ EFL_START_TEST(efl_ui_test_init)
|
|||
_efl_startup_time = ecore_time_unix_get();
|
||||
_EFL_APP_VERSION_SET();
|
||||
fail_if(!ecore_init());
|
||||
efl_event_callback_add(efl_app_get(), EFL_LOOP_EVENT_ARGUMENTS, efl_main, NULL);
|
||||
efl_event_callback_add(efl_app_main_get(EFL_APP_CLASS), EFL_LOOP_EVENT_ARGUMENTS, efl_main, NULL);
|
||||
fail_if(!ecore_init_ex(argc, argv));
|
||||
__EFL_MAIN_CONSTRUCTOR;
|
||||
ret__ = efl_loop_begin(efl_app_get());
|
||||
ret__ = efl_loop_begin(efl_app_main_get(EFL_APP_CLASS));
|
||||
real__ = efl_loop_exit_code_process(ret__);
|
||||
__EFL_MAIN_DESTRUCTOR;
|
||||
ecore_shutdown_ex();
|
||||
|
|
Loading…
Reference in New Issue