netstar pushed a commit to branch master.

http://git.enlightenment.org/apps/evisum.git/commit/?id=d4cb84b2fb8a237dd7c9629dd7825912fde2f39e

commit d4cb84b2fb8a237dd7c9629dd7825912fde2f39e
Author: Alastair Poole <nets...@gmail.com>
Date:   Fri Jan 1 17:33:16 2021 +0000

    ui: cache..
---
 src/bin/ui/ui_cache.c        | 24 ++++++++++++++++++++++++
 src/bin/ui/ui_cache.h        |  1 +
 src/bin/ui/ui_process_list.c |  6 +-----
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/src/bin/ui/ui_cache.c b/src/bin/ui/ui_cache.c
index 3912b27..2c3f596 100644
--- a/src/bin/ui/ui_cache.c
+++ b/src/bin/ui/ui_cache.c
@@ -10,6 +10,7 @@ evisum_ui_item_cache_new(Evas_Object *parent,
    cache->parent = parent;
    cache->item_create_cb = create_cb;
    cache->items = NULL;
+   cache->time = time(NULL);
 
    for (int i = 0; i < size; i++)
      {
@@ -50,12 +51,35 @@ evisum_ui_item_cache_item_get(Evisum_Ui_Cache *cache)
    return it;
 }
 
+static int
+_clean_cb(const void *p1, const void *p2)
+{
+   Item_Cache *c1, *c2;
+
+   c1 = (Item_Cache *) p1;
+   c2 = (Item_Cache *) p1;
+
+   if (c1->used == 0 || c2->used == 0)
+     return -1;
+
+   return 1;
+}
+
 Eina_Bool
 evisum_ui_item_cache_item_release(Evisum_Ui_Cache *cache, Evas_Object *obj)
 {
    Item_Cache *it;
    Eina_List *l;
    Eina_Bool released = EINA_FALSE;
+   time_t now = time(NULL);
+
+   if ((now - cache->time) > 60)
+     {
+        cache->items = eina_list_sort(cache->items,
+                                      eina_list_count(cache->items),
+                                      _clean_cb);
+        cache->time = now;
+     }
 
    EINA_LIST_FOREACH(cache->items, l, it)
      {
diff --git a/src/bin/ui/ui_cache.h b/src/bin/ui/ui_cache.h
index 48ebd95..767d4dc 100644
--- a/src/bin/ui/ui_cache.h
+++ b/src/bin/ui/ui_cache.h
@@ -8,6 +8,7 @@ typedef struct _Evisum_Ui_Cache {
    Eina_List   *items;
    Evas_Object *parent;
    Evas_Object *(*item_create_cb)(Evas_Object *);
+   time_t       time;
 } Evisum_Ui_Cache;
 
 typedef struct _Item_Cache {
diff --git a/src/bin/ui/ui_process_list.c b/src/bin/ui/ui_process_list.c
index c805219..3348678 100644
--- a/src/bin/ui/ui_process_list.c
+++ b/src/bin/ui/ui_process_list.c
@@ -362,6 +362,7 @@ _content_get(void *data, Evas_Object *obj, const char 
*source)
 
    if (strcmp(source, "elm.swallow.content")) return NULL;
    if (!proc) return NULL;
+   if (pd->skip_wait) return NULL;
 
    Item_Cache *it = evisum_ui_item_cache_item_get(pd->cache);
    if (!it)
@@ -380,7 +381,6 @@ _content_get(void *data, Evas_Object *obj, const char 
*source)
         if (ow > w)
           {
              evas_object_size_hint_min_set(pd->btn_pid, w, 1);
-             pd->skip_wait = 1;
           }
      }
    rec = evas_object_data_get(lb, "rec");
@@ -402,7 +402,6 @@ _content_get(void *data, Evas_Object *obj, const char 
*source)
         if (ow > w)
           {
              evas_object_size_hint_min_set(pd->btn_uid, w, 1);
-             pd->skip_wait = 1;
           }
      }
    rec = evas_object_data_get(lb, "rec");
@@ -420,7 +419,6 @@ _content_get(void *data, Evas_Object *obj, const char 
*source)
         if (ow > w)
           {
              evas_object_size_hint_min_set(pd->btn_size, w, 1);
-             pd->skip_wait = 1;
           }
      }
    rec = evas_object_data_get(lb, "rec");
@@ -438,7 +436,6 @@ _content_get(void *data, Evas_Object *obj, const char 
*source)
         if (ow > w)
           {
              evas_object_size_hint_min_set(pd->btn_rss, w, 1);
-             pd->skip_wait = 1;
           }
      }
    rec = evas_object_data_get(lb, "rec");
@@ -457,7 +454,6 @@ _content_get(void *data, Evas_Object *obj, const char 
*source)
    if (ow > w)
      {
         evas_object_size_hint_min_set(pd->btn_cmd, w, 1);
-        pd->skip_wait = 1;
      }
    rec = evas_object_data_get(lb, "rec");
    evas_object_size_hint_min_set(rec, w, 1);

-- 


Reply via email to