From a66491b19681716e674f4a4ab30baff356ea85c6 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Fri, 24 Dec 2010 16:02:30 +0000 Subject: [PATCH] make flush config have a master boolean enable/disable SVN revision: 55744 --- config/default/base.src | 1 + config/illume/base.src | 1 + config/standard/base.src | 1 + src/bin/config.c | 30 +++++++++++++++++++--- src/lib/Elementary.h.in | 3 +++ src/lib/elm_config.c | 46 +++++++++++++++++++++++----------- src/lib/elm_main.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/elm_priv.h | 1 + 8 files changed, 130 insertions(+), 18 deletions(-) diff --git a/config/default/base.src b/config/default/base.src index 1101c8f..5bc2be3 100644 --- a/config/default/base.src +++ b/config/default/base.src @@ -16,6 +16,7 @@ group "Elm_Config" struct { value "compositing" int: 1; value "font_hinting" int: 2; value "cache_flush_poll_interval" int: 512; + value "cache_flush_enable" uchar: 1; value "image_cache" int: 4096; value "font_cache" int: 512; value "edje_cache" int: 32; diff --git a/config/illume/base.src b/config/illume/base.src index 1101c8f..5bc2be3 100644 --- a/config/illume/base.src +++ b/config/illume/base.src @@ -16,6 +16,7 @@ group "Elm_Config" struct { value "compositing" int: 1; value "font_hinting" int: 2; value "cache_flush_poll_interval" int: 512; + value "cache_flush_enable" uchar: 1; value "image_cache" int: 4096; value "font_cache" int: 512; value "edje_cache" int: 32; diff --git a/config/standard/base.src b/config/standard/base.src index 4e6be3b..142e0e7 100644 --- a/config/standard/base.src +++ b/config/standard/base.src @@ -16,6 +16,7 @@ group "Elm_Config" struct { value "compositing" int: 1; value "font_hinting" int: 2; value "cache_flush_poll_interval" int: 512; + value "cache_flush_enable" uchar: 1; value "image_cache" int: 4096; value "font_cache" int: 512; value "edje_cache" int: 32; diff --git a/src/bin/config.c b/src/bin/config.c index 1a2a2b8..8bc8ed4 100644 --- a/src/bin/config.c +++ b/src/bin/config.c @@ -358,6 +358,19 @@ tsbf_change(void *data __UNUSED__, } static void +cf_enable(void *data, + Evas_Object *obj, + void *event_info __UNUSED__) +{ + Eina_Bool cf = elm_cache_flush_enmabled_get(); + Eina_Bool val = elm_check_state_get(obj); + + if (cf == val) return; + elm_object_disabled_set((Evas_Object *)data, !val); + elm_cache_flush_enabled_all_set(val); +} + +static void cf_round(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) @@ -2694,13 +2707,13 @@ static void _status_config_caches(Evas_Object *win, Evas_Object *pager) { - Evas_Object *lb, *pd, *bx, *sl, *sp; + Evas_Object *lb, *pd, *bx, *sl, *sp, *ck; bx = elm_box_add(win); evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0); evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5); - LABEL_FRAME_ADD("Cache Flush Interval"); + LABEL_FRAME_ADD("Cache Flush Interval (8 ticks pre second)"); sl = elm_slider_add(win); evas_object_data_set(win, "cache_flush_interval_slider", sl); @@ -2711,9 +2724,20 @@ _status_config_caches(Evas_Object *win, elm_slider_indicator_format_set(sl, "%1.0f"); elm_slider_min_max_set(sl, 8.0, 4096.0); elm_slider_value_set(sl, elm_cache_flush_interval_get()); + elm_object_disabled_set(sl, !elm_cache_flush_enmabled_get()); + + ck = elm_check_add(win); + evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(ck, EVAS_HINT_FILL, 0.5); + elm_check_label_set(ck, "Enable Flushing"); + elm_check_state_set(ck, elm_cache_flush_enmabled_get()); + evas_object_smart_callback_add(ck, "changed", cf_enable, sl); + elm_box_pack_end(bx, ck); + evas_object_show(ck); + elm_box_pack_end(bx, sl); evas_object_show(sl); - + evas_object_smart_callback_add(sl, "changed", cf_round, NULL); evas_object_smart_callback_add(sl, "delay,changed", cf_change, NULL); diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index c1e7208..5f8ba3e 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -255,6 +255,9 @@ extern "C" { EAPI int elm_cache_flush_interval_get(void); EAPI void elm_cache_flush_interval_set(int size); EAPI void elm_cache_flush_interval_all_set(int size); + EAPI Eina_Bool elm_cache_flush_enmabled_get(void); + EAPI void elm_cache_flush_enabled_set(Eina_Bool enabled); + EAPI void elm_cache_flush_enabled_all_set(Eina_Bool enabled); EAPI int elm_font_cache_get(void); EAPI void elm_font_cache_set(int size); EAPI void elm_font_cache_all_set(int size); diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c index 53f102e..3e0511a 100644 --- a/src/lib/elm_config.c +++ b/src/lib/elm_config.c @@ -84,6 +84,7 @@ static const char *_atom_names[ATOM_COUNT] = "ENLIGHTENMENT_PROFILE", "ENLIGHTENMENT_FONT_OVERLAY", "ENLIGHTENMENT_CACHE_FLUSH_INTERVAL", + "ENLIGHTENMENT_CACHE_FLUSH_ENABLE", "ENLIGHTENMENT_FONT_CACHE", "ENLIGHTENMENT_IMAGE_CACHE", "ENLIGHTENMENT_EDJE_FILE_CACHE", @@ -106,21 +107,22 @@ static const char *_atom_names[ATOM_COUNT] = #define ATOM_E_PROFILE 3 #define ATOM_E_FONT_OVERLAY 4 #define ATOM_E_CACHE_FLUSH_INTERVAL 5 -#define ATOM_E_FONT_CACHE 6 -#define ATOM_E_IMAGE_CACHE 7 -#define ATOM_E_EDJE_FILE_CACHE 8 -#define ATOM_E_EDJE_COLLECTION_CACHE 9 -#define ATOM_E_THUMBSCROLL_BOUNCE_ENABLE 10 -#define ATOM_E_THUMBSCROLL_BOUNCE_FRICTION 11 -#define ATOM_E_THUMBSCROLL_ENABLE 12 -#define ATOM_E_THUMBSCROLL_THRESHOLD 13 -#define ATOM_E_THUMBSCROLL_MOMENTUM_THRESHOLD 14 -#define ATOM_E_THUMBSCROLL_FRICTION 15 -#define ATOM_E_THUMBSCROLL_BORDER_FRICTION 16 -#define ATOM_E_THUMBSCROLL_PAGE_SCROLL_FRICTION 17 -#define ATOM_E_THUMBSCROLL_BRING_IN_SCROLL_FRICTION 18 -#define ATOM_E_THUMBSCROLL_ZOOM_FRICTION 19 -#define ATOM_E_CONFIG 20 +#define ATOM_E_CACHE_FLUSH_ENABLE 6 +#define ATOM_E_FONT_CACHE 7 +#define ATOM_E_IMAGE_CACHE 8 +#define ATOM_E_EDJE_FILE_CACHE 9 +#define ATOM_E_EDJE_COLLECTION_CACHE 10 +#define ATOM_E_THUMBSCROLL_BOUNCE_ENABLE 11 +#define ATOM_E_THUMBSCROLL_BOUNCE_FRICTION 12 +#define ATOM_E_THUMBSCROLL_ENABLE 13 +#define ATOM_E_THUMBSCROLL_THRESHOLD 14 +#define ATOM_E_THUMBSCROLL_MOMENTUM_THRESHOLD 15 +#define ATOM_E_THUMBSCROLL_FRICTION 16 +#define ATOM_E_THUMBSCROLL_BORDER_FRICTION 17 +#define ATOM_E_THUMBSCROLL_PAGE_SCROLL_FRICTION 18 +#define ATOM_E_THUMBSCROLL_BRING_IN_SCROLL_FRICTION 19 +#define ATOM_E_THUMBSCROLL_ZOOM_FRICTION 20 +#define ATOM_E_CONFIG 21 static Eina_Bool _prop_config_get(void); static Eina_Bool _prop_change(void *data __UNUSED__, @@ -303,6 +305,18 @@ _prop_change(void *data __UNUSED__, _elm_recache(); } } + else if (event->atom == _atom[ATOM_E_CACHE_FLUSH_ENABLE]) + { + unsigned int val = 1000; + + if (ecore_x_window_prop_card32_get(event->win, + event->atom, + &val, 1) > 0) + { + _elm_config->cache_flush_enable = !!val; + _elm_recache(); + } + } else if (event->atom == _atom[ATOM_E_FONT_CACHE]) { unsigned int val = 1000; @@ -565,6 +579,7 @@ _desc_init(void) ELM_CONFIG_LIST(D, T, font_overlays, _config_font_overlay_edd); ELM_CONFIG_VAL(D, T, font_hinting, T_INT); ELM_CONFIG_VAL(D, T, cache_flush_poll_interval, T_INT); + ELM_CONFIG_VAL(D, T, cache_flush_enable, T_UCHAR); ELM_CONFIG_VAL(D, T, image_cache, T_INT); ELM_CONFIG_VAL(D, T, font_cache, T_INT); ELM_CONFIG_VAL(D, T, edje_cache, T_INT); @@ -1102,6 +1117,7 @@ _config_load(void) _elm_config->compositing = 1; _elm_config->font_hinting = 2; _elm_config->cache_flush_poll_interval = 512; + _elm_config->cache_flush_enable = EINA_TRUE; _elm_config->font_dirs = NULL; _elm_config->image_cache = 4096; _elm_config->font_cache = 512; diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c index e395e66..ef20b61 100644 --- a/src/lib/elm_main.c +++ b/src/lib/elm_main.c @@ -1903,6 +1903,71 @@ elm_cache_flush_interval_all_set(int size) } /** + * Get the configured cache flush enabled state + * + * This gets the globally configured cache flush state - if it is enabled + * or not. When cache flushing is enabled, elementary will regularly + * (see elm_cache_flush_interval_get() ) flush caches and dump data out of + * memory and allow usage to re-seed caches and data in memory where it + * can do so. An idle application will thus minimise its memory usage as + * data will be freed from memory and not be re-loaded as it is idle and + * not rendering or doing anything graphically right now. + * + * @return The cache flush state + * @ingroup Caches + * + * @see elm_all_flush() + */ +EAPI Eina_Bool +elm_cache_flush_enmabled_get(void) +{ + return _elm_config->cache_flush_enable; +} + +/** + * Set the configured cache flush enabled state + * + * This sets the globally configured cache flush enabled state + * + * @param size The cache flush enabled state + * @ingroup Caches + * + * @see elm_all_flush() + */ +EAPI void +elm_cache_flush_enabled_set(Eina_Bool enabled) +{ + enabled = !!enabled; + if (_elm_config->cache_flush_enable == enabled) return; + _elm_config->cache_flush_enable = enabled; + + _elm_recache(); +} + +/** + * Set the configured cache flush enabled state for all applications on the + * display + * + * This sets the globally configured cache flush enabled state for all + * applications on the display. + * + * @param size The cache flush enabled state + * @ingroup Caches + */ +EAPI void +elm_cache_flush_enabled_all_set(Eina_Bool enabled) +{ +#ifdef HAVE_ELEMENTARY_X + static Ecore_X_Atom atom = 0; + unsigned int enabled_i = (unsigned int)enabled; + + if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_CACHE_FLUSH_ENABLE"); + ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(), + atom, &enabled_i, 1); +#endif +} + +/** * Get the configured font cache size * * This gets the globally configured font cache size, in bytes diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h index 332e74e..90686c9 100644 --- a/src/lib/elm_priv.h +++ b/src/lib/elm_priv.h @@ -93,6 +93,7 @@ struct _Elm_Config Eina_List *font_overlays; int font_hinting; int cache_flush_poll_interval; + Eina_Bool cache_flush_enable; int image_cache; int font_cache; int edje_cache; -- 2.7.4