summaryrefslogtreecommitdiff
path: root/src/lib/elementary
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-09-25 15:48:53 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-09-25 15:48:53 -0700
commit596dba5fe5fa8b4101f50bbed66c29c791a2572f (patch)
treecbd58c1d2ae8e92cb4a21424a63682ffa131592b /src/lib/elementary
parentec9869b933dbf99707e85cf2c7846dc6af6b8ee7 (diff)
elementary: provide and implement lifecycle event on the window.
pause event means that the window is not visible anymore to any user. resume is triggered when the window became visible again or just became visible again.
Diffstat (limited to 'src/lib/elementary')
-rw-r--r--src/lib/elementary/efl_ui_win.c61
-rw-r--r--src/lib/elementary/efl_ui_win.eo2
2 files changed, 59 insertions, 4 deletions
diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c
index 3d6abd8483..ae7354a026 100644
--- a/src/lib/elementary/efl_ui_win.c
+++ b/src/lib/elementary/efl_ui_win.c
@@ -37,6 +37,8 @@
37 37
38static const Elm_Win_Trap *trap = NULL; 38static const Elm_Win_Trap *trap = NULL;
39 39
40static int _paused_windows = 0;
41
40#define TRAP(sd, name, ...) \ 42#define TRAP(sd, name, ...) \
41 do \ 43 do \
42 { \ 44 { \
@@ -274,6 +276,7 @@ struct _Efl_Ui_Win_Data
274 Eina_Bool single_edje_content: 1; /* hack for E */ 276 Eina_Bool single_edje_content: 1; /* hack for E */
275 Eina_Bool shown : 1; 277 Eina_Bool shown : 1;
276 Eina_Bool stack_base : 1; 278 Eina_Bool stack_base : 1;
279 Eina_Bool paused : 1;
277}; 280};
278 281
279struct _Input_Pointer_Iterator 282struct _Input_Pointer_Iterator
@@ -505,6 +508,8 @@ _elm_win_state_eval(void *data EINA_UNUSED)
505 evas_render_dump(evas); 508 evas_render_dump(evas);
506 } 509 }
507 } 510 }
511
512 efl_event_callback_call(obj, EFL_UI_WIN_EVENT_PAUSE, NULL);
508 continue; 513 continue;
509 } 514 }
510 } 515 }
@@ -2180,6 +2185,28 @@ _win_event_del_cb(void *data, const Efl_Event *ev)
2180} 2185}
2181 2186
2182static void 2187static void
2188_win_paused(void *data, const Efl_Event *ev)
2189{
2190 Efl_Ui_Win_Data *sd = data;
2191
2192 if (sd->paused)
2193 {
2194 ERR("A window did receive a pause event while still paused. Dismissing.");
2195 return ;
2196 }
2197 sd->paused = EINA_TRUE;
2198 _paused_windows++;
2199
2200 if (_elm_win_count == _paused_windows)
2201 efl_event_callback_call(efl_loop_get(ev->object), EFL_LOOP_EVENT_PAUSE, NULL);
2202}
2203
2204EFL_CALLBACKS_ARRAY_DEFINE(_elm_win_tracking,
2205 { EFL_EVENT_CALLBACK_ADD, _win_event_add_cb },
2206 { EFL_EVENT_CALLBACK_DEL, _win_event_del_cb },
2207 { EFL_UI_WIN_EVENT_PAUSE, _win_paused })
2208
2209static void
2183_elm_win_cb_mouse_up(void *data, const Efl_Event *ev EINA_UNUSED) 2210_elm_win_cb_mouse_up(void *data, const Efl_Event *ev EINA_UNUSED)
2184{ 2211{
2185 DBG("Evas mouse up event"); 2212 DBG("Evas mouse up event");
@@ -2189,6 +2216,26 @@ _elm_win_cb_mouse_up(void *data, const Efl_Event *ev EINA_UNUSED)
2189} 2216}
2190 2217
2191static void 2218static void
2219_elm_win_resume(void *data, const Efl_Event *ev)
2220{
2221 Efl_Ui_Win_Data *sd = data;
2222
2223 if (!sd->paused) return ;
2224
2225 efl_event_callback_call(sd->obj, EFL_UI_WIN_EVENT_RESUME, NULL);
2226 sd->paused = EINA_FALSE;
2227
2228 if (_elm_win_count == _paused_windows)
2229 efl_event_callback_call(efl_loop_get(ev->object), EFL_LOOP_EVENT_RESUME, NULL);
2230
2231 _paused_windows--;
2232}
2233
2234EFL_CALLBACKS_ARRAY_DEFINE(_elm_evas_tracking,
2235 { EFL_EVENT_POINTER_UP, _elm_win_cb_mouse_up },
2236 { EFL_CANVAS_EVENT_RENDER_PRE, _elm_win_resume })
2237
2238static void
2192_deferred_ecore_evas_free(void *data) 2239_deferred_ecore_evas_free(void *data)
2193{ 2240{
2194 ecore_evas_free(data); 2241 ecore_evas_free(data);
@@ -2810,6 +2857,9 @@ _efl_ui_win_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Win_Data *sd)
2810 _elm_win_count--; 2857 _elm_win_count--;
2811 _elm_win_state_eval_queue(); 2858 _elm_win_state_eval_queue();
2812 2859
2860 if (_elm_win_count == _paused_windows)
2861 efl_event_callback_call(efl_loop_get(obj), EFL_LOOP_EVENT_PAUSE, NULL);
2862
2813 if (sd->ee) 2863 if (sd->ee)
2814 { 2864 {
2815 ecore_evas_callback_delete_request_set(sd->ee, NULL); 2865 ecore_evas_callback_delete_request_set(sd->ee, NULL);
@@ -5298,10 +5348,9 @@ _elm_win_finalize_internal(Eo *obj, Efl_Ui_Win_Data *sd, const char *name, Elm_W
5298 efl_composite_attach(obj, efl_provider_find(ecore_main_loop_get(), EFL_CONFIG_GLOBAL_CLASS)); 5348 efl_composite_attach(obj, efl_provider_find(ecore_main_loop_get(), EFL_CONFIG_GLOBAL_CLASS));
5299 5349
5300 efl_event_callback_array_add(obj, _elm_win_evas_feed_fake_callbacks(), sd->evas); 5350 efl_event_callback_array_add(obj, _elm_win_evas_feed_fake_callbacks(), sd->evas);
5301 efl_event_callback_add(obj, EFL_EVENT_CALLBACK_ADD, _win_event_add_cb, sd); 5351 efl_event_callback_array_add(obj, _elm_evas_tracking(), sd);
5302 efl_event_callback_add(obj, EFL_EVENT_CALLBACK_DEL, _win_event_del_cb, sd);
5303 5352
5304 efl_event_callback_add(sd->evas, EFL_EVENT_POINTER_UP, _elm_win_cb_mouse_up, sd); 5353 efl_event_callback_array_add(sd->evas, _elm_win_tracking(), sd);
5305 evas_object_show(sd->legacy.edje); 5354 evas_object_show(sd->legacy.edje);
5306 5355
5307 if (type == ELM_WIN_FAKE) 5356 if (type == ELM_WIN_FAKE)
@@ -5330,9 +5379,13 @@ _elm_win_finalize_internal(Eo *obj, Efl_Ui_Win_Data *sd, const char *name, Elm_W
5330EOLIAN static Eo * 5379EOLIAN static Eo *
5331_efl_ui_win_efl_object_finalize(Eo *obj, Efl_Ui_Win_Data *sd) 5380_efl_ui_win_efl_object_finalize(Eo *obj, Efl_Ui_Win_Data *sd)
5332{ 5381{
5382 Eina_Bool resume = !_elm_win_count;
5383
5333 obj = _elm_win_finalize_internal(obj, sd, sd->name, sd->type); 5384 obj = _elm_win_finalize_internal(obj, sd, sd->name, sd->type);
5334 if (!obj) return NULL; 5385 if (!obj) return NULL;
5335 return efl_finalize(efl_super(obj, MY_CLASS)); 5386 obj = efl_finalize(efl_super(obj, MY_CLASS));
5387 if (obj && resume) efl_event_callback_call(efl_loop_get(obj), EFL_LOOP_EVENT_RESUME, NULL);
5388 return obj;
5336} 5389}
5337 5390
5338EOLIAN static void 5391EOLIAN static void
diff --git a/src/lib/elementary/efl_ui_win.eo b/src/lib/elementary/efl_ui_win.eo
index 2cae3d776e..9a640f088e 100644
--- a/src/lib/elementary/efl_ui_win.eo
+++ b/src/lib/elementary/efl_ui_win.eo
@@ -889,5 +889,7 @@ class Efl.Ui.Win (Elm.Widget, Efl.Canvas, Efl.Access.Window,
889 wm,rotation,changed; [[Called when window manager rotation changed]] 889 wm,rotation,changed; [[Called when window manager rotation changed]]
890 theme,changed; [[Called when theme changed]] 890 theme,changed; [[Called when theme changed]]
891 elm,action,block_menu; [[Called when elementary block menu action happened]] 891 elm,action,block_menu; [[Called when elementary block menu action happened]]
892 pause; [[Called when the window is going not be displayed for some time]]
893 resume; [[Called before a window get rendered after a pause event]]
892 } 894 }
893} 895}