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 You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330, the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02111-1307, USA. */ Boston, MA 02110-1301 USA. */
/* As a special exception, if you link this library with files compiled with /* 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 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 You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330, the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02111-1307, USA. */ Boston, MA 02110-1301 USA. */
/* As a special exception, if you link this library with files compiled with /* 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 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 * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * 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> #include <stdlib.h>

View file

@ -12,8 +12,22 @@
--- ---
CHANGES: 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) 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. * debugged the parse_rc file.
30/04/1998 (Martijn Pieterse, pieterse@xs4all.nl) 30/04/1998 (Martijn Pieterse, pieterse@xs4all.nl)
* Ripped similar code from all the wm* programs, * Ripped similar code from all the wm* programs,
@ -63,7 +77,6 @@ typedef struct {
int right; int right;
} MOUSE_REGION; } MOUSE_REGION;
#define MAX_MOUSE_REGION (8)
MOUSE_REGION mouse_region[MAX_MOUSE_REGION]; MOUSE_REGION mouse_region[MAX_MOUSE_REGION];
/***********************/ /***********************/
@ -77,16 +90,52 @@ void AddMouseRegion(int, int, int, int, int);
int CheckMouseRegion(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 *p;
char temp[128]; char temp[128];
char *tokens = " :\t\n"; char *tokens = " :\t\n";
FILE *fp; FILE *fp;
int i,key; int i,key;
char *family = NULL;
fp = fopen(filename, "r"); fp = fopen(filename, "r");
if (fp) { if (fp) {
@ -105,6 +154,7 @@ void parse_rcfile(const char *filename, rckeys *keys) {
} }
fclose(fp); fclose(fp);
} }
free(family);
} }
@ -232,6 +282,40 @@ int CheckMouseRegion(int x, int y) {
return (i-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 *| |* copyXPMArea *|
\*******************************************************************************/ \*******************************************************************************/
@ -276,13 +360,20 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
XGCValues gcv; XGCValues gcv;
unsigned long gcm; unsigned long gcm;
char *geometry = NULL;
int dummy=0; int dummy=0;
int i; int i, wx, wy;
for (i=1; argv[i]; i++) { for (i=1; argv[i]; i++) {
if (!strcmp(argv[i], "-display")) if (!strcmp(argv[i], "-display")) {
display_name = argv[i+1]; display_name = argv[i+1];
i++;
}
if (!strcmp(argv[i], "-geometry")) {
geometry = argv[i+1];
i++;
}
} }
if (!(display = XOpenDisplay(display_name))) { 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); XSetCommand(display, win, argv, argc);
XMapWindow(display, win); 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 */ /* Defines */
/***********/ /***********/
#define MAX_MOUSE_REGION (8) #define MAX_MOUSE_REGION (16)
/************/ /************/
/* Typedefs */ /* Typedefs */
@ -18,6 +18,14 @@ struct _rckeys {
char **var; char **var;
}; };
typedef struct _rckeys2 rckeys2;
struct _rckeys2 {
const char *family;
const char *label;
char **var;
};
typedef struct { typedef struct {
Pixmap pixmap; Pixmap pixmap;
Pixmap mask; Pixmap mask;
@ -41,6 +49,7 @@ void openXwindow(int argc, char *argv[], char **, char *, int, int);
void RedrawWindow(void); void RedrawWindow(void);
void RedrawWindowXY(int x, int y); void RedrawWindowXY(int x, int y);
void createXBMfromXPM(char *, char **, int, int);
void copyXPMArea(int, int, int, int, int, int); void copyXPMArea(int, int, int, int, int, int);
void copyXBMArea(int, int, int, int, int, int); void copyXBMArea(int, int, int, int, int, int);
void setMaskXY(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) */ /* 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;
@ -50,10 +51,12 @@ LinkedList *list_cons(void *head, LinkedList *tail)
/* Return the length of a list, list_length(NULL) returns zero */ /* Return the length of a list, list_length(NULL) returns zero */
int list_length(LinkedList *list) int
list_length(LinkedList* list)
{ {
int i = 0; int i = 0;
while (list) { while(list)
{
i += 1; i += 1;
list = list->tail; 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 /* Return the Nth element of LIST, where N count from zero. If N
larger than the list length, NULL is returned */ 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) if(list->tail)
list = list->tail; list = list->tail;
else else
@ -76,15 +81,18 @@ void *list_nth(int index, LinkedList *list)
/* Remove the element at the head by replacing it by its successor */ /* 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 */ LinkedList* tail = (*list)->tail; /* fetch next */
*(*list) = *tail; /* copy next to list head */ *(*list) = *tail; /* copy next to list head */
free(tail); /* free next */ free(tail); /* free next */
} else { /* only one element in list */ }
else /* only one element in list */
{
free(*list); free(*list);
(*list) = 0; (*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; LinkedList *tmp;
@ -123,9 +132,11 @@ LinkedList *list_remove_elem(LinkedList *list, void *elem)
/* Return element that has ELEM as car */ /* 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) if (list->head == elem)
return list; return list;
list = list->tail; list = list->tail;
@ -135,9 +146,11 @@ LinkedList *list_find(LinkedList *list, void *elem)
/* Free list (backwards recursive) */ /* Free list (backwards recursive) */
void list_free(LinkedList *list) void
list_free(LinkedList* list)
{
if(list)
{ {
if (list) {
list_free(list->tail); list_free(list->tail);
free(list); free(list);
} }
@ -145,9 +158,11 @@ void list_free(LinkedList *list)
/* Map FUNCTION over all elements in 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); (*function)(list->head);
list = list->tail; list = list->tail;
} }

View file

@ -16,7 +16,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * 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> #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 */ {{-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},{7,0},{6,1},{5,0},{3,0}},
{{6,1},{6,1},{6,1},{6,1},{5,0},{6,1}}, {{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* char*
@ -92,9 +92,10 @@ next_token(char *word, char **next)
} }
state = mtable[state][ctype].nstate; state = mtable[state][ctype].nstate;
ptr++; ptr++;
if (mtable[state][0].output < 0) if (mtable[state][0].output<0) {
break; break;
} }
}
if (*ret==0) if (*ret==0)
t = NULL; t = NULL;
@ -122,8 +123,9 @@ parse_command(char *command, char ***argv, int *argc)
line = command; line = command;
do { do {
token = next_token(line, &line); token = next_token(line, &line);
if (token) if (token) {
list = list_cons(token, list); list = list_cons(token, list);
}
} while (token!=NULL && line!=NULL); } while (token!=NULL && line!=NULL);
count = list_length(list); count = list_length(list);
@ -145,19 +147,20 @@ execCommand(char *command)
parse_command(command, &argv, &argc); parse_command(command, &argv, &argc);
if (argv == NULL) if (argv==NULL) {
return 0; return 0;
}
pid = fork(); if ((pid=fork())==0) {
if (pid == 0) {
char **args; char **args;
int i; int i;
args = malloc(sizeof(char*)*(argc+1)); args = malloc(sizeof(char*)*(argc+1));
if (!args) if (!args)
exit(10); exit(10);
for (i = 0; i < argc; i++) for (i=0; i<argc; i++) {
args[i] = argv[i]; args[i] = argv[i];
}
args[argc] = NULL; args[argc] = NULL;
execvp(argv[0], args); execvp(argv[0], args);
exit(10); exit(10);

View file

@ -12,8 +12,22 @@
--- ---
CHANGES: 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) 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. * debugged the parse_rc file.
30/04/1998 (Martijn Pieterse, pieterse@xs4all.nl) 30/04/1998 (Martijn Pieterse, pieterse@xs4all.nl)
* Ripped similar code from all the wm* programs, * Ripped similar code from all the wm* programs,
@ -63,7 +77,6 @@ typedef struct {
int right; int right;
} MOUSE_REGION; } MOUSE_REGION;
#define MAX_MOUSE_REGION (8)
MOUSE_REGION mouse_region[MAX_MOUSE_REGION]; MOUSE_REGION mouse_region[MAX_MOUSE_REGION];
/***********************/ /***********************/
@ -77,13 +90,12 @@ void AddMouseRegion(int, int, int, int, int);
int CheckMouseRegion(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 temp[128];
char *tokens = " :\t\n"; char *tokens = " :\t\n";
FILE *fp; FILE *fp;
@ -93,23 +105,56 @@ void parse_rcfile(const char *filename, rckeys *keys)
if (fp) { if (fp) {
while (fgets(temp, 128, fp)) { while (fgets(temp, 128, fp)) {
key = 0; key = 0;
q = strdup(temp);
q = strtok(q, tokens);
while (key >= 0 && keys[key].label) { while (key >= 0 && keys[key].label) {
if ((!strcmp(q, keys[key].label))) {
p = strstr(temp, keys[key].label); p = strstr(temp, keys[key].label);
if (p) {
p += strlen(keys[key].label); p += strlen(keys[key].label);
p += strspn(p, tokens); p += strspn(p, tokens);
i = strcspn(p, "#\n"); if ((i = strcspn(p, "#\n"))) p[i] = 0;
if (i)
p[i] = 0;
free(*keys[key].var); free(*keys[key].var);
*keys[key].var = strdup(p); *keys[key].var = strdup(p);
key = -1; key = -1;
} else } else key++;
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); fclose(fp);
} }
free(family);
} }
@ -117,8 +162,7 @@ void parse_rcfile(const char *filename, rckeys *keys)
|* GetXPM *| |* GetXPM *|
\*******************************************************************************/ \*******************************************************************************/
static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[]) static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[]) {
{
XWindowAttributes attributes; XWindowAttributes attributes;
int err; int err;
@ -141,8 +185,7 @@ static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[])
|* GetColor *| |* GetColor *|
\*******************************************************************************/ \*******************************************************************************/
static Pixel GetColor(char *name) static Pixel GetColor(char *name) {
{
XColor color; XColor color;
XWindowAttributes attributes; XWindowAttributes attributes;
@ -150,10 +193,11 @@ static Pixel GetColor(char *name)
XGetWindowAttributes(display, Root, &attributes); XGetWindowAttributes(display, Root, &attributes);
color.pixel = 0; 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); 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); fprintf(stderr, "wm.app: can't allocate %s.\n", name);
}
return color.pixel; return color.pixel;
} }
@ -161,8 +205,7 @@ static Pixel GetColor(char *name)
|* flush_expose *| |* flush_expose *|
\*******************************************************************************/ \*******************************************************************************/
static int flush_expose(Window w) static int flush_expose(Window w) {
{
XEvent dummy; XEvent dummy;
int i=0; int i=0;
@ -177,8 +220,7 @@ static int flush_expose(Window w)
|* RedrawWindow *| |* RedrawWindow *|
\*******************************************************************************/ \*******************************************************************************/
void RedrawWindow(void) void RedrawWindow(void) {
{
flush_expose(iconwin); flush_expose(iconwin);
XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, XCopyArea(display, wmgen.pixmap, iconwin, NormalGC,
@ -192,8 +234,7 @@ void RedrawWindow(void)
|* RedrawWindowXY *| |* RedrawWindowXY *|
\*******************************************************************************/ \*******************************************************************************/
void RedrawWindowXY(int x, int y) void RedrawWindowXY(int x, int y) {
{
flush_expose(iconwin); flush_expose(iconwin);
XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, XCopyArea(display, wmgen.pixmap, iconwin, NormalGC,
@ -207,8 +248,7 @@ void RedrawWindowXY(int x, int y)
|* AddMouseRegion *| |* 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) { if (index < MAX_MOUSE_REGION) {
mouse_region[index].enable = 1; mouse_region[index].enable = 1;
@ -223,8 +263,7 @@ void AddMouseRegion(int index, int left, int top, int right, int bottom)
|* CheckMouseRegion *| |* CheckMouseRegion *|
\*******************************************************************************/ \*******************************************************************************/
int CheckMouseRegion(int x, int y) int CheckMouseRegion(int x, int y) {
{
int i; int i;
int found; int found;
@ -239,17 +278,49 @@ int CheckMouseRegion(int x, int y)
y >= mouse_region[i].top) y >= mouse_region[i].top)
found = 1; found = 1;
} }
if (!found) if (!found) return -1;
return -1;
return (i-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 *| |* 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); 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 *| |* 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); 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 *| |* setMaskXY *|
\*******************************************************************************/ \*******************************************************************************/
void setMaskXY(int x, int y) void setMaskXY(int x, int y) {
{
XShapeCombineMask(display, win, ShapeBounding, x, y, pixmask, ShapeSet); XShapeCombineMask(display, win, ShapeBounding, x, y, pixmask, ShapeSet);
XShapeCombineMask(display, iconwin, ShapeBounding, x, y, pixmask, ShapeSet); XShapeCombineMask(display, iconwin, ShapeBounding, x, y, pixmask, ShapeSet);
@ -280,9 +349,7 @@ void setMaskXY(int x, int y)
/*******************************************************************************\ /*******************************************************************************\
|* openXwindow *| |* openXwindow *|
\*******************************************************************************/ \*******************************************************************************/
void openXwindow(int argc, char *argv[], char *pixmap_bytes[], void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bits, int pixmask_width, int pixmask_height) {
char *pixmask_bits, int pixmask_width, int pixmask_height)
{
unsigned int borderwidth = 1; unsigned int borderwidth = 1;
XClassHint classHint; XClassHint classHint;
@ -293,17 +360,23 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[],
XGCValues gcv; XGCValues gcv;
unsigned long gcm; unsigned long gcm;
char *geometry = NULL;
int dummy=0; int dummy=0;
int i; int i, wx, wy;
for (i=1; argv[i]; i++) { for (i=1; argv[i]; i++) {
if (!strcmp(argv[i], "-display")) if (!strcmp(argv[i], "-display")) {
display_name = argv[i+1]; display_name = argv[i+1];
i++;
}
if (!strcmp(argv[i], "-geometry")) {
geometry = argv[i+1];
i++;
}
} }
display = XOpenDisplay(display_name); if (!(display = XOpenDisplay(display_name))) {
if (!display) {
fprintf(stderr, "%s: can't open display %s\n", fprintf(stderr, "%s: can't open display %s\n",
wname, XDisplayName(display_name)); wname, XDisplayName(display_name));
exit(1); exit(1);
@ -342,10 +415,8 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[],
classHint.res_class = wname; classHint.res_class = wname;
XSetClassHint(display, win, &classHint); XSetClassHint(display, win, &classHint);
XSelectInput(display, win, XSelectInput(display, win, ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask); XSelectInput(display, iconwin, ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
XSelectInput(display, iconwin,
ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
if (XStringListToTextProperty(&wname, 1, &name) == 0) { if (XStringListToTextProperty(&wname, 1, &name) == 0) {
fprintf(stderr, "%s: can't allocate window name\n", wname); 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); XSetCommand(display, win, argv, argc);
XMapWindow(display, win); 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 */ /* Defines */
/***********/ /***********/
#define MAX_MOUSE_REGION (8) #define MAX_MOUSE_REGION (16)
/************/ /************/
/* Typedefs */ /* Typedefs */
@ -18,6 +18,14 @@ struct _rckeys {
char **var; char **var;
}; };
typedef struct _rckeys2 rckeys2;
struct _rckeys2 {
const char *family;
const char *label;
char **var;
};
typedef struct { typedef struct {
Pixmap pixmap; Pixmap pixmap;
Pixmap mask; Pixmap mask;
@ -41,6 +49,7 @@ void openXwindow(int argc, char *argv[], char **, char *, int, int);
void RedrawWindow(void); void RedrawWindow(void);
void RedrawWindowXY(int x, int y); void RedrawWindowXY(int x, int y);
void createXBMfromXPM(char *, char **, int, int);
void copyXPMArea(int, int, int, int, int, int); void copyXPMArea(int, int, int, int, int, int);
void copyXBMArea(int, int, int, int, int, int); void copyXBMArea(int, int, int, int, int, int);
void setMaskXY(int, int); void setMaskXY(int, int);

View file

@ -12,8 +12,22 @@
--- ---
CHANGES: 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) 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. * debugged the parse_rc file.
30/04/1998 (Martijn Pieterse, pieterse@xs4all.nl) 30/04/1998 (Martijn Pieterse, pieterse@xs4all.nl)
* Ripped similar code from all the wm* programs, * Ripped similar code from all the wm* programs,
@ -63,7 +77,6 @@ typedef struct {
int right; int right;
} MOUSE_REGION; } MOUSE_REGION;
#define MAX_MOUSE_REGION (8)
MOUSE_REGION mouse_region[MAX_MOUSE_REGION]; MOUSE_REGION mouse_region[MAX_MOUSE_REGION];
/***********************/ /***********************/
@ -77,16 +90,52 @@ void AddMouseRegion(int, int, int, int, int);
int CheckMouseRegion(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 *p;
char temp[128]; char temp[128];
char *tokens = " :\t\n"; char *tokens = " :\t\n";
FILE *fp; FILE *fp;
int i,key; int i,key;
char *family = NULL;
fp = fopen(filename, "r"); fp = fopen(filename, "r");
if (fp) { if (fp) {
@ -105,6 +154,7 @@ void parse_rcfile(const char *filename, rckeys *keys) {
} }
fclose(fp); fclose(fp);
} }
free(family);
} }
@ -232,6 +282,40 @@ int CheckMouseRegion(int x, int y) {
return (i-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 *| |* copyXPMArea *|
\*******************************************************************************/ \*******************************************************************************/
@ -276,13 +360,20 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
XGCValues gcv; XGCValues gcv;
unsigned long gcm; unsigned long gcm;
char *geometry = NULL;
int dummy=0; int dummy=0;
int i; int i, wx, wy;
for (i=1; argv[i]; i++) { for (i=1; argv[i]; i++) {
if (!strcmp(argv[i], "-display")) if (!strcmp(argv[i], "-display")) {
display_name = argv[i+1]; display_name = argv[i+1];
i++;
}
if (!strcmp(argv[i], "-geometry")) {
geometry = argv[i+1];
i++;
}
} }
if (!(display = XOpenDisplay(display_name))) { 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); XSetCommand(display, win, argv, argc);
XMapWindow(display, win); 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 */ /* Defines */
/***********/ /***********/
#define MAX_MOUSE_REGION (8) #define MAX_MOUSE_REGION (16)
/************/ /************/
/* Typedefs */ /* Typedefs */
@ -18,6 +18,14 @@ struct _rckeys {
char **var; char **var;
}; };
typedef struct _rckeys2 rckeys2;
struct _rckeys2 {
const char *family;
const char *label;
char **var;
};
typedef struct { typedef struct {
Pixmap pixmap; Pixmap pixmap;
Pixmap mask; Pixmap mask;
@ -41,6 +49,7 @@ void openXwindow(int argc, char *argv[], char **, char *, int, int);
void RedrawWindow(void); void RedrawWindow(void);
void RedrawWindowXY(int x, int y); void RedrawWindowXY(int x, int y);
void createXBMfromXPM(char *, char **, int, int);
void copyXPMArea(int, int, int, int, int, int); void copyXPMArea(int, int, int, int, int, int);
void copyXBMArea(int, int, int, int, int, int); void copyXBMArea(int, int, int, int, int, int);
void setMaskXY(int, int); void setMaskXY(int, int);