We update the dockapps with the older 1998-05-02 version (wmfsm, wmifs, and
wmkeys), and also remove trailing whitespace from the wmcpufreq copy.
---
 wmcpufreq/wmgeneral/list.c      |  14 +--
 wmcpufreq/wmgeneral/list.h      |   6 +-
 wmcpufreq/wmgeneral/misc.c      |  26 ++---
 wmcpufreq/wmgeneral/wmgeneral.c |  22 ++---
 wmcpufreq/wmgeneral/wmgeneral.h |   2 +-
 wmfsm/wmgeneral/wmgeneral.c     | 108 ++++++++++++++++++++-
 wmfsm/wmgeneral/wmgeneral.h     |  11 ++-
 wmifs/wmgeneral/list.c          | 157 +++++++++++++++++--------------
 wmifs/wmgeneral/list.h          |  20 ++--
 wmifs/wmgeneral/misc.c          | 203 ++++++++++++++++++++--------------------
 wmifs/wmgeneral/wmgeneral.c     | 194 ++++++++++++++++++++++++++------------
 wmifs/wmgeneral/wmgeneral.h     |  11 ++-
 wmkeys/wmgeneral/wmgeneral.c    | 108 ++++++++++++++++++++-
 wmkeys/wmgeneral/wmgeneral.h    |  11 ++-
 14 files changed, 606 insertions(+), 287 deletions(-)

diff --git a/wmcpufreq/wmgeneral/list.c b/wmcpufreq/wmgeneral/list.c
index 0104c94..0b69885 100644
--- a/wmcpufreq/wmgeneral/list.c
+++ b/wmcpufreq/wmgeneral/list.c
@@ -1,11 +1,11 @@
-/* Generic single linked list to keep various information 
+/* Generic single linked list to keep various information
    Copyright (C) 1993, 1994 Free Software Foundation, Inc.
 
 
 Author: Kresten Krab Thorup
 
 Many modifications by Alfredo K. Kojima
- 
+
 
 This file is part of GNU CC.
 
@@ -21,8 +21,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301 USA.  */
 
 /* As a special exception, if you link this library with files compiled with
    GCC to produce an executable, this does not cause the resulting executable
@@ -63,7 +63,7 @@ list_length(LinkedList* list)
   return i;
 }
 
-/* Return the Nth element of LIST, where N count from zero.  If N 
+/* Return the Nth element of LIST, where N count from zero.  If N
    larger than the list length, NULL is returned  */
 
 void*
@@ -84,7 +84,7 @@ list_nth(int index, LinkedList* list)
 void
 list_remove_head(LinkedList** list)
 {
-  if (!*list) return;  
+  if (!*list) return;
   if ((*list)->tail)
     {
       LinkedList* tail = (*list)->tail; /* fetch next */
@@ -116,7 +116,7 @@ LinkedList *
 list_remove_elem(LinkedList* list, void* elem)
 {
     LinkedList *tmp;
-    
+
     if (list) {
        if (list->head == elem) {
            tmp = list->tail;
diff --git a/wmcpufreq/wmgeneral/list.h b/wmcpufreq/wmgeneral/list.h
index 43a42c3..3d6bad5 100644
--- a/wmcpufreq/wmgeneral/list.h
+++ b/wmcpufreq/wmgeneral/list.h
@@ -1,4 +1,4 @@
-/* Generic single linked list to keep various information 
+/* Generic single linked list to keep various information
    Copyright (C) 1993, 1994 Free Software Foundation, Inc.
 
 Author: Kresten Krab Thorup
@@ -17,8 +17,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301 USA.  */
 
 /* As a special exception, if you link this library with files compiled with
    GCC to produce an executable, this does not cause the resulting executable
diff --git a/wmcpufreq/wmgeneral/misc.c b/wmcpufreq/wmgeneral/misc.c
index 3ad6ab3..2ba6d06 100644
--- a/wmcpufreq/wmgeneral/misc.c
+++ b/wmcpufreq/wmgeneral/misc.c
@@ -1,9 +1,9 @@
 /* dock.c- built-in Dock module for WindowMaker
- * 
+ *
  *  WindowMaker window manager
- * 
+ *
  *  Copyright (c) 1997 Alfredo K. Kojima
- * 
+ *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
@@ -16,7 +16,7 @@
  *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
USA.
  */
 
 #include <stdlib.h>
@@ -29,7 +29,7 @@
  *----------------------------------------------------------------------
  * parse_command--
  *     Divides a command line into a argv/argc pair.
- *---------------------------------------------------------------------- 
+ *----------------------------------------------------------------------
  */
 #define PRC_ALPHA      0
 #define PRC_BLANK      1
@@ -69,11 +69,11 @@ next_token(char *word, char **next)
            exit(EXIT_FAILURE);
     }
     ptr = word;
-    
+
     state = 0;
     *t = 0;
     while (1) {
-       if (*ptr==0) 
+       if (*ptr==0)
            ctype = PRC_EOS;
        else if (*ptr=='\\')
            ctype = PRC_ESCAPE;
@@ -103,12 +103,12 @@ next_token(char *word, char **next)
        t = strdup(ret);
 
     free(ret);
-    
+
     if (ctype==PRC_EOS)
        *next = NULL;
     else
        *next = ptr;
-    
+
     return t;
 }
 
@@ -123,7 +123,7 @@ parse_command(char *command, char ***argv, int *argc)
     line = command;
     do {
        token = next_token(line, &line);
-       if (token) {        
+       if (token) {
            list = list_cons(token, list);
        }
     } while (token!=NULL && line!=NULL);
@@ -146,15 +146,15 @@ execCommand(char *command)
     int argc;
 
     parse_command(command, &argv, &argc);
-    
+
     if (argv==NULL) {
         return 0;
     }
-    
+
     if ((pid=fork())==0) {
         char **args;
         int i;
-        
+
         args = malloc(sizeof(char*)*(argc+1));
         if (!args)
           exit(10);
diff --git a/wmcpufreq/wmgeneral/wmgeneral.c b/wmcpufreq/wmgeneral/wmgeneral.c
index c9c7446..44de5b9 100755
--- a/wmcpufreq/wmgeneral/wmgeneral.c
+++ b/wmcpufreq/wmgeneral/wmgeneral.c
@@ -14,7 +14,7 @@
        ---
        11/09/1998 (Martijn Pieterse, [email protected])
                * Removed a bug from parse_rcfile. You could
-                 not use "start" in a command if a label was 
+                 not use "start" in a command if a label was
                  also start.
                * Changed the needed geometry string.
                  We don't use window size, and don't support
@@ -174,7 +174,7 @@ static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[]) {
 
        err = XpmCreatePixmapFromData(display, Root, pixmap_bytes, 
&(wmgen->pixmap),
                                        &(wmgen->mask), &(wmgen->attributes));
-       
+
        if (err != XpmSuccess) {
                fprintf(stderr, "Not enough free colorcells.\n");
                exit(1);
@@ -221,9 +221,9 @@ static int flush_expose(Window w) {
 
\*******************************************************************************/
 
 void RedrawWindow(void) {
-       
+
        flush_expose(iconwin);
-       XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, 
+       XCopyArea(display, wmgen.pixmap, iconwin, NormalGC,
                                0,0, wmgen.attributes.width, 
wmgen.attributes.height, 0,0);
        flush_expose(win);
        XCopyArea(display, wmgen.pixmap, win, NormalGC,
@@ -235,9 +235,9 @@ void RedrawWindow(void) {
 
\*******************************************************************************/
 
 void RedrawWindowXY(int x, int y) {
-       
+
        flush_expose(iconwin);
-       XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, 
+       XCopyArea(display, wmgen.pixmap, iconwin, NormalGC,
                                x,y, wmgen.attributes.width, 
wmgen.attributes.height, 0,0);
        flush_expose(win);
        XCopyArea(display, wmgen.pixmap, win, NormalGC,
@@ -292,7 +292,7 @@ void createXBMfromXPM(char *xbm, char **xpm, int sx, int 
sy) {
        char    zero;
        unsigned char   bwrite;
        int             bcount;
-       
+
 
        sscanf(*xpm, "%d %d %d", &width, &height, &numcol);
 
@@ -377,7 +377,7 @@ void openXwindow(int argc, char *argv[], char 
*pixmap_bytes[], char *pixmask_bit
        }
 
        if (!(display = XOpenDisplay(display_name))) {
-               fprintf(stderr, "%s: can't open display %s\n", 
+               fprintf(stderr, "%s: can't open display %s\n",
                                                wname, 
XDisplayName(display_name));
                exit(1);
        }
@@ -402,10 +402,10 @@ void openXwindow(int argc, char *argv[], char 
*pixmap_bytes[], char *pixmask_bit
 
        mysizehints.width = 64;
        mysizehints.height = 64;
-               
+
        win = XCreateSimpleWindow(display, Root, mysizehints.x, mysizehints.y,
                                mysizehints.width, mysizehints.height, 
borderwidth, fore_pix, back_pix);
-       
+
        iconwin = XCreateSimpleWindow(display, win, mysizehints.x, 
mysizehints.y,
                                mysizehints.width, mysizehints.height, 
borderwidth, fore_pix, back_pix);
 
@@ -426,7 +426,7 @@ void openXwindow(int argc, char *argv[], char 
*pixmap_bytes[], char *pixmask_bit
        XSetWMName(display, win, &name);
 
        /* Create GC for drawing */
-       
+
        gcm = GCForeground | GCBackground | GCGraphicsExposures;
        gcv.foreground = fore_pix;
        gcv.background = back_pix;
diff --git a/wmcpufreq/wmgeneral/wmgeneral.h b/wmcpufreq/wmgeneral/wmgeneral.h
index e822075..e9d6ca6 100755
--- a/wmcpufreq/wmgeneral/wmgeneral.h
+++ b/wmcpufreq/wmgeneral/wmgeneral.h
@@ -45,7 +45,7 @@ Display               *display;
 void AddMouseRegion(int index, int left, int top, int right, int bottom);
 int CheckMouseRegion(int x, int y);
 
-void openXwindow(int argc, char *argv[],char **,char *, int, int);
+void openXwindow(int argc, char *argv[], char **, char *, int, int);
 void RedrawWindow(void);
 void RedrawWindowXY(int x, int y);
 
diff --git a/wmfsm/wmgeneral/wmgeneral.c b/wmfsm/wmgeneral/wmgeneral.c
index 645321c..44de5b9 100644
--- a/wmfsm/wmgeneral/wmgeneral.c
+++ b/wmfsm/wmgeneral/wmgeneral.c
@@ -12,8 +12,22 @@
        ---
        CHANGES:
        ---
+       11/09/1998 (Martijn Pieterse, [email protected])
+               * Removed a bug from parse_rcfile. You could
+                 not use "start" in a command if a label was
+                 also start.
+               * Changed the needed geometry string.
+                 We don't use window size, and don't support
+                 negative positions.
+       03/09/1998 (Martijn Pieterse, [email protected])
+               * Added parse_rcfile2
+       02/09/1998 (Martijn Pieterse, [email protected])
+               * Added -geometry support (untested)
+       28/08/1998 (Martijn Pieterse, [email protected])
+               * Added createXBMfromXPM routine
+               * Saves a lot of work with changing xpm's.
        02/05/1998 (Martijn Pieterse, [email protected])
-               * changed the read_rc_file to parse_rcfile, as suggester by 
Marcelo E. Magallon
+               * changed the read_rc_file to parse_rcfile, as suggested by 
Marcelo E. Magallon
                * debugged the parse_rc file.
        30/04/1998 (Martijn Pieterse, [email protected])
                * Ripped similar code from all the wm* programs,
@@ -63,7 +77,6 @@ typedef struct {
        int             right;
 } MOUSE_REGION;
 
-#define MAX_MOUSE_REGION (8)
 MOUSE_REGION   mouse_region[MAX_MOUSE_REGION];
 
   /***********************/
@@ -77,16 +90,52 @@ void AddMouseRegion(int, int, int, int, int);
 int CheckMouseRegion(int, int);
 
 
/*******************************************************************************\
-|* read_rc_file                                                                
                                                                   *|
+|* parse_rcfile                                                                
                                                                   *|
 
\*******************************************************************************/
 
 void parse_rcfile(const char *filename, rckeys *keys) {
 
+       char    *p,*q;
+       char    temp[128];
+       char    *tokens = " :\t\n";
+       FILE    *fp;
+       int             i,key;
+
+       fp = fopen(filename, "r");
+       if (fp) {
+               while (fgets(temp, 128, fp)) {
+                       key = 0;
+                       q = strdup(temp);
+                       q = strtok(q, tokens);
+                       while (key >= 0 && keys[key].label) {
+                               if ((!strcmp(q, keys[key].label))) {
+                                       p = strstr(temp, keys[key].label);
+                                       p += strlen(keys[key].label);
+                                       p += strspn(p, tokens);
+                                       if ((i = strcspn(p, "#\n"))) p[i] = 0;
+                                       free(*keys[key].var);
+                                       *keys[key].var = strdup(p);
+                                       key = -1;
+                               } else key++;
+                       }
+                       free(q);
+               }
+               fclose(fp);
+       }
+}
+
+/*******************************************************************************\
+|* parse_rcfile2                                                               
                                                           *|
+\*******************************************************************************/
+
+void parse_rcfile2(const char *filename, rckeys2 *keys) {
+
        char    *p;
        char    temp[128];
        char    *tokens = " :\t\n";
        FILE    *fp;
        int             i,key;
+       char    *family = NULL;
 
        fp = fopen(filename, "r");
        if (fp) {
@@ -105,6 +154,7 @@ void parse_rcfile(const char *filename, rckeys *keys) {
                }
                fclose(fp);
        }
+       free(family);
 }
 
 
@@ -233,6 +283,40 @@ int CheckMouseRegion(int x, int y) {
 }
 
 
/*******************************************************************************\
+|* createXBMfromXPM                                                            
                                                           *|
+\*******************************************************************************/
+void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) {
+
+       int             i,j;
+       int             width, height, numcol;
+       char    zero;
+       unsigned char   bwrite;
+       int             bcount;
+
+
+       sscanf(*xpm, "%d %d %d", &width, &height, &numcol);
+
+       zero = xpm[1][0];
+       for (i=numcol+1; i < numcol+sy+1; i++) {
+               bcount = 0;
+               bwrite = 0;
+               for (j=0; j<sx; j++) {
+                       bwrite >>= 1;
+                       if (xpm[i][j] != zero) {
+                               bwrite += 128;
+                       }
+                       bcount++;
+                       if (bcount == 8) {
+                               *xbm = bwrite;
+                               xbm++;
+                               bcount = 0;
+                               bwrite = 0;
+                       }
+               }
+       }
+}
+
+/*******************************************************************************\
 |* copyXPMArea                                                                 
                                                           *|
 
\*******************************************************************************/
 
@@ -276,13 +360,20 @@ void openXwindow(int argc, char *argv[], char 
*pixmap_bytes[], char *pixmask_bit
        XGCValues               gcv;
        unsigned long   gcm;
 
+       char                    *geometry = NULL;
 
        int                             dummy=0;
-       int                             i;
+       int                             i, wx, wy;
 
        for (i=1; argv[i]; i++) {
-               if (!strcmp(argv[i], "-display"))
+               if (!strcmp(argv[i], "-display")) {
                        display_name = argv[i+1];
+                       i++;
+               }
+               if (!strcmp(argv[i], "-geometry")) {
+                       geometry = argv[i+1];
+                       i++;
+               }
        }
 
        if (!(display = XOpenDisplay(display_name))) {
@@ -363,4 +454,11 @@ void openXwindow(int argc, char *argv[], char 
*pixmap_bytes[], char *pixmask_bit
        XSetCommand(display, win, argv, argc);
        XMapWindow(display, win);
 
+       if (geometry) {
+               if (sscanf(geometry, "+%d+%d", &wx, &wy) != 2) {
+                       fprintf(stderr, "Bad geometry string.\n");
+                       exit(1);
+               }
+               XMoveWindow(display, win, wx, wy);
+       }
 }
diff --git a/wmfsm/wmgeneral/wmgeneral.h b/wmfsm/wmgeneral/wmgeneral.h
index 55b37dd..e9d6ca6 100644
--- a/wmfsm/wmgeneral/wmgeneral.h
+++ b/wmfsm/wmgeneral/wmgeneral.h
@@ -5,7 +5,7 @@
  /* Defines */
 /***********/
 
-#define MAX_MOUSE_REGION (8)
+#define MAX_MOUSE_REGION (16)
 
   /************/
  /* Typedefs */
@@ -18,6 +18,14 @@ struct _rckeys {
        char            **var;
 };
 
+typedef struct _rckeys2 rckeys2;
+
+struct _rckeys2 {
+       const char      *family;
+       const char      *label;
+       char            **var;
+};
+
 typedef struct {
        Pixmap                  pixmap;
        Pixmap                  mask;
@@ -41,6 +49,7 @@ void openXwindow(int argc, char *argv[], char **, char *, 
int, int);
 void RedrawWindow(void);
 void RedrawWindowXY(int x, int y);
 
+void createXBMfromXPM(char *, char **, int, int);
 void copyXPMArea(int, int, int, int, int, int);
 void copyXBMArea(int, int, int, int, int, int);
 void setMaskXY(int, int);
diff --git a/wmifs/wmgeneral/list.c b/wmifs/wmgeneral/list.c
index d116b1f..0b69885 100644
--- a/wmifs/wmgeneral/list.c
+++ b/wmifs/wmgeneral/list.c
@@ -38,117 +38,132 @@ Boston, MA 02110-1301 USA.  */
 
 /* Return a cons cell produced from (head . tail) */
 
-LinkedList *list_cons(void *head, LinkedList *tail)
+LinkedList*
+list_cons(void* head, LinkedList* tail)
 {
-       LinkedList *cell;
+  LinkedList* cell;
 
-       cell = (LinkedList *)malloc(sizeof(LinkedList));
-       cell->head = head;
-       cell->tail = tail;
-       return cell;
+  cell = (LinkedList*)malloc(sizeof(LinkedList));
+  cell->head = head;
+  cell->tail = tail;
+  return cell;
 }
 
 /* Return the length of a list, list_length(NULL) returns zero */
 
-int list_length(LinkedList *list)
+int
+list_length(LinkedList* list)
 {
-       int i = 0;
-       while (list) {
-               i += 1;
-               list = list->tail;
-       }
-       return i;
+  int i = 0;
+  while(list)
+    {
+      i += 1;
+      list = list->tail;
+    }
+  return i;
 }
 
 /* Return the Nth element of LIST, where N count from zero.  If N
    larger than the list length, NULL is returned  */
 
-void *list_nth(int index, LinkedList *list)
+void*
+list_nth(int index, LinkedList* list)
 {
-       while (index-- != 0) {
-               if (list->tail)
-                       list = list->tail;
-               else
-                       return 0;
-       }
-       return list->head;
+  while(index-- != 0)
+    {
+      if(list->tail)
+       list = list->tail;
+      else
+       return 0;
+    }
+  return list->head;
 }
 
 /* Remove the element at the head by replacing it by its successor */
 
-void list_remove_head(LinkedList **list)
+void
+list_remove_head(LinkedList** list)
 {
-       if (!*list)
-               return;
-       if ((*list)->tail) {
-               LinkedList *tail = (*list)->tail; /* fetch next */
-               *(*list) = *tail;               /* copy next to list head */
-               free(tail);                     /* free next */
-       } else {                                /* only one element in list */
-               free(*list);
-               (*list) = 0;
-       }
+  if (!*list) return;
+  if ((*list)->tail)
+    {
+      LinkedList* tail = (*list)->tail; /* fetch next */
+      *(*list) = *tail;                /* copy next to list head */
+      free(tail);                      /* free next */
+    }
+  else                         /* only one element in list */
+    {
+      free(*list);
+      (*list) = 0;
+    }
 }
 
 
 /* Remove the element with `car' set to ELEMENT */
 /*
-  void
-  list_remove_elem(LinkedList** list, void* elem)
-  {
+void
+list_remove_elem(LinkedList** list, void* elem)
+{
   while (*list)
-  {
-  if ((*list)->head == elem)
-  list_remove_head(list);
-  *list = (*list ? (*list)->tail : NULL);
-  }
-  }*/
-
-LinkedList *list_remove_elem(LinkedList *list, void *elem)
+    {
+      if ((*list)->head == elem)
+        list_remove_head(list);
+      *list = (*list ? (*list)->tail : NULL);
+    }
+}*/
+
+LinkedList *
+list_remove_elem(LinkedList* list, void* elem)
 {
-       LinkedList *tmp;
-
-       if (list) {
-               if (list->head == elem) {
-                       tmp = list->tail;
-                       free(list);
-                       return tmp;
-               }
-               list->tail = list_remove_elem(list->tail, elem);
-               return list;
+    LinkedList *tmp;
+
+    if (list) {
+       if (list->head == elem) {
+           tmp = list->tail;
+           free(list);
+           return tmp;
        }
-       return NULL;
+       list->tail = list_remove_elem(list->tail, elem);
+       return list;
+    }
+    return NULL;
 }
 
 
 /* Return element that has ELEM as car */
 
-LinkedList *list_find(LinkedList *list, void *elem)
+LinkedList*
+list_find(LinkedList* list, void* elem)
 {
-       while (list) {
-               if (list->head == elem)
-                       return list;
-               list = list->tail;
-       }
-       return NULL;
+  while(list)
+    {
+    if (list->head == elem)
+      return list;
+    list = list->tail;
+    }
+  return NULL;
 }
 
 /* Free list (backwards recursive) */
 
-void list_free(LinkedList *list)
+void
+list_free(LinkedList* list)
 {
-       if (list) {
-               list_free(list->tail);
-               free(list);
-       }
+  if(list)
+    {
+      list_free(list->tail);
+      free(list);
+    }
 }
 
 /* Map FUNCTION over all elements in LIST */
 
-void list_mapcar(LinkedList *list, void(*function)(void *))
+void
+list_mapcar(LinkedList* list, void(*function)(void*))
 {
-       while (list) {
-               (*function)(list->head);
-               list = list->tail;
-       }
+  while(list)
+    {
+      (*function)(list->head);
+      list = list->tail;
+    }
 }
diff --git a/wmifs/wmgeneral/list.h b/wmifs/wmgeneral/list.h
index 4fae83a..3d6bad5 100644
--- a/wmifs/wmgeneral/list.h
+++ b/wmifs/wmgeneral/list.h
@@ -30,24 +30,24 @@ Boston, MA 02110-1301 USA.  */
 #define __LIST_H_
 
 typedef struct LinkedList {
-       void *head;
-       struct LinkedList *tail;
+  void *head;
+  struct LinkedList *tail;
 } LinkedList;
 
-LinkedList *list_cons(void *head, LinkedList *tail);
+LinkedList* list_cons(void* head, LinkedList* tail);
 
-int list_length(LinkedList *list);
+int list_length(LinkedList* list);
 
-void *list_nth(int index, LinkedList *list);
+void* list_nth(int index, LinkedList* list);
 
-void list_remove_head(LinkedList **list);
+void list_remove_head(LinkedList** list);
 
-LinkedList *list_remove_elem(LinkedList *list, void *elem);
+LinkedList *list_remove_elem(LinkedList* list, void* elem);
 
-void list_mapcar(LinkedList *list, void(*function)(void *));
+void list_mapcar(LinkedList* list, void(*function)(void*));
 
-LinkedList *list_find(LinkedList *list, void *elem);
+LinkedList*list_find(LinkedList* list, void* elem);
 
-void list_free(LinkedList *list);
+void list_free(LinkedList* list);
 
 #endif
diff --git a/wmifs/wmgeneral/misc.c b/wmifs/wmgeneral/misc.c
index 813db76..2ba6d06 100644
--- a/wmifs/wmgeneral/misc.c
+++ b/wmifs/wmgeneral/misc.c
@@ -16,7 +16,7 @@
  *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
USA.
  */
 
 #include <stdlib.h>
@@ -28,7 +28,7 @@
 /*
  *----------------------------------------------------------------------
  * parse_command--
- *      Divides a command line into a argv/argc pair.
+ *     Divides a command line into a argv/argc pair.
  *----------------------------------------------------------------------
  */
 #define PRC_ALPHA      0
@@ -39,129 +39,132 @@
 #define PRC_SQUOTE     5
 
 typedef struct {
-       short nstate;
-       short output;
+    short nstate;
+    short output;
 } DFA;
 
 
 static DFA mtable[9][6] = {
-       {{3, 1}, {0, 0}, {4, 0}, {1, 0}, {8, 0}, {6, 0} },
-       {{1, 1}, {1, 1}, {2, 0}, {3, 0}, {5, 0}, {1, 1} },
-       {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {5, 0}, {1, 1} },
-       {{3, 1}, {5, 0}, {4, 0}, {1, 0}, {5, 0}, {6, 0} },
-       {{3, 1}, {3, 1}, {3, 1}, {3, 1}, {5, 0}, {3, 1} },
-       {{-1, -1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* final state */
-       {{6, 1}, {6, 1}, {7, 0}, {6, 1}, {5, 0}, {3, 0} },
-       {{6, 1}, {6, 1}, {6, 1}, {6, 1}, {5, 0}, {6, 1} },
-       {{-1, -1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} }  /* final state */
+    {{3,1},{0,0},{4,0},{1,0},{8,0},{6,0}},
+    {{1,1},{1,1},{2,0},{3,0},{5,0},{1,1}},
+    {{1,1},{1,1},{1,1},{1,1},{5,0},{1,1}},
+    {{3,1},{5,0},{4,0},{1,0},{5,0},{6,0}},
+    {{3,1},{3,1},{3,1},{3,1},{5,0},{3,1}},
+    {{-1,-1},{0,0},{0,0},{0,0},{0,0},{0,0}}, /* final state */
+    {{6,1},{6,1},{7,0},{6,1},{5,0},{3,0}},
+    {{6,1},{6,1},{6,1},{6,1},{5,0},{6,1}},
+    {{-1,-1},{0,0},{0,0},{0,0},{0,0},{0,0}}, /* final state */
 };
 
 char*
 next_token(char *word, char **next)
 {
-       char *ptr;
-       char *ret, *t;
-       int state, ctype;
-
-       t = ret = malloc(strlen(word)+1);
-       if (ret == NULL) {
-               fprintf(stderr, "Insufficient memory.\n");
-               exit(EXIT_FAILURE);
+    char *ptr;
+    char *ret, *t;
+    int state, ctype;
+
+    t = ret = malloc(strlen(word)+1);
+    if (ret == NULL) {
+           fprintf(stderr, "Insufficient memory.\n");
+           exit(EXIT_FAILURE);
+    }
+    ptr = word;
+
+    state = 0;
+    *t = 0;
+    while (1) {
+       if (*ptr==0)
+           ctype = PRC_EOS;
+       else if (*ptr=='\\')
+           ctype = PRC_ESCAPE;
+       else if (*ptr=='"')
+           ctype = PRC_DQUOTE;
+       else if (*ptr=='\'')
+           ctype = PRC_SQUOTE;
+       else if (*ptr==' ' || *ptr=='\t')
+           ctype = PRC_BLANK;
+       else
+           ctype = PRC_ALPHA;
+
+       if (mtable[state][ctype].output) {
+           *t = *ptr; t++;
+           *t = 0;
        }
-       ptr = word;
-
-       state = 0;
-       *t = 0;
-       while (1) {
-               if (*ptr == 0)
-                       ctype = PRC_EOS;
-               else if (*ptr == '\\')
-                       ctype = PRC_ESCAPE;
-               else if (*ptr == '"')
-                       ctype = PRC_DQUOTE;
-               else if (*ptr == '\'')
-                       ctype = PRC_SQUOTE;
-               else if (*ptr == ' ' || *ptr == '\t')
-                       ctype = PRC_BLANK;
-               else
-                       ctype = PRC_ALPHA;
-
-               if (mtable[state][ctype].output) {
-                       *t = *ptr; t++;
-                       *t = 0;
-               }
-               state = mtable[state][ctype].nstate;
-               ptr++;
-               if (mtable[state][0].output < 0)
-                       break;
+       state = mtable[state][ctype].nstate;
+       ptr++;
+       if (mtable[state][0].output<0) {
+           break;
        }
+    }
 
-       if (*ret == 0)
-               t = NULL;
-       else
-               t = strdup(ret);
+    if (*ret==0)
+       t = NULL;
+    else
+       t = strdup(ret);
 
-       free(ret);
+    free(ret);
 
-       if (ctype == PRC_EOS)
-               *next = NULL;
-       else
-               *next = ptr;
+    if (ctype==PRC_EOS)
+       *next = NULL;
+    else
+       *next = ptr;
 
-       return t;
+    return t;
 }
 
 
 extern void
 parse_command(char *command, char ***argv, int *argc)
 {
-       LinkedList *list = NULL;
-       char *token, *line;
-       int count, i;
-
-       line = command;
-       do {
-               token = next_token(line, &line);
-               if (token)
-                       list = list_cons(token, list);
-       } while (token != NULL && line != NULL);
-
-       count = list_length(list);
-       *argv = malloc(sizeof(char *)*count);
-       i = count;
-       while (list != NULL) {
-               (*argv)[--i] = list->head;
-               list_remove_head(&list);
+    LinkedList *list = NULL;
+    char *token, *line;
+    int count, i;
+
+    line = command;
+    do {
+       token = next_token(line, &line);
+       if (token) {
+           list = list_cons(token, list);
        }
-       *argc = count;
+    } while (token!=NULL && line!=NULL);
+
+    count = list_length(list);
+    *argv = malloc(sizeof(char*)*count);
+    i = count;
+    while (list!=NULL) {
+       (*argv)[--i] = list->head;
+       list_remove_head(&list);
+    }
+    *argc = count;
 }
 
 extern pid_t
 execCommand(char *command)
 {
-       pid_t pid;
-       char **argv;
-       int argc;
-
-       parse_command(command, &argv, &argc);
-
-       if (argv == NULL)
-               return 0;
-
-       pid = fork();
-       if (pid == 0) {
-               char **args;
-               int i;
-
-               args = malloc(sizeof(char *)*(argc+1));
-               if (!args)
-                       exit(10);
-               for (i = 0; i < argc; i++)
-                       args[i] = argv[i];
-               args[argc] = NULL;
-               execvp(argv[0], args);
-               exit(10);
-       }
-       free(argv);
-       return pid;
+    pid_t pid;
+    char **argv;
+    int argc;
+
+    parse_command(command, &argv, &argc);
+
+    if (argv==NULL) {
+        return 0;
+    }
+
+    if ((pid=fork())==0) {
+        char **args;
+        int i;
+
+        args = malloc(sizeof(char*)*(argc+1));
+        if (!args)
+          exit(10);
+        for (i=0; i<argc; i++) {
+            args[i] = argv[i];
+        }
+        args[argc] = NULL;
+        execvp(argv[0], args);
+        exit(10);
+    }
+    free(argv);
+    return pid;
 }
diff --git a/wmifs/wmgeneral/wmgeneral.c b/wmifs/wmgeneral/wmgeneral.c
index bbd7e60..44de5b9 100644
--- a/wmifs/wmgeneral/wmgeneral.c
+++ b/wmifs/wmgeneral/wmgeneral.c
@@ -12,8 +12,22 @@
        ---
        CHANGES:
        ---
+       11/09/1998 (Martijn Pieterse, [email protected])
+               * Removed a bug from parse_rcfile. You could
+                 not use "start" in a command if a label was
+                 also start.
+               * Changed the needed geometry string.
+                 We don't use window size, and don't support
+                 negative positions.
+       03/09/1998 (Martijn Pieterse, [email protected])
+               * Added parse_rcfile2
+       02/09/1998 (Martijn Pieterse, [email protected])
+               * Added -geometry support (untested)
+       28/08/1998 (Martijn Pieterse, [email protected])
+               * Added createXBMfromXPM routine
+               * Saves a lot of work with changing xpm's.
        02/05/1998 (Martijn Pieterse, [email protected])
-               * changed the read_rc_file to parse_rcfile, as suggester by 
Marcelo E. Magallon
+               * changed the read_rc_file to parse_rcfile, as suggested by 
Marcelo E. Magallon
                * debugged the parse_rc file.
        30/04/1998 (Martijn Pieterse, [email protected])
                * Ripped similar code from all the wm* programs,
@@ -63,7 +77,6 @@ typedef struct {
        int             right;
 } MOUSE_REGION;
 
-#define MAX_MOUSE_REGION (8)
 MOUSE_REGION   mouse_region[MAX_MOUSE_REGION];
 
   /***********************/
@@ -77,39 +90,71 @@ void AddMouseRegion(int, int, int, int, int);
 int CheckMouseRegion(int, int);
 
 
/*******************************************************************************\
-|* read_rc_file                                                                
                                                                   *|
+|* parse_rcfile                                                                
                                                                   *|
 
\*******************************************************************************/
 
-void parse_rcfile(const char *filename, rckeys *keys)
-{
+void parse_rcfile(const char *filename, rckeys *keys) {
+
+       char    *p,*q;
+       char    temp[128];
+       char    *tokens = " :\t\n";
+       FILE    *fp;
+       int             i,key;
+
+       fp = fopen(filename, "r");
+       if (fp) {
+               while (fgets(temp, 128, fp)) {
+                       key = 0;
+                       q = strdup(temp);
+                       q = strtok(q, tokens);
+                       while (key >= 0 && keys[key].label) {
+                               if ((!strcmp(q, keys[key].label))) {
+                                       p = strstr(temp, keys[key].label);
+                                       p += strlen(keys[key].label);
+                                       p += strspn(p, tokens);
+                                       if ((i = strcspn(p, "#\n"))) p[i] = 0;
+                                       free(*keys[key].var);
+                                       *keys[key].var = strdup(p);
+                                       key = -1;
+                               } else key++;
+                       }
+                       free(q);
+               }
+               fclose(fp);
+       }
+}
+
+/*******************************************************************************\
+|* parse_rcfile2                                                               
                                                           *|
+\*******************************************************************************/
+
+void parse_rcfile2(const char *filename, rckeys2 *keys) {
 
        char    *p;
        char    temp[128];
        char    *tokens = " :\t\n";
        FILE    *fp;
-       int     i, key;
+       int             i,key;
+       char    *family = NULL;
 
        fp = fopen(filename, "r");
        if (fp) {
                while (fgets(temp, 128, fp)) {
                        key = 0;
                        while (key >= 0 && keys[key].label) {
-                               p = strstr(temp, keys[key].label);
-                               if (p) {
+                               if ((p = strstr(temp, keys[key].label))) {
                                        p += strlen(keys[key].label);
                                        p += strspn(p, tokens);
-                                       i = strcspn(p, "#\n");
-                                       if (i)
-                                               p[i] = 0;
+                                       if ((i = strcspn(p, "#\n"))) p[i] = 0;
                                        free(*keys[key].var);
                                        *keys[key].var = strdup(p);
                                        key = -1;
-                               } else
-                                       key++;
+                               } else key++;
                        }
                }
                fclose(fp);
        }
+       free(family);
 }
 
 
@@ -117,8 +162,7 @@ void parse_rcfile(const char *filename, rckeys *keys)
 |* GetXPM                                                                      
                                                                   *|
 
\*******************************************************************************/
 
-static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[])
-{
+static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[]) {
 
        XWindowAttributes       attributes;
        int                                     err;
@@ -141,8 +185,7 @@ static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[])
 |* GetColor                                                                    
                                                                   *|
 
\*******************************************************************************/
 
-static Pixel GetColor(char *name)
-{
+static Pixel GetColor(char *name) {
 
        XColor                          color;
        XWindowAttributes       attributes;
@@ -150,10 +193,11 @@ static Pixel GetColor(char *name)
        XGetWindowAttributes(display, Root, &attributes);
 
        color.pixel = 0;
-       if (!XParseColor(display, attributes.colormap, name, &color))
+       if (!XParseColor(display, attributes.colormap, name, &color)) {
                fprintf(stderr, "wm.app: can't parse %s.\n", name);
-       else if (!XAllocColor(display, attributes.colormap, &color))
+       } else if (!XAllocColor(display, attributes.colormap, &color)) {
                fprintf(stderr, "wm.app: can't allocate %s.\n", name);
+       }
        return color.pixel;
 }
 
@@ -161,11 +205,10 @@ static Pixel GetColor(char *name)
 |* flush_expose                                                                
                                                                   *|
 
\*******************************************************************************/
 
-static int flush_expose(Window w)
-{
+static int flush_expose(Window w) {
 
-       XEvent dummy;
-       int i = 0;
+       XEvent          dummy;
+       int                     i=0;
 
        while (XCheckTypedWindowEvent(display, w, Expose, &dummy))
                i++;
@@ -177,38 +220,35 @@ static int flush_expose(Window w)
 |* RedrawWindow                                                                
                                                                   *|
 
\*******************************************************************************/
 
-void RedrawWindow(void)
-{
+void RedrawWindow(void) {
 
        flush_expose(iconwin);
        XCopyArea(display, wmgen.pixmap, iconwin, NormalGC,
-                               0, 0, wmgen.attributes.width, 
wmgen.attributes.height, 0, 0);
+                               0,0, wmgen.attributes.width, 
wmgen.attributes.height, 0,0);
        flush_expose(win);
        XCopyArea(display, wmgen.pixmap, win, NormalGC,
-                               0, 0, wmgen.attributes.width, 
wmgen.attributes.height, 0, 0);
+                               0,0, wmgen.attributes.width, 
wmgen.attributes.height, 0,0);
 }
 
 
/*******************************************************************************\
 |* RedrawWindowXY                                                              
                                                           *|
 
\*******************************************************************************/
 
-void RedrawWindowXY(int x, int y)
-{
+void RedrawWindowXY(int x, int y) {
 
        flush_expose(iconwin);
        XCopyArea(display, wmgen.pixmap, iconwin, NormalGC,
-                               x, y, wmgen.attributes.width, 
wmgen.attributes.height, 0, 0);
+                               x,y, wmgen.attributes.width, 
wmgen.attributes.height, 0,0);
        flush_expose(win);
        XCopyArea(display, wmgen.pixmap, win, NormalGC,
-                               x, y, wmgen.attributes.width, 
wmgen.attributes.height, 0, 0);
+                               x,y, wmgen.attributes.width, 
wmgen.attributes.height, 0,0);
 }
 
 
/*******************************************************************************\
 |* AddMouseRegion                                                              
                                                           *|
 
\*******************************************************************************/
 
-void AddMouseRegion(int index, int left, int top, int right, int bottom)
-{
+void AddMouseRegion(int index, int left, int top, int right, int bottom) {
 
        if (index < MAX_MOUSE_REGION) {
                mouse_region[index].enable = 1;
@@ -223,15 +263,14 @@ void AddMouseRegion(int index, int left, int top, int 
right, int bottom)
 |* CheckMouseRegion                                                            
                                                           *|
 
\*******************************************************************************/
 
-int CheckMouseRegion(int x, int y)
-{
+int CheckMouseRegion(int x, int y) {
 
        int             i;
        int             found;
 
        found = 0;
 
-       for (i = 0; i < MAX_MOUSE_REGION && !found; i++) {
+       for (i=0; i<MAX_MOUSE_REGION && !found; i++) {
                if (mouse_region[i].enable &&
                        x <= mouse_region[i].right &&
                        x >= mouse_region[i].left &&
@@ -239,17 +278,49 @@ int CheckMouseRegion(int x, int y)
                        y >= mouse_region[i].top)
                        found = 1;
        }
-       if (!found)
-               return -1;
+       if (!found) return -1;
        return (i-1);
 }
 
 
/*******************************************************************************\
+|* createXBMfromXPM                                                            
                                                           *|
+\*******************************************************************************/
+void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) {
+
+       int             i,j;
+       int             width, height, numcol;
+       char    zero;
+       unsigned char   bwrite;
+       int             bcount;
+
+
+       sscanf(*xpm, "%d %d %d", &width, &height, &numcol);
+
+       zero = xpm[1][0];
+       for (i=numcol+1; i < numcol+sy+1; i++) {
+               bcount = 0;
+               bwrite = 0;
+               for (j=0; j<sx; j++) {
+                       bwrite >>= 1;
+                       if (xpm[i][j] != zero) {
+                               bwrite += 128;
+                       }
+                       bcount++;
+                       if (bcount == 8) {
+                               *xbm = bwrite;
+                               xbm++;
+                               bcount = 0;
+                               bwrite = 0;
+                       }
+               }
+       }
+}
+
+/*******************************************************************************\
 |* copyXPMArea                                                                 
                                                           *|
 
\*******************************************************************************/
 
-void copyXPMArea(int x, int y, int sx, int sy, int dx, int dy)
-{
+void copyXPMArea(int x, int y, int sx, int sy, int dx, int dy) {
 
        XCopyArea(display, wmgen.pixmap, wmgen.pixmap, NormalGC, x, y, sx, sy, 
dx, dy);
 
@@ -259,8 +330,7 @@ void copyXPMArea(int x, int y, int sx, int sy, int dx, int 
dy)
 |* copyXBMArea                                                                 
                                                           *|
 
\*******************************************************************************/
 
-void copyXBMArea(int x, int y, int sx, int sy, int dx, int dy)
-{
+void copyXBMArea(int x, int y, int sx, int sy, int dx, int dy) {
 
        XCopyArea(display, wmgen.mask, wmgen.pixmap, NormalGC, x, y, sx, sy, 
dx, dy);
 }
@@ -270,8 +340,7 @@ void copyXBMArea(int x, int y, int sx, int sy, int dx, int 
dy)
 |* setMaskXY                                                                   
                                                           *|
 
\*******************************************************************************/
 
-void setMaskXY(int x, int y)
-{
+void setMaskXY(int x, int y) {
 
         XShapeCombineMask(display, win, ShapeBounding, x, y, pixmask, 
ShapeSet);
         XShapeCombineMask(display, iconwin, ShapeBounding, x, y, pixmask, 
ShapeSet);
@@ -280,9 +349,7 @@ void setMaskXY(int x, int y)
 
/*******************************************************************************\
 |* openXwindow                                                                 
                                                           *|
 
\*******************************************************************************/
-void openXwindow(int argc, char *argv[], char *pixmap_bytes[],
-                char *pixmask_bits, int pixmask_width, int pixmask_height)
-{
+void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char 
*pixmask_bits, int pixmask_width, int pixmask_height) {
 
        unsigned int    borderwidth = 1;
        XClassHint              classHint;
@@ -293,17 +360,23 @@ void openXwindow(int argc, char *argv[], char 
*pixmap_bytes[],
        XGCValues               gcv;
        unsigned long   gcm;
 
+       char                    *geometry = NULL;
 
-       int                             dummy = 0;
-       int                             i;
+       int                             dummy=0;
+       int                             i, wx, wy;
 
-       for (i = 1; argv[i]; i++) {
-               if (!strcmp(argv[i], "-display"))
+       for (i=1; argv[i]; i++) {
+               if (!strcmp(argv[i], "-display")) {
                        display_name = argv[i+1];
+                       i++;
+               }
+               if (!strcmp(argv[i], "-geometry")) {
+                       geometry = argv[i+1];
+                       i++;
+               }
        }
 
-       display = XOpenDisplay(display_name);
-       if (!display) {
+       if (!(display = XOpenDisplay(display_name))) {
                fprintf(stderr, "%s: can't open display %s\n",
                                                wname, 
XDisplayName(display_name));
                exit(1);
@@ -325,7 +398,7 @@ void openXwindow(int argc, char *argv[], char 
*pixmap_bytes[],
        fore_pix = GetColor("black");
 
        XWMGeometry(display, screen, Geometry, NULL, borderwidth, &mysizehints,
-                               &mysizehints.x, &mysizehints.y, 
&mysizehints.width, &mysizehints.height, &dummy);
+                               &mysizehints.x, 
&mysizehints.y,&mysizehints.width,&mysizehints.height, &dummy);
 
        mysizehints.width = 64;
        mysizehints.height = 64;
@@ -342,10 +415,8 @@ void openXwindow(int argc, char *argv[], char 
*pixmap_bytes[],
        classHint.res_class = wname;
        XSetClassHint(display, win, &classHint);
 
-       XSelectInput(display, win,
-                    ButtonPressMask | ExposureMask | ButtonReleaseMask | 
PointerMotionMask | StructureNotifyMask);
-       XSelectInput(display, iconwin,
-                    ButtonPressMask | ExposureMask | ButtonReleaseMask | 
PointerMotionMask | StructureNotifyMask);
+       XSelectInput(display, win, ButtonPressMask | ExposureMask | 
ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
+       XSelectInput(display, iconwin, ButtonPressMask | ExposureMask | 
ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
 
        if (XStringListToTextProperty(&wname, 1, &name) == 0) {
                fprintf(stderr, "%s: can't allocate window name\n", wname);
@@ -383,4 +454,11 @@ void openXwindow(int argc, char *argv[], char 
*pixmap_bytes[],
        XSetCommand(display, win, argv, argc);
        XMapWindow(display, win);
 
+       if (geometry) {
+               if (sscanf(geometry, "+%d+%d", &wx, &wy) != 2) {
+                       fprintf(stderr, "Bad geometry string.\n");
+                       exit(1);
+               }
+               XMoveWindow(display, win, wx, wy);
+       }
 }
diff --git a/wmifs/wmgeneral/wmgeneral.h b/wmifs/wmgeneral/wmgeneral.h
index 55b37dd..e9d6ca6 100644
--- a/wmifs/wmgeneral/wmgeneral.h
+++ b/wmifs/wmgeneral/wmgeneral.h
@@ -5,7 +5,7 @@
  /* Defines */
 /***********/
 
-#define MAX_MOUSE_REGION (8)
+#define MAX_MOUSE_REGION (16)
 
   /************/
  /* Typedefs */
@@ -18,6 +18,14 @@ struct _rckeys {
        char            **var;
 };
 
+typedef struct _rckeys2 rckeys2;
+
+struct _rckeys2 {
+       const char      *family;
+       const char      *label;
+       char            **var;
+};
+
 typedef struct {
        Pixmap                  pixmap;
        Pixmap                  mask;
@@ -41,6 +49,7 @@ void openXwindow(int argc, char *argv[], char **, char *, 
int, int);
 void RedrawWindow(void);
 void RedrawWindowXY(int x, int y);
 
+void createXBMfromXPM(char *, char **, int, int);
 void copyXPMArea(int, int, int, int, int, int);
 void copyXBMArea(int, int, int, int, int, int);
 void setMaskXY(int, int);
diff --git a/wmkeys/wmgeneral/wmgeneral.c b/wmkeys/wmgeneral/wmgeneral.c
index 645321c..44de5b9 100644
--- a/wmkeys/wmgeneral/wmgeneral.c
+++ b/wmkeys/wmgeneral/wmgeneral.c
@@ -12,8 +12,22 @@
        ---
        CHANGES:
        ---
+       11/09/1998 (Martijn Pieterse, [email protected])
+               * Removed a bug from parse_rcfile. You could
+                 not use "start" in a command if a label was
+                 also start.
+               * Changed the needed geometry string.
+                 We don't use window size, and don't support
+                 negative positions.
+       03/09/1998 (Martijn Pieterse, [email protected])
+               * Added parse_rcfile2
+       02/09/1998 (Martijn Pieterse, [email protected])
+               * Added -geometry support (untested)
+       28/08/1998 (Martijn Pieterse, [email protected])
+               * Added createXBMfromXPM routine
+               * Saves a lot of work with changing xpm's.
        02/05/1998 (Martijn Pieterse, [email protected])
-               * changed the read_rc_file to parse_rcfile, as suggester by 
Marcelo E. Magallon
+               * changed the read_rc_file to parse_rcfile, as suggested by 
Marcelo E. Magallon
                * debugged the parse_rc file.
        30/04/1998 (Martijn Pieterse, [email protected])
                * Ripped similar code from all the wm* programs,
@@ -63,7 +77,6 @@ typedef struct {
        int             right;
 } MOUSE_REGION;
 
-#define MAX_MOUSE_REGION (8)
 MOUSE_REGION   mouse_region[MAX_MOUSE_REGION];
 
   /***********************/
@@ -77,16 +90,52 @@ void AddMouseRegion(int, int, int, int, int);
 int CheckMouseRegion(int, int);
 
 
/*******************************************************************************\
-|* read_rc_file                                                                
                                                                   *|
+|* parse_rcfile                                                                
                                                                   *|
 
\*******************************************************************************/
 
 void parse_rcfile(const char *filename, rckeys *keys) {
 
+       char    *p,*q;
+       char    temp[128];
+       char    *tokens = " :\t\n";
+       FILE    *fp;
+       int             i,key;
+
+       fp = fopen(filename, "r");
+       if (fp) {
+               while (fgets(temp, 128, fp)) {
+                       key = 0;
+                       q = strdup(temp);
+                       q = strtok(q, tokens);
+                       while (key >= 0 && keys[key].label) {
+                               if ((!strcmp(q, keys[key].label))) {
+                                       p = strstr(temp, keys[key].label);
+                                       p += strlen(keys[key].label);
+                                       p += strspn(p, tokens);
+                                       if ((i = strcspn(p, "#\n"))) p[i] = 0;
+                                       free(*keys[key].var);
+                                       *keys[key].var = strdup(p);
+                                       key = -1;
+                               } else key++;
+                       }
+                       free(q);
+               }
+               fclose(fp);
+       }
+}
+
+/*******************************************************************************\
+|* parse_rcfile2                                                               
                                                           *|
+\*******************************************************************************/
+
+void parse_rcfile2(const char *filename, rckeys2 *keys) {
+
        char    *p;
        char    temp[128];
        char    *tokens = " :\t\n";
        FILE    *fp;
        int             i,key;
+       char    *family = NULL;
 
        fp = fopen(filename, "r");
        if (fp) {
@@ -105,6 +154,7 @@ void parse_rcfile(const char *filename, rckeys *keys) {
                }
                fclose(fp);
        }
+       free(family);
 }
 
 
@@ -233,6 +283,40 @@ int CheckMouseRegion(int x, int y) {
 }
 
 
/*******************************************************************************\
+|* createXBMfromXPM                                                            
                                                           *|
+\*******************************************************************************/
+void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) {
+
+       int             i,j;
+       int             width, height, numcol;
+       char    zero;
+       unsigned char   bwrite;
+       int             bcount;
+
+
+       sscanf(*xpm, "%d %d %d", &width, &height, &numcol);
+
+       zero = xpm[1][0];
+       for (i=numcol+1; i < numcol+sy+1; i++) {
+               bcount = 0;
+               bwrite = 0;
+               for (j=0; j<sx; j++) {
+                       bwrite >>= 1;
+                       if (xpm[i][j] != zero) {
+                               bwrite += 128;
+                       }
+                       bcount++;
+                       if (bcount == 8) {
+                               *xbm = bwrite;
+                               xbm++;
+                               bcount = 0;
+                               bwrite = 0;
+                       }
+               }
+       }
+}
+
+/*******************************************************************************\
 |* copyXPMArea                                                                 
                                                           *|
 
\*******************************************************************************/
 
@@ -276,13 +360,20 @@ void openXwindow(int argc, char *argv[], char 
*pixmap_bytes[], char *pixmask_bit
        XGCValues               gcv;
        unsigned long   gcm;
 
+       char                    *geometry = NULL;
 
        int                             dummy=0;
-       int                             i;
+       int                             i, wx, wy;
 
        for (i=1; argv[i]; i++) {
-               if (!strcmp(argv[i], "-display"))
+               if (!strcmp(argv[i], "-display")) {
                        display_name = argv[i+1];
+                       i++;
+               }
+               if (!strcmp(argv[i], "-geometry")) {
+                       geometry = argv[i+1];
+                       i++;
+               }
        }
 
        if (!(display = XOpenDisplay(display_name))) {
@@ -363,4 +454,11 @@ void openXwindow(int argc, char *argv[], char 
*pixmap_bytes[], char *pixmask_bit
        XSetCommand(display, win, argv, argc);
        XMapWindow(display, win);
 
+       if (geometry) {
+               if (sscanf(geometry, "+%d+%d", &wx, &wy) != 2) {
+                       fprintf(stderr, "Bad geometry string.\n");
+                       exit(1);
+               }
+               XMoveWindow(display, win, wx, wy);
+       }
 }
diff --git a/wmkeys/wmgeneral/wmgeneral.h b/wmkeys/wmgeneral/wmgeneral.h
index 55b37dd..e9d6ca6 100644
--- a/wmkeys/wmgeneral/wmgeneral.h
+++ b/wmkeys/wmgeneral/wmgeneral.h
@@ -5,7 +5,7 @@
  /* Defines */
 /***********/
 
-#define MAX_MOUSE_REGION (8)
+#define MAX_MOUSE_REGION (16)
 
   /************/
  /* Typedefs */
@@ -18,6 +18,14 @@ struct _rckeys {
        char            **var;
 };
 
+typedef struct _rckeys2 rckeys2;
+
+struct _rckeys2 {
+       const char      *family;
+       const char      *label;
+       char            **var;
+};
+
 typedef struct {
        Pixmap                  pixmap;
        Pixmap                  mask;
@@ -41,6 +49,7 @@ void openXwindow(int argc, char *argv[], char **, char *, 
int, int);
 void RedrawWindow(void);
 void RedrawWindowXY(int x, int y);
 
+void createXBMfromXPM(char *, char **, int, int);
 void copyXPMArea(int, int, int, int, int, int);
 void copyXBMArea(int, int, int, int, int, int);
 void setMaskXY(int, int);
-- 
2.1.4


-- 
To unsubscribe, send mail to [email protected].

Reply via email to