forked from enlightenment/efl
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
This commit is contained in:
parent
e2a14d22ae
commit
dada522426
|
@ -49,6 +49,20 @@ EAPI extern int ELM_EVENT_CONFIG_ALL_CHANGED;
|
|||
*/
|
||||
EAPI extern int ELM_EVENT_POLICY_CHANGED;
|
||||
|
||||
/**
|
||||
* Emitted when nothing is visible and the process as a whole should go into
|
||||
* a background state.
|
||||
* @since 1.12
|
||||
*/
|
||||
EAPI extern int ELM_EVENT_PROCESS_BACKGROUND;
|
||||
|
||||
/**
|
||||
* Emitted when going from nothing being visible to at least one window
|
||||
* being visible.
|
||||
* @since 1.12
|
||||
*/
|
||||
EAPI extern int ELM_EVENT_PROCESS_FOREGROUND;
|
||||
|
||||
/**
|
||||
* @typedef Elm_Event_Policy_Changed
|
||||
*
|
||||
|
@ -350,6 +364,27 @@ EAPI int elm_policy_get(unsigned int policy);
|
|||
*/
|
||||
EAPI void elm_language_set(const char *lang);
|
||||
|
||||
typedef enum _Elm_Process_State
|
||||
{
|
||||
ELM_PROCESS_STATE_FOREGROUND, /*< The process is in a foreground/active/running state - work as normal. @since 1.12 */
|
||||
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 */
|
||||
} Elm_Process_State; /** The state of the process as a whole. @since 1.12 */
|
||||
|
||||
/**
|
||||
* Get the process state as a while
|
||||
*
|
||||
* @return The current process state
|
||||
*
|
||||
* The process may logically be some runnable state. a "foreground" application
|
||||
* runs as normal and may be user-visible or "active" in some way. A
|
||||
* background application is not user-visible or otherwise important and
|
||||
* likely should release resources and not wake up often or process much.
|
||||
*
|
||||
* @ingroup General
|
||||
* @since 1.12
|
||||
*/
|
||||
EAPI Elm_Process_State elm_process_state_get(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -65,6 +65,8 @@ const char *_elm_lib_dir = NULL;
|
|||
int _elm_log_dom = -1;
|
||||
|
||||
EAPI int ELM_EVENT_POLICY_CHANGED = 0;
|
||||
EAPI int ELM_EVENT_PROCESS_BACKGROUND = 0;
|
||||
EAPI int ELM_EVENT_PROCESS_FOREGROUND = 0;
|
||||
|
||||
static int _elm_init_count = 0;
|
||||
static int _elm_sub_init_count = 0;
|
||||
|
@ -612,6 +614,10 @@ elm_quicklaunch_init(int argc,
|
|||
memset(_elm_policies, 0, sizeof(_elm_policies));
|
||||
if (!ELM_EVENT_POLICY_CHANGED)
|
||||
ELM_EVENT_POLICY_CHANGED = ecore_event_type_new();
|
||||
if (!ELM_EVENT_PROCESS_BACKGROUND)
|
||||
ELM_EVENT_PROCESS_BACKGROUND = ecore_event_type_new();
|
||||
if (!ELM_EVENT_PROCESS_FOREGROUND)
|
||||
ELM_EVENT_PROCESS_FOREGROUND = ecore_event_type_new();
|
||||
|
||||
ecore_file_init();
|
||||
eio_init();
|
||||
|
|
|
@ -345,6 +345,15 @@ _win_noblank_eval(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
static Elm_Process_State _elm_process_state = ELM_PROCESS_STATE_FOREGROUND;
|
||||
|
||||
EAPI Elm_Process_State
|
||||
elm_process_state_get(void)
|
||||
{
|
||||
return _elm_process_state;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_elm_win_state_eval(void *data EINA_UNUSED)
|
||||
{
|
||||
|
@ -353,6 +362,7 @@ _elm_win_state_eval(void *data EINA_UNUSED)
|
|||
int _elm_win_count_shown = 0;
|
||||
int _elm_win_count_iconified = 0;
|
||||
int _elm_win_count_withdrawn = 0;
|
||||
Eina_Bool throttle = EINA_FALSE;
|
||||
|
||||
_elm_win_state_eval_job = NULL;
|
||||
|
||||
|
@ -397,41 +407,46 @@ _elm_win_state_eval(void *data EINA_UNUSED)
|
|||
if (((_elm_config->auto_throttle) &&
|
||||
(elm_policy_get(ELM_POLICY_THROTTLE) != ELM_POLICY_THROTTLE_NEVER)) ||
|
||||
(elm_policy_get(ELM_POLICY_THROTTLE) == ELM_POLICY_THROTTLE_HIDDEN_ALWAYS))
|
||||
throttle = EINA_TRUE;
|
||||
if (_elm_win_count == 0)
|
||||
{
|
||||
if (_elm_win_count == 0)
|
||||
if (_elm_win_auto_throttled)
|
||||
{
|
||||
if (_elm_win_auto_throttled)
|
||||
_elm_process_state = ELM_PROCESS_STATE_FOREGROUND;
|
||||
ecore_event_add(ELM_EVENT_PROCESS_FOREGROUND, NULL, NULL, NULL);
|
||||
if (throttle)
|
||||
ecore_throttle_adjust(-_elm_config->auto_throttle_amount);
|
||||
_elm_win_auto_throttled = EINA_FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EINA_LIST_FOREACH(_elm_win_list, l, obj)
|
||||
{
|
||||
if (elm_win_withdrawn_get(obj)) _elm_win_count_withdrawn++;
|
||||
else if (elm_win_iconified_get(obj)) _elm_win_count_iconified++;
|
||||
else if (evas_object_visible_get(obj)) _elm_win_count_shown++;
|
||||
}
|
||||
if (_elm_win_count_shown <= 0)
|
||||
{
|
||||
if (!_elm_win_auto_throttled)
|
||||
{
|
||||
ecore_throttle_adjust(-_elm_config->auto_throttle_amount);
|
||||
_elm_win_auto_throttled = EINA_FALSE;
|
||||
_elm_process_state = ELM_PROCESS_STATE_BACKGROUND;
|
||||
ecore_event_add(ELM_EVENT_PROCESS_BACKGROUND, NULL, NULL, NULL);
|
||||
if (throttle)
|
||||
ecore_throttle_adjust(_elm_config->auto_throttle_amount);
|
||||
_elm_win_auto_throttled = EINA_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EINA_LIST_FOREACH(_elm_win_list, l, obj)
|
||||
if (_elm_win_auto_throttled)
|
||||
{
|
||||
if (elm_win_withdrawn_get(obj))
|
||||
_elm_win_count_withdrawn++;
|
||||
else if (elm_win_iconified_get(obj))
|
||||
_elm_win_count_iconified++;
|
||||
else if (evas_object_visible_get(obj))
|
||||
_elm_win_count_shown++;
|
||||
}
|
||||
if (_elm_win_count_shown <= 0)
|
||||
{
|
||||
if (!_elm_win_auto_throttled)
|
||||
{
|
||||
ecore_throttle_adjust(_elm_config->auto_throttle_amount);
|
||||
_elm_win_auto_throttled = EINA_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_elm_win_auto_throttled)
|
||||
{
|
||||
ecore_throttle_adjust(-_elm_config->auto_throttle_amount);
|
||||
_elm_win_auto_throttled = EINA_FALSE;
|
||||
}
|
||||
_elm_process_state = ELM_PROCESS_STATE_FOREGROUND;
|
||||
ecore_event_add(ELM_EVENT_PROCESS_FOREGROUND, NULL, NULL, NULL);
|
||||
if (throttle)
|
||||
ecore_throttle_adjust(-_elm_config->auto_throttle_amount);
|
||||
_elm_win_auto_throttled = EINA_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue