summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-01-31 11:54:54 -0500
committerMike Blumenkrantz <zmike@samsung.com>2019-01-31 11:54:54 -0500
commit9b129b5c7a9b74b2261066b55037c7891f10c12d (patch)
tree9a3607f78d549557e0a1add9c937543c2dab1f01
parenta6c3be13515e43287060080eabd792081466f62a (diff)
efl_ui_win: add 'exit_on_all_windows_closed' class property and unit test
Summary: this property causes the main loop to exit with the passed exit code when the standby event is triggered @feature ref T5494 Reviewers: cedric, bu5hm4n, segfaultxavi Reviewed By: cedric, bu5hm4n, segfaultxavi Subscribers: segfaultxavi, bu5hm4n, #reviewers, #committers Tags: #efl Maniphest Tasks: T5494 Differential Revision: https://phab.enlightenment.org/D7594
-rw-r--r--src/lib/elementary/efl_ui_win.c24
-rw-r--r--src/lib/elementary/efl_ui_win.eo12
-rw-r--r--src/tests/elementary/elm_test_win.c32
3 files changed, 67 insertions, 1 deletions
diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c
index 8c0543dc11..a54e4520b6 100644
--- a/src/lib/elementary/efl_ui_win.c
+++ b/src/lib/elementary/efl_ui_win.c
@@ -360,6 +360,7 @@ static const Elm_Action key_actions[] = {
360 360
361Eina_List *_elm_win_list = NULL; 361Eina_List *_elm_win_list = NULL;
362int _elm_win_deferred_free = 0; 362int _elm_win_deferred_free = 0;
363static Eina_Value exit_on_all_windows_closed;
363 364
364static Eina_Bool _elm_win_throttle_ok = EINA_FALSE; 365static Eina_Bool _elm_win_throttle_ok = EINA_FALSE;
365static int _elm_win_count = 0; 366static int _elm_win_count = 0;
@@ -2991,7 +2992,11 @@ _efl_ui_win_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Win_Data *sd)
2991 _elm_win_flush_cache_and_exit(obj); 2992 _elm_win_flush_cache_and_exit(obj);
2992 } 2993 }
2993 if (!_elm_win_list) 2994 if (!_elm_win_list)
2994 efl_event_callback_call(efl_app_main_get(EFL_APP_CLASS), EFL_APP_EVENT_STANDBY, NULL); 2995 {
2996 efl_event_callback_call(efl_app_main_get(EFL_APP_CLASS), EFL_APP_EVENT_STANDBY, NULL);
2997 if (eina_value_type_get(&exit_on_all_windows_closed))
2998 efl_loop_quit(efl_loop_get(obj), exit_on_all_windows_closed);
2999 }
2995} 3000}
2996 3001
2997EOLIAN static void 3002EOLIAN static void
@@ -6240,6 +6245,23 @@ _dbus_menu_set(Eina_Bool dbus_connect, void *data)
6240 //sd->deferred_resize_job = EINA_TRUE; 6245 //sd->deferred_resize_job = EINA_TRUE;
6241} 6246}
6242 6247
6248EOLIAN static const Eina_Value *
6249_efl_ui_win_exit_on_all_windows_closed_get(const Eo *obj EINA_UNUSED, void *pd EINA_UNUSED)
6250{
6251 return &exit_on_all_windows_closed;
6252}
6253
6254EOLIAN static void
6255_efl_ui_win_exit_on_all_windows_closed_set(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Eina_Value *exit_code)
6256{
6257 const Eina_Value_Type *type = eina_value_type_get(exit_code);
6258
6259 if (type)
6260 eina_value_copy(exit_code, &exit_on_all_windows_closed);
6261 else
6262 eina_value_flush(&exit_on_all_windows_closed);
6263}
6264
6243EOLIAN static void 6265EOLIAN static void
6244_efl_ui_win_maximized_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Bool maximized) 6266_efl_ui_win_maximized_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Bool maximized)
6245{ 6267{
diff --git a/src/lib/elementary/efl_ui_win.eo b/src/lib/elementary/efl_ui_win.eo
index 7594ee6edf..5f5085e107 100644
--- a/src/lib/elementary/efl_ui_win.eo
+++ b/src/lib/elementary/efl_ui_win.eo
@@ -657,6 +657,18 @@ class Efl.Ui.Win extends Efl.Ui.Widget implements Efl.Canvas.Scene, Efl.Access.W
657 This will try and delete all the windows in the stack that 657 This will try and delete all the windows in the stack that
658 are above the window.]] 658 are above the window.]]
659 } 659 }
660 @property exit_on_all_windows_closed @class {
661 [[Enable quitting the main loop when all windows are closed.
662
663 When set, the main loop will quit with the passed exit code once all windows have been closed.
664
665 The Eina.Value passed should be $EMPTY to unset this state or an int value to be
666 used as the exit code.
667 ]]
668 values {
669 exit_code: const(any_value_ptr); [[The exit code to use when exiting]]
670 }
671 }
660 activate { 672 activate {
661 [[Activate a window object. 673 [[Activate a window object.
662 674
diff --git a/src/tests/elementary/elm_test_win.c b/src/tests/elementary/elm_test_win.c
index 207e777d57..2b0ec55b2c 100644
--- a/src/tests/elementary/elm_test_win.c
+++ b/src/tests/elementary/elm_test_win.c
@@ -40,6 +40,14 @@ _timer_delete_request_cb(void *data)
40} 40}
41 41
42static Eina_Bool 42static Eina_Bool
43_timer_del_window_cb(void *data)
44{
45 Eo *win = (Eo*) data;
46 evas_object_del(win);
47 return EINA_FALSE;
48}
49
50static Eina_Bool
43_timer_hide_window_cb(void *data) 51_timer_hide_window_cb(void *data)
44{ 52{
45 Eo *win = (Eo*) data; 53 Eo *win = (Eo*) data;
@@ -154,6 +162,29 @@ EFL_START_TEST(elm_win_autohide)
154} 162}
155EFL_END_TEST 163EFL_END_TEST
156 164
165EFL_START_TEST (elm_win_test_app_exit_on_windows_close)
166{
167 Eo *win = win_add(NULL, "win", ELM_WIN_BASIC);
168 Eo *app = efl_app_main_get(EFL_APP_CLASS);
169 Eina_Value val, *exit_val;
170 int code;
171
172 val = eina_value_int_init(66);
173 efl_ui_win_exit_on_all_windows_closed_set(win, &val);
174 efl_gfx_entity_visible_set(win, EINA_TRUE);
175
176 Eina_Bool fail_flag = EINA_FALSE;
177 ecore_timer_add(_timeout1, _timer_del_window_cb, win);
178 ecore_timer_add(_timeout_fail, _timer_fail_flag_cb, &fail_flag);
179
180 exit_val = efl_loop_begin(efl_loop_get(win));
181 ck_assert(eina_value_int_get(exit_val, &code));
182 ck_assert_int_eq(code, 66);
183 efl_ui_win_exit_on_all_windows_closed_set(app, &EINA_VALUE_EMPTY);
184}
185EFL_END_TEST
186
187
157EFL_START_TEST(elm_win_policy_quit_last_window_hidden) 188EFL_START_TEST(elm_win_policy_quit_last_window_hidden)
158{ 189{
159 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN); 190 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
@@ -405,6 +436,7 @@ void elm_test_win(TCase *tc)
405 tcase_add_test(tc, elm_atspi_role_get); 436 tcase_add_test(tc, elm_atspi_role_get);
406 tcase_add_test(tc, elm_atspi_component_screen_position); 437 tcase_add_test(tc, elm_atspi_component_screen_position);
407 tcase_add_test(tc, elm_win_policy_quit_last_window_hidden); 438 tcase_add_test(tc, elm_win_policy_quit_last_window_hidden);
439 tcase_add_test(tc, elm_win_test_app_exit_on_windows_close);
408 tcase_add_test(tc, efl_ui_win_multi_touch_inputs); 440 tcase_add_test(tc, efl_ui_win_multi_touch_inputs);
409#ifdef HAVE_ELEMENTARY_X 441#ifdef HAVE_ELEMENTARY_X
410 tcase_add_test(tc, elm_win_autohide); 442 tcase_add_test(tc, elm_win_autohide);