elementary: add an interface to enable/disable PAUSE/RESUME application state.
authorCedric Bail <cedric@osg.samsung.com>
Wed, 15 Nov 2017 23:08:32 +0000 (15:08 -0800)
committerCedric Bail <cedric@osg.samsung.com>
Thu, 16 Nov 2017 00:28:20 +0000 (16:28 -0800)
If you want to have EFL application behave in a more efficient way. Like dropping
memory usage or stopping unecessary network operation, this option should be on
and the application should listen on PAUSE/RESUME event on the main loop.

src/bin/elementary/config.c
src/lib/elementary/elm_config.c
src/lib/elementary/elm_config.h

index 7e60377..8870ad7 100644 (file)
@@ -3963,6 +3963,19 @@ _cb_vsync(void *data EINA_UNUSED, Evas_Object *obj, void *info EINA_UNUSED)
 }
 
 static void
+_cb_withdrawn(void *data EINA_UNUSED, Evas_Object *obj, void *info EINA_UNUSED)
+{
+   Eina_Bool val = elm_check_state_get(obj);
+   Eina_Bool sb = elm_config_agressive_withdrawn_get();
+
+   if (val != sb)
+     {
+        elm_config_agressive_withdrawn_set(val);
+        elm_config_all_flush();
+     }
+}
+
+static void
 _status_config_rendering(Evas_Object *win,
                          Evas_Object *naviframe)
 {
@@ -4030,6 +4043,13 @@ _status_config_rendering(Evas_Object *win,
              _cb_vsync, NULL);
    elm_check_state_set(ck, elm_config_vsync_get());
 
+   CHECK_ADD("Aggressive withdrawn",
+             "When the application is iconified it will<br>"
+             "drop its ressource and switch to a paused state<br>"
+             "if the application handle that lifecycle state.",
+             _cb_withdrawn, NULL);
+   elm_check_state_set(ck, elm_config_agressive_withdrawn_get());
+
    evas_object_data_set(win, "rendering", bx);
    elm_naviframe_item_simple_push(naviframe, bx);
 }
index 26cddfb..4c312b3 100644 (file)
@@ -3359,6 +3359,24 @@ elm_config_vsync_set(Eina_Bool enabled)
 }
 
 EAPI Eina_Bool
+elm_config_agressive_withdrawn_get(void)
+{
+   return _elm_config->auto_norender_withdrawn &&
+     _elm_config->auto_norender_iconified_same_as_withdrawn &&
+     _elm_config->auto_flush_withdrawn &&
+     _elm_config->auto_dump_withdrawn;
+}
+
+EAPI void
+elm_config_agressive_withdrawn_set(Eina_Bool enabled)
+{
+   _elm_config->auto_norender_withdrawn = enabled;
+   _elm_config->auto_norender_iconified_same_as_withdrawn = enabled;
+   _elm_config->auto_flush_withdrawn = enabled;
+   _elm_config->auto_dump_withdrawn = enabled;
+}
+
+EAPI Eina_Bool
 elm_config_accel_preference_override_get(void)
 {
    return _elm_config->accel_override;
index 019975d..aa83915 100644 (file)
@@ -1542,6 +1542,26 @@ EAPI Eina_Bool  elm_config_vsync_get(void);
 EAPI void       elm_config_vsync_set(Eina_Bool enabled);
 
 /**
+ * Get the configure flag that will define if a window agressively drop its
+ * ressource when minimized.
+ *
+ * @return if it does.
+ *
+ * @since 1.21
+ */
+EAPI Eina_Bool elm_config_agressive_withdrawn_get(void);
+
+/**
+ * Set the configure flag that will make a window agressively drop its
+ * ressource when minimized.
+ *
+ * @param enabled This should be @c EINA_TRUE if enabled, or @c EINA_FALSE if
+ * not.
+ * @since 1.21
+ */
+EAPI void elm_config_agressive_withdrawn_set(Eina_Bool enabled);
+
+/**
  * Get the acceleration override preference flag
  *
  * This gets the acceleration override preference. This is a flag that