summaryrefslogtreecommitdiff
path: root/src/lib/elementary
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-09-25 15:51:19 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-09-25 15:51:19 -0700
commitfdc92ca868c76a2e7d7cdb701a7a27262858b23a (patch)
tree923dccf9f2e5efcbbc3dab6537dcad9fc5459d98 /src/lib/elementary
parent596dba5fe5fa8b4101f50bbed66c29c791a2572f (diff)
elementary: provide a new initialization macro that support lifecycle.
EFL_MAIN_EX require efl_main, efl_resume, efl_pause and efl_terminate to be working. Quicklaunch support added too.
Diffstat (limited to 'src/lib/elementary')
-rw-r--r--src/lib/elementary/elm_general.h22
-rw-r--r--src/lib/elementary/elm_main.c27
2 files changed, 47 insertions, 2 deletions
diff --git a/src/lib/elementary/elm_general.h b/src/lib/elementary/elm_general.h
index 4259bea16c..2ef86cfaa1 100644
--- a/src/lib/elementary/elm_general.h
+++ b/src/lib/elementary/elm_general.h
@@ -110,12 +110,32 @@ extern EAPI double _elm_startup_time;
110 110
111#ifndef ELM_LIB_QUICKLAUNCH 111#ifndef ELM_LIB_QUICKLAUNCH
112#define EFL_MAIN() int main(int argc, char **argv) { int ret__; _EFL_APP_VERSION_SET(); _elm_startup_time = ecore_time_unix_get(); elm_init(argc, argv); efl_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS, efl_main, NULL); ret__ = efl_loop_begin(ecore_main_loop_get()); elm_shutdown(); return ret__; } 112#define EFL_MAIN() int main(int argc, char **argv) { int ret__; _EFL_APP_VERSION_SET(); _elm_startup_time = ecore_time_unix_get(); elm_init(argc, argv); efl_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS, efl_main, NULL); ret__ = efl_loop_begin(ecore_main_loop_get()); elm_shutdown(); return ret__; }
113
114#define EFL_MAIN_EX() \
115 EFL_CALLBACKS_ARRAY_DEFINE(_efl_main_ex, \
116 { EFL_LOOP_EVENT_ARGUMENTS, efl_main }, \
117 { EFL_LOOP_EVENT_PAUSE, efl_pause }, \
118 { EFL_LOOP_EVENT_RESUME, efl_resume }, \
119 { EFL_EVENT_DEL, efl_terminate }); \
120 int main(int argc, char **argv) \
121 { \
122 int ret__; \
123 _EFL_APP_VERSION_SET(); \
124 _elm_startup_time = ecore_time_unix_get(); \
125 elm_init(argc, argv); \
126 efl_event_callback_array_add(ecore_main_loop_get(), _efl_main_ex(), NULL); \
127 ret__ = efl_loop_begin(ecore_main_loop_get()); \
128 elm_shutdown(); \
129 return ret__; \
130 }
131
113#else 132#else
114/** @deprecated macro to be used after the elm_main() function. 133/** @deprecated macro to be used after the elm_main() function.
115 * Do not define ELM_LIB_QUICKLAUNCH 134 * Do not define ELM_LIB_QUICKLAUNCH
116 * Compile your programs with -fpie and -pie -rdynamic instead, to generate a single binary (linkable executable). 135 * Compile your programs with -fpie and -pie -rdynamic instead, to generate a single binary (linkable executable).
117 */ 136 */
118#define EFL_MAIN() int main(int argc, char **argv) { int ret__; _EFL_APP_VERSION_SET(); _elm_startup_time = ecore_time_unix_get(); ret__ = efl_quicklaunch_fallback(argc, argv); elm_shutdown(); return ret__; } 137#define EFL_MAIN() int main(int argc, char **argv) { int ret__; _EFL_APP_VERSION_SET(); _elm_startup_time = ecore_time_unix_get(); ret__ = efl_quicklaunch_fallback(argc, argv); elm_shutdown(); return ret__; (void) efl_main(NULL, NULL); return 0; }
138#define EFL_MAIN_EX() int main(int argc, char **argv) { int ret__; _EFL_APP_VERSION_SET(); _elm_startup_time = ecore_time_unix_get(); ret__ = efl_quicklaunch_fallback(argc, argv); elm_shutdown(); return ret__; (void) efl_main(NULL, NULL); (void) efl_pause(NULL, NULL); (void) efl_resume(NULL, NULL); (void) efl_terminate(NULL, NULL); return 0; }
119#endif 139#endif
120 140
121#endif /* EFL_BETA_API_SUPPORT */ 141#endif /* EFL_BETA_API_SUPPORT */
diff --git a/src/lib/elementary/elm_main.c b/src/lib/elementary/elm_main.c
index c82050e944..4d65e56052 100644
--- a/src/lib/elementary/elm_main.c
+++ b/src/lib/elementary/elm_main.c
@@ -930,6 +930,18 @@ static int (*qr_main)(int argc,
930 char **argv) = NULL; 930 char **argv) = NULL;
931static void (*qre_main)(void *data, 931static void (*qre_main)(void *data,
932 const Efl_Event *ev) = NULL; 932 const Efl_Event *ev) = NULL;
933static void (*qre_pause)(void *data,
934 const Efl_Event *ev) = NULL;
935static void (*qre_resume)(void *data,
936 const Efl_Event *ev) = NULL;
937static void (*qre_terminate)(void *data,
938 const Efl_Event *ev) = NULL;
939
940EFL_CALLBACKS_ARRAY_DEFINE(_qre_main_ex,
941 { EFL_LOOP_EVENT_ARGUMENTS, qre_main },
942 { EFL_LOOP_EVENT_PAUSE, qre_pause },
943 { EFL_LOOP_EVENT_RESUME, qre_resume },
944 { EFL_EVENT_DEL, qre_terminate });
933 945
934EAPI Eina_Bool 946EAPI Eina_Bool
935elm_quicklaunch_prepare(int argc, 947elm_quicklaunch_prepare(int argc,
@@ -1057,6 +1069,9 @@ efl_quicklaunch_prepare(int argc,
1057 { 1069 {
1058 INF("dlopen('%s') = %p", exe, qr_handle); 1070 INF("dlopen('%s') = %p", exe, qr_handle);
1059 qre_main = dlsym(qr_handle, "efl_main"); 1071 qre_main = dlsym(qr_handle, "efl_main");
1072 qre_pause = dlsym(qr_handle, "efl_pause");
1073 qre_resume = dlsym(qr_handle, "efl_resume");
1074 qre_terminate = dlsym(qr_handle, "efl_terminate");
1060 if (qre_main) 1075 if (qre_main)
1061 { 1076 {
1062 INF("dlsym(%p, 'elm_main') = %p", qr_handle, qre_main); 1077 INF("dlsym(%p, 'elm_main') = %p", qr_handle, qre_main);
@@ -1090,6 +1105,9 @@ efl_quicklaunch_prepare(int argc,
1090 INF("dlopen('%s') = %p", exe2, qr_handle); 1105 INF("dlopen('%s') = %p", exe2, qr_handle);
1091 qre_main = dlsym(qr_handle, "efl_main"); 1106 qre_main = dlsym(qr_handle, "efl_main");
1092 INF("dlsym(%p, 'elm_main') = %p", qr_handle, qre_main); 1107 INF("dlsym(%p, 'elm_main') = %p", qr_handle, qre_main);
1108 qre_pause = dlsym(qr_handle, "efl_pause");
1109 qre_resume = dlsym(qr_handle, "efl_resume");
1110 qre_terminate = dlsym(qr_handle, "efl_terminate");
1093 if (!qre_main) 1111 if (!qre_main)
1094 { 1112 {
1095 WRN("not quicklauncher capable: no efl_main in '%s'", exe2); 1113 WRN("not quicklauncher capable: no efl_main in '%s'", exe2);
@@ -1210,7 +1228,14 @@ elm_quicklaunch_fork(int argc,
1210 1228
1211 if (qre_main) 1229 if (qre_main)
1212 { 1230 {
1213 efl_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS, qre_main, NULL); 1231 if (qre_pause && qre_resume && qre_terminate)
1232 {
1233 efl_event_callback_array_add(ecore_main_loop_get(), _qre_main_ex(), NULL);
1234 }
1235 else
1236 {
1237 efl_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS, qre_main, NULL);
1238 }
1214 ret = efl_loop_begin(ecore_main_loop_get()); 1239 ret = efl_loop_begin(ecore_main_loop_get());
1215 elm_shutdown(); 1240 elm_shutdown();
1216 exit(ret); 1241 exit(ret);