summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-09-04 15:09:10 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-09-04 15:09:10 +0900
commitf18fda182e6cf7bddc1dd9c8e6a07a336e0a4c95 (patch)
treef56f7b8521787904a8d4848be4d8c15d366f71f2 /src/lib
parent7bbd247a61c2df0894b1086b07e2d43e92954eb5 (diff)
elm process state - add events and state get function
this adds the ability to query current process state, and get events idicating a change in process state and what change that was. @feature
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/elm_general.h35
-rw-r--r--src/lib/elm_main.c6
-rw-r--r--src/lib/elm_win.c69
3 files changed, 83 insertions, 27 deletions
diff --git a/src/lib/elm_general.h b/src/lib/elm_general.h
index 03adee736..88d9ff16f 100644
--- a/src/lib/elm_general.h
+++ b/src/lib/elm_general.h
@@ -50,6 +50,20 @@ EAPI extern int ELM_EVENT_CONFIG_ALL_CHANGED;
50EAPI extern int ELM_EVENT_POLICY_CHANGED; 50EAPI extern int ELM_EVENT_POLICY_CHANGED;
51 51
52/** 52/**
53 * Emitted when nothing is visible and the process as a whole should go into
54 * a background state.
55 * @since 1.12
56 */
57EAPI extern int ELM_EVENT_PROCESS_BACKGROUND;
58
59/**
60 * Emitted when going from nothing being visible to at least one window
61 * being visible.
62 * @since 1.12
63 */
64EAPI extern int ELM_EVENT_PROCESS_FOREGROUND;
65
66/**
53 * @typedef Elm_Event_Policy_Changed 67 * @typedef Elm_Event_Policy_Changed
54 * 68 *
55 * Data on the event when an Elementary policy has changed 69 * Data on the event when an Elementary policy has changed
@@ -350,6 +364,27 @@ EAPI int elm_policy_get(unsigned int policy);
350 */ 364 */
351EAPI void elm_language_set(const char *lang); 365EAPI void elm_language_set(const char *lang);
352 366
367typedef enum _Elm_Process_State
368{
369 ELM_PROCESS_STATE_FOREGROUND, /*< The process is in a foreground/active/running state - work as normal. @since 1.12 */
370 ELM_PROCESS_STATE_BACKGROUND /*< The process is in the bacgkround, so you may want to stop animating, fetching data as often etc. @since 1.12 */
371} Elm_Process_State; /** The state of the process as a whole. @since 1.12 */
372
373/**
374 * Get the process state as a while
375 *
376 * @return The current process state
377 *
378 * The process may logically be some runnable state. a "foreground" application
379 * runs as normal and may be user-visible or "active" in some way. A
380 * background application is not user-visible or otherwise important and
381 * likely should release resources and not wake up often or process much.
382 *
383 * @ingroup General
384 * @since 1.12
385 */
386EAPI Elm_Process_State elm_process_state_get(void);
387
353/** 388/**
354 * @} 389 * @}
355 */ 390 */
diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c
index 905db6264..ee73d8aab 100644
--- a/src/lib/elm_main.c
+++ b/src/lib/elm_main.c
@@ -65,6 +65,8 @@ const char *_elm_lib_dir = NULL;
65int _elm_log_dom = -1; 65int _elm_log_dom = -1;
66 66
67EAPI int ELM_EVENT_POLICY_CHANGED = 0; 67EAPI int ELM_EVENT_POLICY_CHANGED = 0;
68EAPI int ELM_EVENT_PROCESS_BACKGROUND = 0;
69EAPI int ELM_EVENT_PROCESS_FOREGROUND = 0;
68 70
69static int _elm_init_count = 0; 71static int _elm_init_count = 0;
70static int _elm_sub_init_count = 0; 72static int _elm_sub_init_count = 0;
@@ -612,6 +614,10 @@ elm_quicklaunch_init(int argc,
612 memset(_elm_policies, 0, sizeof(_elm_policies)); 614 memset(_elm_policies, 0, sizeof(_elm_policies));
613 if (!ELM_EVENT_POLICY_CHANGED) 615 if (!ELM_EVENT_POLICY_CHANGED)
614 ELM_EVENT_POLICY_CHANGED = ecore_event_type_new(); 616 ELM_EVENT_POLICY_CHANGED = ecore_event_type_new();
617 if (!ELM_EVENT_PROCESS_BACKGROUND)
618 ELM_EVENT_PROCESS_BACKGROUND = ecore_event_type_new();
619 if (!ELM_EVENT_PROCESS_FOREGROUND)
620 ELM_EVENT_PROCESS_FOREGROUND = ecore_event_type_new();
615 621
616 ecore_file_init(); 622 ecore_file_init();
617 eio_init(); 623 eio_init();
diff --git a/src/lib/elm_win.c b/src/lib/elm_win.c
index a5f93edaf..1de207578 100644
--- a/src/lib/elm_win.c
+++ b/src/lib/elm_win.c
@@ -345,6 +345,15 @@ _win_noblank_eval(void)
345#endif 345#endif
346} 346}
347 347
348static Elm_Process_State _elm_process_state = ELM_PROCESS_STATE_FOREGROUND;
349
350EAPI Elm_Process_State
351elm_process_state_get(void)
352{
353 return _elm_process_state;
354}
355
356
348static void 357static void
349_elm_win_state_eval(void *data EINA_UNUSED) 358_elm_win_state_eval(void *data EINA_UNUSED)
350{ 359{
@@ -353,6 +362,7 @@ _elm_win_state_eval(void *data EINA_UNUSED)
353 int _elm_win_count_shown = 0; 362 int _elm_win_count_shown = 0;
354 int _elm_win_count_iconified = 0; 363 int _elm_win_count_iconified = 0;
355 int _elm_win_count_withdrawn = 0; 364 int _elm_win_count_withdrawn = 0;
365 Eina_Bool throttle = EINA_FALSE;
356 366
357 _elm_win_state_eval_job = NULL; 367 _elm_win_state_eval_job = NULL;
358 368
@@ -397,41 +407,46 @@ _elm_win_state_eval(void *data EINA_UNUSED)
397 if (((_elm_config->auto_throttle) && 407 if (((_elm_config->auto_throttle) &&
398 (elm_policy_get(ELM_POLICY_THROTTLE) != ELM_POLICY_THROTTLE_NEVER)) || 408 (elm_policy_get(ELM_POLICY_THROTTLE) != ELM_POLICY_THROTTLE_NEVER)) ||
399 (elm_policy_get(ELM_POLICY_THROTTLE) == ELM_POLICY_THROTTLE_HIDDEN_ALWAYS)) 409 (elm_policy_get(ELM_POLICY_THROTTLE) == ELM_POLICY_THROTTLE_HIDDEN_ALWAYS))
410 throttle = EINA_TRUE;
411 if (_elm_win_count == 0)
400 { 412 {
401 if (_elm_win_count == 0) 413 if (_elm_win_auto_throttled)
402 { 414 {
403 if (_elm_win_auto_throttled) 415 _elm_process_state = ELM_PROCESS_STATE_FOREGROUND;
416 ecore_event_add(ELM_EVENT_PROCESS_FOREGROUND, NULL, NULL, NULL);
417 if (throttle)
418 ecore_throttle_adjust(-_elm_config->auto_throttle_amount);
419 _elm_win_auto_throttled = EINA_FALSE;
420 }
421 }
422 else
423 {
424 EINA_LIST_FOREACH(_elm_win_list, l, obj)
425 {
426 if (elm_win_withdrawn_get(obj)) _elm_win_count_withdrawn++;
427 else if (elm_win_iconified_get(obj)) _elm_win_count_iconified++;
428 else if (evas_object_visible_get(obj)) _elm_win_count_shown++;
429 }
430 if (_elm_win_count_shown <= 0)
431 {
432 if (!_elm_win_auto_throttled)
404 { 433 {
405 ecore_throttle_adjust(-_elm_config->auto_throttle_amount); 434 _elm_process_state = ELM_PROCESS_STATE_BACKGROUND;
406 _elm_win_auto_throttled = EINA_FALSE; 435 ecore_event_add(ELM_EVENT_PROCESS_BACKGROUND, NULL, NULL, NULL);
436 if (throttle)
437 ecore_throttle_adjust(_elm_config->auto_throttle_amount);
438 _elm_win_auto_throttled = EINA_TRUE;
407 } 439 }
408 } 440 }
409 else 441 else
410 { 442 {
411 EINA_LIST_FOREACH(_elm_win_list, l, obj) 443 if (_elm_win_auto_throttled)
412 {
413 if (elm_win_withdrawn_get(obj))
414 _elm_win_count_withdrawn++;
415 else if (elm_win_iconified_get(obj))
416 _elm_win_count_iconified++;
417 else if (evas_object_visible_get(obj))
418 _elm_win_count_shown++;
419 }
420 if (_elm_win_count_shown <= 0)
421 {
422 if (!_elm_win_auto_throttled)
423 {
424 ecore_throttle_adjust(_elm_config->auto_throttle_amount);
425 _elm_win_auto_throttled = EINA_TRUE;
426 }
427 }
428 else
429 { 444 {
430 if (_elm_win_auto_throttled) 445 _elm_process_state = ELM_PROCESS_STATE_FOREGROUND;
431 { 446 ecore_event_add(ELM_EVENT_PROCESS_FOREGROUND, NULL, NULL, NULL);
432 ecore_throttle_adjust(-_elm_config->auto_throttle_amount); 447 if (throttle)
433 _elm_win_auto_throttled = EINA_FALSE; 448 ecore_throttle_adjust(-_elm_config->auto_throttle_amount);
434 } 449 _elm_win_auto_throttled = EINA_FALSE;
435 } 450 }
436 } 451 }
437 } 452 }