wmgeneral: Bump to 1998-09-11 version found in wmcpufreq and wmppp.app.

We update the dockapps with the older 1998-05-02 version (wmfsm, wmifs, and
wmkeys), and also remove trailing whitespace from the wmcpufreq copy.
This commit is contained in:
Doug Torrance 2015-05-19 22:30:47 -05:00 committed by Carlos R. Mafra
parent 7d77c17cc1
commit 6c8c14e710
14 changed files with 601 additions and 282 deletions

View file

@ -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

View file

@ -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

View file

@ -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>

View file

@ -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);

View file

@ -12,8 +12,22 @@
---
CHANGES:
---
11/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
* 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, pieterse@xs4all.nl)
* Added parse_rcfile2
02/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
* Added -geometry support (untested)
28/08/1998 (Martijn Pieterse, pieterse@xs4all.nl)
* Added createXBMfromXPM routine
* Saves a lot of work with changing xpm's.
02/05/1998 (Martijn Pieterse, pieterse@xs4all.nl)
* 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, pieterse@xs4all.nl)
* 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);
}
@ -232,6 +282,40 @@ int CheckMouseRegion(int x, int y) {
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 *|
\*******************************************************************************/
@ -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);
}
}

View file

@ -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);

View file

@ -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)
{
while (*list)
{
if ((*list)->head == elem)
list_remove_head(list);
*list = (*list ? (*list)->tail : NULL);
}
}*/
LinkedList *list_remove_elem(LinkedList *list, void *elem)
void
list_remove_elem(LinkedList** list, void* elem)
{
LinkedList *tmp;
while (*list)
{
if ((*list)->head == elem)
list_remove_head(list);
*list = (*list ? (*list)->tail : NULL);
}
}*/
if (list) {
if (list->head == elem) {
tmp = list->tail;
free(list);
return tmp;
}
list->tail = list_remove_elem(list->tail, elem);
return list;
LinkedList *
list_remove_elem(LinkedList* list, void* elem)
{
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;
}
}

View file

@ -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

View file

@ -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;
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;
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;
}
state = mtable[state][ctype].nstate;
ptr++;
if (mtable[state][0].output < 0)
break;
}
if (*ret == 0)
t = NULL;
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
t = strdup(ret);
ctype = PRC_ALPHA;
free(ret);
if (mtable[state][ctype].output) {
*t = *ptr; t++;
*t = 0;
}
state = mtable[state][ctype].nstate;
ptr++;
if (mtable[state][0].output<0) {
break;
}
}
if (ctype == PRC_EOS)
*next = NULL;
else
*next = ptr;
if (*ret==0)
t = NULL;
else
t = strdup(ret);
return t;
free(ret);
if (ctype==PRC_EOS)
*next = NULL;
else
*next = ptr;
return t;
}
extern void
parse_command(char *command, char ***argv, int *argc)
{
LinkedList *list = NULL;
char *token, *line;
int count, i;
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);
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;
pid_t pid;
char **argv;
int argc;
parse_command(command, &argv, &argc);
parse_command(command, &argv, &argc);
if (argv == NULL)
return 0;
if (argv==NULL) {
return 0;
}
pid = fork();
if (pid == 0) {
char **args;
int i;
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;
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;
}

View file

@ -12,8 +12,22 @@
---
CHANGES:
---
11/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
* 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, pieterse@xs4all.nl)
* Added parse_rcfile2
02/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
* Added -geometry support (untested)
28/08/1998 (Martijn Pieterse, pieterse@xs4all.nl)
* Added createXBMfromXPM routine
* Saves a lot of work with changing xpm's.
02/05/1998 (Martijn Pieterse, pieterse@xs4all.nl)
* 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, pieterse@xs4all.nl)
* 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);
}
}

View file

@ -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);

View file

@ -12,8 +12,22 @@
---
CHANGES:
---
11/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
* 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, pieterse@xs4all.nl)
* Added parse_rcfile2
02/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
* Added -geometry support (untested)
28/08/1998 (Martijn Pieterse, pieterse@xs4all.nl)
* Added createXBMfromXPM routine
* Saves a lot of work with changing xpm's.
02/05/1998 (Martijn Pieterse, pieterse@xs4all.nl)
* 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, pieterse@xs4all.nl)
* 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);
}
@ -232,6 +282,40 @@ int CheckMouseRegion(int x, int y) {
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 *|
\*******************************************************************************/
@ -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);
}
}

View file

@ -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);