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

@ -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,7 +38,8 @@ 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;
@ -50,10 +51,12 @@ LinkedList *list_cons(void *head, LinkedList *tail)
/* 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) {
while(list)
{
i += 1;
list = list->tail;
}
@ -63,9 +66,11 @@ int list_length(LinkedList *list)
/* 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)
{
while (index-- != 0) {
if(list->tail)
list = list->tail;
else
@ -76,15 +81,18 @@ void *list_nth(int index, LinkedList *list)
/* 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)
{
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 */
}
else /* only one element in list */
{
free(*list);
(*list) = 0;
}
@ -104,7 +112,8 @@ void list_remove_head(LinkedList **list)
}
}*/
LinkedList *list_remove_elem(LinkedList *list, void *elem)
LinkedList *
list_remove_elem(LinkedList* list, void* elem)
{
LinkedList *tmp;
@ -123,9 +132,11 @@ LinkedList *list_remove_elem(LinkedList *list, void *elem)
/* Return element that has ELEM as car */
LinkedList *list_find(LinkedList *list, void *elem)
LinkedList*
list_find(LinkedList* list, void* elem)
{
while(list)
{
while (list) {
if (list->head == elem)
return list;
list = list->tail;
@ -135,9 +146,11 @@ LinkedList *list_find(LinkedList *list, void *elem)
/* Free list (backwards recursive) */
void list_free(LinkedList *list)
void
list_free(LinkedList* list)
{
if(list)
{
if (list) {
list_free(list->tail);
free(list);
}
@ -145,9 +158,11 @@ void list_free(LinkedList *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)
{
while (list) {
(*function)(list->head);
list = list->tail;
}

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>
@ -53,7 +53,7 @@ static DFA mtable[9][6] = {
{{-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 */
{{-1,-1},{0,0},{0,0},{0,0},{0,0},{0,0}}, /* final state */
};
char*
@ -92,9 +92,10 @@ next_token(char *word, char **next)
}
state = mtable[state][ctype].nstate;
ptr++;
if (mtable[state][0].output < 0)
if (mtable[state][0].output<0) {
break;
}
}
if (*ret==0)
t = NULL;
@ -122,8 +123,9 @@ 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);
count = list_length(list);
@ -145,19 +147,20 @@ execCommand(char *command)
parse_command(command, &argv, &argc);
if (argv == NULL)
if (argv==NULL) {
return 0;
}
pid = fork();
if (pid == 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++)
for (i=0; i<argc; i++) {
args[i] = argv[i];
}
args[argc] = NULL;
execvp(argv[0], args);
exit(10);

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,13 +90,12 @@ 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;
char *p,*q;
char temp[128];
char *tokens = " :\t\n";
FILE *fp;
@ -93,23 +105,56 @@ void parse_rcfile(const char *filename, rckeys *keys)
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);
if (p) {
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++;
}
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) {
while (fgets(temp, 128, fp)) {
key = 0;
while (key >= 0 && keys[key].label) {
if ((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++;
}
}
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,8 +205,7 @@ static Pixel GetColor(char *name)
|* flush_expose *|
\*******************************************************************************/
static int flush_expose(Window w)
{
static int flush_expose(Window w) {
XEvent dummy;
int i=0;
@ -177,8 +220,7 @@ static int flush_expose(Window w)
|* RedrawWindow *|
\*******************************************************************************/
void RedrawWindow(void)
{
void RedrawWindow(void) {
flush_expose(iconwin);
XCopyArea(display, wmgen.pixmap, iconwin, NormalGC,
@ -192,8 +234,7 @@ void RedrawWindow(void)
|* RedrawWindowXY *|
\*******************************************************************************/
void RedrawWindowXY(int x, int y)
{
void RedrawWindowXY(int x, int y) {
flush_expose(iconwin);
XCopyArea(display, wmgen.pixmap, iconwin, NormalGC,
@ -207,8 +248,7 @@ void RedrawWindowXY(int x, int y)
|* 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,8 +263,7 @@ 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;
@ -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 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++;
}
}
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);
@ -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);