Enlightenment CVS committal

Author  : onefang
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/bin


Modified Files:
        e_apps.c 


Log Message:
Finish and turn on the new e_app_border_find code.  You can now
optionally turn on old, new, or both for testing purposes using #if's at
the top of the source, but only the new version is turned on by default. 
The question is, is an average 0.00007 seconds border find time worth
the memory hit versus an average 0.003 seconds?  Keeping in mind that if
you have the pager module running, it adds two border finds, and taskbar
adds thirty for some strange reason.  As a bonus e_app_exe_find is also
much quicker.

===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_apps.c,v
retrieving revision 1.217
retrieving revision 1.218
diff -u -3 -r1.217 -r1.218
--- e_apps.c    3 Oct 2006 10:13:07 -0000       1.217
+++ e_apps.c    3 Oct 2006 12:56:00 -0000       1.218
@@ -15,7 +15,14 @@
 
 #define DEBUG 0
 #define IDLE_ICONS 0
-#define CLEVER_BORDERS 0
+
+/* These two can be used to turn on or off the new and old border matching 
code.
+ * There is a printf at the end of e_app_border_find that gives the times and 
results.
+ * You can have both turned on at once for a better comparison.
+ * Just never turn them both off.
+ */
+#define CLEVER_BORDERS 1
+#define OLD_BORDERS 0
 /* local subsystem functions */
 typedef struct _E_App_Change_Info E_App_Change_Info;
 typedef struct _E_App_Callback    E_App_Callback;
@@ -505,7 +512,7 @@
            in_all = 1;
          if (ecore_file_is_dir(a->path))
            {
-              if (!a->filled)
+               if ((!a->idle_fill) && (!a->filled))
                 {
                    snprintf(buf, sizeof(buf), "%s/.directory.eap", path);
                    if (ecore_file_exists(buf))
@@ -514,6 +521,7 @@
                      {
                         a->name = 
evas_stringshare_add(ecore_file_get_file(a->path));
                         a->filled = 1;
+                        a->idle_fill = 1;
                      }
                 }
               if (!a->filled) goto error;
@@ -531,7 +539,7 @@
            }
         else if (_e_app_is_eapp(a->path))
            {
-               if (!a->filled)
+                if ((!a->idle_fill) && (!a->filled))
                   e_app_fields_fill(a, a->path);
                  
                /* no exe field.. not valid. drop it */
@@ -1237,32 +1245,53 @@
 
 
 static void
-_e_apps_winners_add(Evas_Hash **winners, const char *path, int addition)
+_e_apps_winners_add(Evas_Hash **winners, const char *path, const char *name, 
int match_name)
 {
    int *count = NULL;
-   int found = 0;
+   int found = 0, do_it = 0, addition = 1;
+
+   /* Do the name batching magic if we need to. */
+   if (match_name)
+     {
+        E_App *a;
 
-   count = evas_hash_find((*winners), path);
-   if (count)
-      found = 1;
+        /* If class didn't match then we would not be here. */
+       /* Its a match if the name and the border are both NULL. */
+       /* If a name glob was specified in the E_App, then try to match that. */
+        addition = 2;
+        a = e_app_path_find(path);
+       if (a)
+          if ( (!a->win_name) || ((!name) && (!a->win_name)) || 
(e_util_glob_match(name, a->win_name)) )
+              do_it = 1;
+     }
    else
-      count = calloc(1, sizeof(int));  // FIXME: not very efficient, allocate 
a bunch of them in one go and point into the next available one.
+     do_it = 1;
 
-   if (count)
+   if (do_it)
      {
-        (*count) = (*count) + addition;
-        if (found)
-          evas_hash_modify((*winners), path, count);
-       else
-          (*winners) = evas_hash_direct_add((*winners), path, count);
+        count = evas_hash_find((*winners), path);
+        if (count)
+           found = 1;
+        else
+           count = calloc(1, sizeof(int));  // FIXME: not very efficient, 
allocate a bunch of them in one go and point into the next available one.
+
+        if (count)
+          {
+             (*count) = (*count) + addition;
+             if (found)
+               evas_hash_modify((*winners), path, count);
+            else
+               (*winners) = evas_hash_direct_add((*winners), path, count);
+          }
      }
 }
 
 static void
-_e_apps_winners_search(Evas_Hash *non_glob, Evas_List *glob, const char *text, 
Evas_Hash **winners, int addition)
+_e_apps_winners_search(Evas_Hash *non_glob, Evas_List *glob, const char *text, 
const char *name, Evas_Hash **winners, int match_name)
 {
    Evas_List *l, *entry = NULL;
 
+   /* Check the non_glob list first. */
    entry = evas_hash_find(non_glob, text);
    if (entry)
      {
@@ -1271,9 +1300,10 @@
             const char *path;
 
             path = l->data;
-             _e_apps_winners_add(winners, path, addition);
+             _e_apps_winners_add(winners, path, name, match_name);
          }
      }
+   /* Then check the glob lilst. */
    if (glob)
      {
         for (l = glob; l; l = l->next)
@@ -1281,8 +1311,8 @@
              struct _E_App_Glob_List_Entry *glob;
 
             glob = l->data;
-            if (e_util_glob_match(text, glob->path))
-                _e_apps_winners_add(winners, glob->path, addition);
+            if (e_util_glob_match(text, glob->key))
+                _e_apps_winners_add(winners, glob->path, name, match_name);
           }
      }
 }
@@ -1324,8 +1354,7 @@
    title = bd->client.netwm.name;
    if (!title) title = bd->client.icccm.title;
    begin = ecore_time_get();
-/* FIXME:
-  Speed this up.
+/* About the CLEVER_BORDERS code.
   
   ASSUMPTIONS:
     When E execs an E_App, it will fill the E_App first.
@@ -1384,7 +1413,7 @@
      {
         winner.path = NULL;
         winner.ok = 0;
-        if (ok)  /* Fill all E_Apps and try again. */
+        if (ok)  /* Fill all E_Apps and try again on the second pass. */
          {
              for (l = _e_apps_all->subapps; l; l = l->next)
                {
@@ -1395,23 +1424,14 @@
                     e_app_fields_fill(a, a->path);
               }
          }
-        /* FIXME: +2 if class AND name match; +2 if class matches and there is 
no name. */
         if ((bd->client.icccm.class))
-          {
-           _e_apps_winners_search(_e_apps_border_ng_win_class, 
_e_apps_border_g_win_class, bd->client.icccm.class, &winners, 2);
-          }
-
-        if ((bd->client.icccm.name))
-          {
-            _e_apps_winners_search(_e_apps_border_ng_win_name, 
_e_apps_border_g_win_name, bd->client.icccm.name, &winners, 2);
-          }
-
+           _e_apps_winners_search(_e_apps_border_ng_win_class, 
_e_apps_border_g_win_class, bd->client.icccm.class, bd->client.icccm.name, 
&winners, TRUE);
         if ((title))
-           _e_apps_winners_search(_e_apps_border_ng_win_title, 
_e_apps_border_g_win_title, title, &winners, 1);
+           _e_apps_winners_search(_e_apps_border_ng_win_title, 
_e_apps_border_g_win_title, title, NULL, &winners, FALSE);
         if ((bd->client.icccm.window_role))
-           _e_apps_winners_search(_e_apps_border_ng_win_role, 
_e_apps_border_g_win_role, bd->client.icccm.window_role, &winners, 1);
+           _e_apps_winners_search(_e_apps_border_ng_win_role, 
_e_apps_border_g_win_role, bd->client.icccm.window_role, NULL, &winners, FALSE);
         if ((bd->client.icccm.command.argv) && 
(bd->client.icccm.command.argv[0]))
-           _e_apps_winners_search(_e_apps_border_ng_exe, NULL, 
bd->client.icccm.command.argv[0], &winners, 1);
+           _e_apps_winners_search(_e_apps_border_ng_exe, NULL, 
bd->client.icccm.command.argv[0], NULL, &winners, FALSE);
 
         evas_hash_foreach(winners, _e_apps_winners_hash_cb_check_free, 
&winner);
         if (winner.path)
@@ -1426,6 +1446,7 @@
 }
    clever_time = ecore_time_get() - begin;
 #endif
+#if OLD_BORDERS
    for (l = _e_apps_all->subapps; l; l = l->next)
      {
        a = l->data;
@@ -1492,12 +1513,31 @@
        _e_apps_all->subapps = evas_list_remove_list(_e_apps_all->subapps, 
l_match);
        _e_apps_all->subapps = evas_list_prepend(_e_apps_all->subapps, a_match);
      }
+#else
+   a_match = clever_match;
+   clever_match = NULL;
+#endif
    time = ecore_time_get() - begin;
    time -= clever_time;
    border_count++;
    border_time += time;
    border_clever_time += clever_time;
-   printf("APP BORDER SCAN %2.6f, %2.6f (average %2.6f, %2.6f) FOUND %s AND 
%s\n", clever_time, time, border_clever_time / border_count, border_time / 
border_count, ((clever_match == NULL) ? "NOTHING" : clever_match->path), 
((a_match == NULL) ? "NOTHING" : a_match->path));
+#if CLEVER_BORDERS && OLD_BORDERS
+   printf("APP BORDER SCAN NEW - %2.6f, OLD - %2.6f (average %2.6f, %2.6f) 
FOUND %s AND %s\n",
+          clever_time, time, border_clever_time / border_count, border_time / 
border_count, 
+         ((clever_match == NULL) ? "NOTHING" : clever_match->path), ((a_match 
== NULL) ? "NOTHING" : a_match->path));
+#else
+#if CLEVER_BORDERS
+   printf("APP BORDER SCAN NEW - %2.6f (average %2.6f) FOUND %s\n",
+          clever_time, border_clever_time / border_count, 
+         ((a_match == NULL) ? "NOTHING" : a_match->path));
+#endif
+#if OLD_BORDERS
+   printf("APP BORDER SCAN OLD - %2.6f (average %2.6f) FOUND %s\n",
+          time, border_time / border_count, 
+         ((a_match == NULL) ? "NOTHING" : a_match->path));
+#endif
+#endif
    return a_match;
 }
 
@@ -1562,7 +1602,7 @@
        a = l->data;
         E_OBJECT_CHECK_RETURN(a, NULL);
         E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
-        if (!a->filled)
+        if ((!a->idle_fill) && (!a->filled))
          e_app_fields_fill(a, a->path);
        if (!a->filled) continue;
        if (a->name)
@@ -1593,7 +1633,7 @@
        a = l->data;
         E_OBJECT_CHECK_RETURN(a, NULL);
         E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
-        if (!a->filled)
+        if ((!a->idle_fill) && (!a->filled))
          e_app_fields_fill(a, a->path);
        if (!a->filled) continue;
        if (a->generic)
@@ -1633,7 +1673,7 @@
        a = l->data;
         E_OBJECT_CHECK_RETURN(a, NULL);
         E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
-        if (!a->filled)
+        if ((!a->idle_fill) && (!a->filled))
          e_app_fields_fill(a, a->path);
        if (!a->filled) continue;
        if (a->exe)
@@ -1667,7 +1707,7 @@
        a = l->data;
         E_OBJECT_CHECK_RETURN(a, NULL);
         E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
-        if (!a->filled)
+        if ((!a->idle_fill) && (!a->filled))
          e_app_fields_fill(a, a->path);
        if (!a->filled) continue;
        if (a->name)
@@ -1694,7 +1734,7 @@
        a = l->data;
         E_OBJECT_CHECK_RETURN(a, NULL);
         E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
-        if (!a->filled)
+        if ((!a->idle_fill) && (!a->filled))
          e_app_fields_fill(a, a->path);
        if (!a->filled) continue;
        if (a->generic)
@@ -1721,7 +1761,7 @@
        a = l->data;
         E_OBJECT_CHECK_RETURN(a, NULL);
         E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
-        if (!a->filled)
+        if ((!a->idle_fill) && (!a->filled))
          e_app_fields_fill(a, a->path);
        if (!a->filled) continue;
        if (a->exe)
@@ -1748,7 +1788,7 @@
        a = l->data;
         E_OBJECT_CHECK_RETURN(a, NULL);
         E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
-        if (!a->filled)
+        if ((!a->idle_fill) && (!a->filled))
          e_app_fields_fill(a, a->path);
        if (!a->filled)
          continue;
@@ -2191,6 +2231,7 @@
    a->no_icon = 0;
    a->found_icon = 0;
    a->filled = 0;
+   a->idle_fill = 0;
 }
 
 EAPI Ecore_List *
@@ -3040,6 +3081,7 @@
    dst->hard_icon = src->hard_icon;
    dst->no_icon = src->no_icon;
    dst->filled = src->filled;
+   dst->idle_fill = src->idle_fill;
 
    return 1;
 }



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to