Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        E.h ecore-e16.c lists.c memory.c snaps.c 


Log Message:
Client adoption changes - continued. Cleanups, various bug fixes.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.504
retrieving revision 1.505
diff -u -3 -r1.504 -r1.505
--- E.h 29 Oct 2005 13:09:31 -0000      1.504
+++ E.h 30 Oct 2005 01:05:26 -0000      1.505
@@ -608,6 +608,10 @@
 {
    struct
    {
+      unsigned int        startup_id;
+   } apps;
+   struct
+   {
       char               *name;
       char               *dir;
       char               *cache_dir;
@@ -1112,6 +1116,8 @@
 #define _EFREE(p)    do { if (p) { Efree(p); p = NULL; } } while (0)
 #define _EFDUP(p, s) do { if (p) Efree(p); p = Estrdup(s); } while (0)
 
+char               *Estrtrim(char *s);
+
 #if USE_LIBC_STRDUP
 #define Estrdup(s) ((s) ? strdup(s) : NULL)
 #else
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/ecore-e16.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- ecore-e16.c 10 Jul 2005 00:23:52 -0000      1.16
+++ ecore-e16.c 30 Oct 2005 01:05:26 -0000      1.17
@@ -270,7 +270,8 @@
               {
                  pstr = malloc(items * sizeof(char *));
                  for (i = 0; i < items; i++)
-                    pstr[i] = (list[i]) ? strdup(list[i]) : NULL;
+                    pstr[i] = (list[i] && (*list[i] || i < items - 1)) ?
+                       strdup(list[i]) : NULL;
               }
             if (list)
                XFreeStringList(list);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/lists.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- lists.c     25 Sep 2005 13:24:25 -0000      1.19
+++ lists.c     30 Oct 2005 01:05:26 -0000      1.20
@@ -47,9 +47,11 @@
    ptr = lists[type].next;
    if (find_by == LIST_FINDBY_NAME)
      {
+       if (!name)
+          return NULL;
        while (ptr)
          {
-            if ((!strcmp(name, ptr->name)))
+            if (!strcmp(name, ptr->name))
                return ptr->item;
             ptr = ptr->next;
          }
@@ -65,6 +67,8 @@
      }
    else if (find_by == LIST_FINDBY_BOTH)
      {
+       if (!name)
+          return NULL;
        while (ptr)
          {
             if ((!strcmp(name, ptr->name)) && (ptr->id == id))
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/memory.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -3 -r1.46 -r1.47
--- memory.c    16 Jul 2005 15:53:53 -0000      1.46
+++ memory.c    30 Oct 2005 01:05:26 -0000      1.47
@@ -22,6 +22,25 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 #include "E.h"
+#include <ctype.h>
+
+char               *
+Estrtrim(char *s)
+{
+   int                 l;
+
+   while (*s == ' ')
+      s++;
+   if (!*s)
+      return s;
+
+   l = strlen(s);
+   while (isspace(s[l - 1]))
+      l--;
+   s[l] = '\0';
+
+   return s;
+}
 
 #if !USE_LIBC_STRDUP
 char               *
@@ -159,6 +178,8 @@
             if (++j >= num)
                goto done;
             p = lst[j];
+            if (!p || !p[0])
+               goto done;
             *s++ = ' ';
             break;
          case ' ':
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/snaps.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -3 -r1.104 -r1.105
--- snaps.c     29 Oct 2005 19:57:06 -0000      1.104
+++ snaps.c     30 Oct 2005 01:05:26 -0000      1.105
@@ -38,6 +38,7 @@
    char               *win_role;
    Window              win;
    EWin               *used;
+   unsigned int        startup_id;
    char                track_changes;
    unsigned int        match_flags;
    unsigned int        use_flags;
@@ -150,6 +151,9 @@
    if (ewin->state.identified)
       return sn->win == _EwinGetClientXwin(ewin);
 
+   if (sn->startup_id && !sn->cmd)
+      return 0;
+
    if (sn->match_flags & SNAP_MATCH_TITLE
        && !SEQ(sn->win_title, ewin->icccm.wm_name))
       return 0;
@@ -187,26 +191,36 @@
    if (!lst)
       return NULL;
 
+   /* If exec'ed by snap try matching command exactly */
    for (i = 0; i < num; i++)
      {
        sn = lst[i];
+       if (sn->used || !sn->startup_id || !sn->cmd)
+          continue;
+       if (strcmp(sn->cmd, ewin->icccm.wm_command))
+          continue;
+       if (!SnapshotEwinMatch(sn, ewin))
+          continue;
+       goto done;
+     }
 
+   for (i = 0; i < num; i++)
+     {
+       sn = lst[i];
        if (sn->used)
           continue;
-
        if (!SnapshotEwinMatch(sn, ewin))
           continue;
-
-       if (!(sn->match_flags & SNAP_MATCH_MULTIPLE))
-         {
-            sn->used = ewin;
-            ewin->snap = sn;
-         }
        goto done;
      }
    sn = NULL;
 
  done:
+   if (sn && !(sn->match_flags & SNAP_MATCH_MULTIPLE))
+     {
+       sn->used = ewin;
+       ewin->snap = sn;
+     }
    Efree(lst);
    return sn;
 }
@@ -1185,7 +1199,10 @@
             sn = lst[i];
             if ((sn->use_flags & SNAP_USE_COMMAND) && (sn->cmd) &&
                 !sn->used && !(sn->match_flags & SNAP_MATCH_MULTIPLE))
-               EspawnCmd(sn->cmd);
+              {
+                 sn->startup_id = ++Mode.apps.startup_id;
+                 EspawnCmd(sn->cmd);
+              }
          }
        Efree(lst);
      }
@@ -1196,9 +1213,9 @@
 LoadSnapInfo(void)
 {
    Snapshot           *sn = NULL;
-   char                buf[4096], s[4096];
+   char                buf[4096], *s;
    FILE               *f;
-   int                 res_w, res_h;
+   int                 res_w, res_h, a, b, c, d;
 
    Esnprintf(buf, sizeof(buf), "%s.snapshots", EGetSavePrefix());
    f = fopen(buf, "r");
@@ -1209,84 +1226,90 @@
    res_h = VRoot.h;
    while (fgets(buf, sizeof(buf), f))
      {
-       /* nuke \n */
-       buf[strlen(buf) - 1] = 0;
-       s[0] = '\0';
-       word(buf, 1, s);
-       if (!s[0])
+       s = strchr(buf, ':');
+       if (!s)
+          continue;
+       *s++ = '\0';
+       s = Estrtrim(s);
+       if (!buf[0] || !s[0])
           continue;
-       if (!strcmp(s, "NEW:"))
+       if (!strcmp(buf, "NEW"))
          {
             res_w = VRoot.w;
             res_h = VRoot.h;
-            sn = SnapshotCreate(atword(buf, 2));
+            sn = SnapshotCreate(s);
          }
        else if (sn)
          {
-            if (!strcmp(s, "WIN:"))
+            if (!strcmp(buf, "WIN"))
               {
-                 sn->win = strtoul(atword(buf, 2), NULL, 0);
+                 sn->win = strtoul(s, NULL, 0);
               }
-            else if (!strcmp(s, "TITLE:"))
+            else if (!strcmp(buf, "TITLE"))
               {
-                 sn->win_title = Estrdup(atword(buf, 2));
+                 sn->win_title = Estrdup(s);
                  sn->match_flags |= SNAP_MATCH_TITLE;
               }
-            else if (!strcmp(s, "NAME:"))
+            else if (!strcmp(buf, "NAME"))
               {
-                 sn->win_name = Estrdup(atword(buf, 2));
+                 sn->win_name = Estrdup(s);
                  sn->match_flags |= SNAP_MATCH_NAME;
               }
-            else if (!strcmp(s, "CLASS:"))
+            else if (!strcmp(buf, "CLASS"))
               {
-                 sn->win_class = Estrdup(atword(buf, 2));
+                 sn->win_class = Estrdup(s);
                  sn->match_flags |= SNAP_MATCH_CLASS;
               }
-            else if (!strcmp(s, "ROLE:"))
+            else if (!strcmp(buf, "ROLE"))
               {
-                 sn->win_role = Estrdup(atword(buf, 2));
+                 sn->win_role = Estrdup(s);
                  sn->match_flags |= SNAP_MATCH_ROLE;
               }
-            else if (!strcmp(s, "AUTO:"))
-               sn->track_changes = 1;
-            else if (!strcmp(s, "BORDER:"))
+            else if (!strcmp(buf, "AUTO"))
+              {
+                 sn->track_changes = 1;
+              }
+            else if (!strcmp(buf, "BORDER"))
               {
                  sn->use_flags |= SNAP_USE_BORDER;
-                 sn->border_name = Estrdup(atword(buf, 2));
+                 sn->border_name = Estrdup(s);
               }
-            else if (!strcmp(s, "CMD:"))
+            else if (!strcmp(buf, "CMD"))
               {
                  sn->use_flags |= SNAP_USE_COMMAND;
-                 sn->cmd = Estrdup(atword(buf, 2));
+                 sn->cmd = Estrdup(s);
               }
-            else if (!strcmp(s, "DESKTOP:"))
+            else if (!strcmp(buf, "DESKTOP"))
               {
                  sn->use_flags |= SNAP_USE_DESK;
-                 word(buf, 2, s);
                  sn->desktop = atoi(s);
               }
-            else if (!strcmp(s, "RES:"))
-              {
-                 word(buf, 2, s);
-                 res_w = atoi(s);
-                 word(buf, 3, s);
-                 res_h = atoi(s);
-              }
-            else if (!strcmp(s, "WH:"))
+            else if (!strcmp(buf, "RES"))
               {
+                 if (sscanf(s, "%u %u", &a, &b) < 2)
+                    continue;
+                 if (a <= 0 || b <= 0)
+                    continue;
+                 res_w = a;
+                 res_h = b;
+              }
+            else if (!strcmp(buf, "WH"))
+              {
+                 if (sscanf(s, "%u %u", &a, &b) < 2)
+                    continue;
+                 if (a <= 0 || b <= 0)
+                    continue;
                  sn->use_flags |= SNAP_USE_SIZE;
-                 word(buf, 2, s);
-                 sn->w = atoi(s);
-                 word(buf, 3, s);
-                 sn->h = atoi(s);
+                 sn->w = a;
+                 sn->h = b;
               }
-            else if (!strcmp(s, "XY:"))
+            else if (!strcmp(buf, "XY"))
               {
+                 if (sscanf(s, "%d %d %u %u", &a, &b, &c, &d) < 4)
+                    continue;
                  sn->use_flags |= SNAP_USE_POS;
-                 word(buf, 2, s);
-                 sn->x = atoi(s);
-                 word(buf, 3, s);
-                 sn->y = atoi(s);
+                 sn->x = a;
+                 sn->y = b;
                  /* we changed reses since we last used this snapshot file */
                  if (res_w != VRoot.w)
                    {
@@ -1320,56 +1343,46 @@
                               sn->y = VRoot.h - 32;
                         }
                    }
-                 word(buf, 4, s);
-                 sn->area_x = atoi(s);
-                 word(buf, 5, s);
-                 sn->area_y = atoi(s);
+                 sn->area_x = c;
+                 sn->area_y = d;
               }
-            else if (!strcmp(s, "LAYER:"))
+            else if (!strcmp(buf, "LAYER"))
               {
                  sn->use_flags |= SNAP_USE_LAYER;
-                 word(buf, 2, s);
                  sn->layer = atoi(s);
               }
-            else if (!strcmp(s, "STICKY:"))
+            else if (!strcmp(buf, "STICKY"))
               {
                  sn->use_flags |= SNAP_USE_STICKY;
-                 word(buf, 2, s);
                  sn->sticky = atoi(s);
               }
-            else if (!strcmp(s, "SHADE:"))
+            else if (!strcmp(buf, "SHADE"))
               {
                  sn->use_flags |= SNAP_USE_SHADED;
-                 word(buf, 2, s);
                  sn->shaded = atoi(s);
               }
-            else if (!strcmp(s, "SKIPFOCUS:"))
+            else if (!strcmp(buf, "SKIPFOCUS"))
               {
                  sn->use_flags |= SNAP_USE_SKIP_LISTS;
-                 word(buf, 2, s);
                  sn->skipfocus = atoi(s);
               }
-            else if (!strcmp(s, "SKIPTASK:"))
+            else if (!strcmp(buf, "SKIPTASK"))
               {
                  sn->use_flags |= SNAP_USE_SKIP_LISTS;
-                 word(buf, 2, s);
                  sn->skiptask = atoi(s);
               }
-            else if (!strcmp(s, "SKIPWINLIST:"))
+            else if (!strcmp(buf, "SKIPWINLIST"))
               {
                  sn->use_flags |= SNAP_USE_SKIP_LISTS;
-                 word(buf, 2, s);
                  sn->skipwinlist = atoi(s);
               }
-            else if (!strcmp(s, "NEVERFOCUS:"))
+            else if (!strcmp(buf, "NEVERFOCUS"))
               {
                  sn->use_flags |= SNAP_USE_FOCUS_NEVER;
-                 word(buf, 2, s);
                  sn->neverfocus = atoi(s);
               }
-            else if (!strcmp(s, "GROUP:"))
+            else if (!strcmp(buf, "GROUP"))
               {
-                 word(buf, 2, s);
                  sn->num_groups++;
                  sn->groups =
                     Erealloc(sn->groups, sizeof(int) * sn->num_groups);
@@ -1377,16 +1390,14 @@
                  sn->groups[sn->num_groups - 1] = atoi(s);
               }
 #if USE_COMPOSITE
-            else if (!strcmp(s, "OPACITY:"))
+            else if (!strcmp(buf, "OPACITY"))
               {
                  sn->use_flags |= SNAP_USE_OPACITY;
-                 word(buf, 2, s);
                  sn->opacity = atoi(s);
               }
-            else if (!strcmp(s, "SHADOW:"))
+            else if (!strcmp(buf, "SHADOW"))
               {
                  sn->use_flags |= SNAP_USE_SHADOW;
-                 word(buf, 2, s);
                  sn->shadow = atoi(s);
               }
 #endif




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to