indent -linux -l144 -i4 -ts4 **/*.[ch]
This commit is contained in:
parent
cb310ed1a1
commit
324a28e4ba
9 changed files with 719 additions and 784 deletions
|
@ -9,7 +9,6 @@
|
||||||
* that your changes will be lost if you ever run `configure' again.
|
* that your changes will be lost if you ever run `configure' again.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* *************************************************************************
|
/* *************************************************************************
|
||||||
CONFIGURING SERVER EXTENSIONS
|
CONFIGURING SERVER EXTENSIONS
|
||||||
************************************************************************* */
|
************************************************************************* */
|
||||||
|
@ -110,8 +109,6 @@
|
||||||
*/
|
*/
|
||||||
/* #undef HAVE_PROC_INTERRUPTS */
|
/* #undef HAVE_PROC_INTERRUPTS */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* *************************************************************************
|
/* *************************************************************************
|
||||||
CONFIGURING GRAPHICS TOOLKITS
|
CONFIGURING GRAPHICS TOOLKITS
|
||||||
************************************************************************* */
|
************************************************************************* */
|
||||||
|
@ -184,8 +181,6 @@
|
||||||
*/
|
*/
|
||||||
#define ZIPPY_PROGRAM "/packages/libexec/emacs/20.2/sparc-sun-solaris2.6/yow"
|
#define ZIPPY_PROGRAM "/packages/libexec/emacs/20.2/sparc-sun-solaris2.6/yow"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* *************************************************************************
|
/* *************************************************************************
|
||||||
CONFIGURING PASSWORD AUTHENTICATION
|
CONFIGURING PASSWORD AUTHENTICATION
|
||||||
************************************************************************* */
|
************************************************************************* */
|
||||||
|
@ -258,13 +253,11 @@
|
||||||
*/
|
*/
|
||||||
/* #undef HAVE_VT_LOCKSWITCH */
|
/* #undef HAVE_VT_LOCKSWITCH */
|
||||||
|
|
||||||
|
|
||||||
/* Define this if you the openlog(), syslog(), and closelog() functions.
|
/* Define this if you the openlog(), syslog(), and closelog() functions.
|
||||||
This is used for logging failed login attempts.
|
This is used for logging failed login attempts.
|
||||||
*/
|
*/
|
||||||
#define HAVE_SYSLOG 1
|
#define HAVE_SYSLOG 1
|
||||||
|
|
||||||
|
|
||||||
/* *************************************************************************
|
/* *************************************************************************
|
||||||
OTHER C ENVIRONMENT JUNK
|
OTHER C ENVIRONMENT JUNK
|
||||||
************************************************************************* */
|
************************************************************************* */
|
||||||
|
|
|
@ -37,11 +37,8 @@ extern Pixel back_pix, fore_pix;
|
||||||
extern int PixmapSize;
|
extern int PixmapSize;
|
||||||
int CHAR_HEIGHT;
|
int CHAR_HEIGHT;
|
||||||
|
|
||||||
|
static void load_images(m_state * state)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
static void load_images (m_state *state) {
|
|
||||||
|
|
||||||
if (state->xgwa.depth > 1) {
|
if (state->xgwa.depth > 1) {
|
||||||
|
|
||||||
|
@ -58,23 +55,20 @@ static void load_images (m_state *state) {
|
||||||
xpmattrs.valuemask |= XpmColormap;
|
xpmattrs.valuemask |= XpmColormap;
|
||||||
xpmattrs.colormap = state->xgwa.colormap;
|
xpmattrs.colormap = state->xgwa.colormap;
|
||||||
|
|
||||||
if (PixmapSize == 1){
|
if (PixmapSize == 1) {
|
||||||
|
|
||||||
CHAR_HEIGHT = 4;
|
CHAR_HEIGHT = 4;
|
||||||
result = XpmCreatePixmapFromData (state->dpy, state->window, small,
|
result = XpmCreatePixmapFromData(state->dpy, state->window, small, &state->images, 0 /* mask */ ,
|
||||||
&state->images, 0 /* mask */,
|
|
||||||
&xpmattrs);
|
&xpmattrs);
|
||||||
} else if (PixmapSize == 2){
|
} else if (PixmapSize == 2) {
|
||||||
|
|
||||||
CHAR_HEIGHT = 6;
|
CHAR_HEIGHT = 6;
|
||||||
result = XpmCreatePixmapFromData (state->dpy, state->window, medium,
|
result = XpmCreatePixmapFromData(state->dpy, state->window, medium, &state->images, 0 /* mask */ ,
|
||||||
&state->images, 0 /* mask */,
|
|
||||||
&xpmattrs);
|
&xpmattrs);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
CHAR_HEIGHT = 8;
|
CHAR_HEIGHT = 8;
|
||||||
result = XpmCreatePixmapFromData (state->dpy, state->window, large,
|
result = XpmCreatePixmapFromData(state->dpy, state->window, large, &state->images, 0 /* mask */ ,
|
||||||
&state->images, 0 /* mask */,
|
|
||||||
&xpmattrs);
|
&xpmattrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,25 +85,23 @@ static void load_images (m_state *state) {
|
||||||
state->image_height = matrix_height;
|
state->image_height = matrix_height;
|
||||||
state->nglyphs = state->image_height / CHAR_HEIGHT;
|
state->nglyphs = state->image_height / CHAR_HEIGHT;
|
||||||
|
|
||||||
state->images = XCreatePixmapFromBitmapData (state->dpy, state->window,
|
state->images = XCreatePixmapFromBitmapData(state->dpy, state->window,
|
||||||
(char *) matrix_bits,
|
(char *)matrix_bits,
|
||||||
state->image_width, state->image_height,
|
state->image_width, state->image_height, back_pix, fore_pix, state->xgwa.depth);
|
||||||
back_pix, fore_pix, state->xgwa.depth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_state *init_matrix(Display * dpy, Window window)
|
||||||
|
{
|
||||||
|
|
||||||
m_state *init_matrix( Display *dpy, Window window ) {
|
m_state *state = (m_state *) calloc(sizeof(*state), 1);
|
||||||
|
|
||||||
m_state *state = (m_state *) calloc (sizeof(*state), 1);
|
|
||||||
|
|
||||||
|
|
||||||
state->dpy = dpy;
|
state->dpy = dpy;
|
||||||
state->window = window;
|
state->window = window;
|
||||||
|
|
||||||
XGetWindowAttributes (dpy, window, &state->xgwa);
|
XGetWindowAttributes(dpy, window, &state->xgwa);
|
||||||
load_images (state);
|
load_images(state);
|
||||||
|
|
||||||
state->draw_gc = NormalGC;
|
state->draw_gc = NormalGC;
|
||||||
state->erase_gc = EraseGC;
|
state->erase_gc = EraseGC;
|
||||||
|
@ -122,26 +114,26 @@ m_state *init_matrix( Display *dpy, Window window ) {
|
||||||
state->grid_width++;
|
state->grid_width++;
|
||||||
state->grid_height++;
|
state->grid_height++;
|
||||||
|
|
||||||
state->cells = (m_cell *)calloc (sizeof(m_cell), state->grid_width * state->grid_height);
|
state->cells = (m_cell *) calloc(sizeof(m_cell), state->grid_width * state->grid_height);
|
||||||
state->feeders = (m_feeder *)calloc (sizeof(m_feeder), state->grid_width);
|
state->feeders = (m_feeder *) calloc(sizeof(m_feeder), state->grid_width);
|
||||||
|
|
||||||
state->density = 40;
|
state->density = 40;
|
||||||
|
|
||||||
state->insert_top_p = False;
|
state->insert_top_p = False;
|
||||||
state->insert_bottom_p = True;
|
state->insert_bottom_p = True;
|
||||||
|
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void insert_glyph(m_state * state, int glyph, int x, int y)
|
||||||
static void insert_glyph (m_state *state, int glyph, int x, int y) {
|
{
|
||||||
|
|
||||||
Bool bottom_feeder_p = (y >= 0);
|
Bool bottom_feeder_p = (y >= 0);
|
||||||
m_cell *from, *to;
|
m_cell *from, *to;
|
||||||
|
|
||||||
if (y >= state->grid_height) return;
|
if (y >= state->grid_height)
|
||||||
|
return;
|
||||||
|
|
||||||
if (bottom_feeder_p) {
|
if (bottom_feeder_p) {
|
||||||
|
|
||||||
|
@ -149,9 +141,9 @@ static void insert_glyph (m_state *state, int glyph, int x, int y) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
for (y = state->grid_height-1; y > 0; y--) {
|
for (y = state->grid_height - 1; y > 0; y--) {
|
||||||
|
|
||||||
from = &state->cells[state->grid_width * (y-1) + x];
|
from = &state->cells[state->grid_width * (y - 1) + x];
|
||||||
to = &state->cells[state->grid_width * y + x];
|
to = &state->cells[state->grid_width * y + x];
|
||||||
*to = *from;
|
*to = *from;
|
||||||
to->changed = True;
|
to->changed = True;
|
||||||
|
@ -165,17 +157,18 @@ static void insert_glyph (m_state *state, int glyph, int x, int y) {
|
||||||
to->changed = True;
|
to->changed = True;
|
||||||
|
|
||||||
if (!to->glyph) ;
|
if (!to->glyph) ;
|
||||||
else if (bottom_feeder_p) to->glow = 1 + (random() % 2);
|
else if (bottom_feeder_p)
|
||||||
else to->glow = 0;
|
to->glow = 1 + (random() % 2);
|
||||||
|
else
|
||||||
|
to->glow = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void feed_matrix(m_state * state)
|
||||||
static void feed_matrix (m_state *state) {
|
{
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update according to current feeders.
|
* Update according to current feeders.
|
||||||
*/
|
*/
|
||||||
|
@ -190,14 +183,16 @@ static void feed_matrix (m_state *state) {
|
||||||
} else if (f->remaining > 0) { /* how many items are in the pipe */
|
} else if (f->remaining > 0) { /* how many items are in the pipe */
|
||||||
|
|
||||||
int g = (random() % state->nglyphs) + 1;
|
int g = (random() % state->nglyphs) + 1;
|
||||||
insert_glyph (state, g, x, f->y);
|
insert_glyph(state, g, x, f->y);
|
||||||
f->remaining--;
|
f->remaining--;
|
||||||
if (f->y >= 0) f->y++; /* bottom_feeder_p */
|
if (f->y >= 0)
|
||||||
|
f->y++; /* bottom_feeder_p */
|
||||||
|
|
||||||
} else { /* if pipe is empty, insert spaces */
|
} else { /* if pipe is empty, insert spaces */
|
||||||
|
|
||||||
insert_glyph (state, 0, x, f->y);
|
insert_glyph(state, 0, x, f->y);
|
||||||
if (f->y >= 0) f->y++; /* bottom_feeder_p */
|
if (f->y >= 0)
|
||||||
|
f->y++; /* bottom_feeder_p */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,29 +206,43 @@ static void feed_matrix (m_state *state) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int densitizer (m_state *state) {
|
static int densitizer(m_state * state)
|
||||||
|
{
|
||||||
|
|
||||||
/* Horrid kludge that converts percentages (density of screen coverage)
|
/* Horrid kludge that converts percentages (density of screen coverage)
|
||||||
to the parameter that actually controls this. I got this mapping
|
to the parameter that actually controls this. I got this mapping
|
||||||
empirically, on a 1024x768 screen. Sue me. */
|
empirically, on a 1024x768 screen. Sue me. */
|
||||||
if (state->density < 10) return 85;
|
if (state->density < 10)
|
||||||
else if (state->density < 15) return 60;
|
return 85;
|
||||||
else if (state->density < 20) return 45;
|
else if (state->density < 15)
|
||||||
else if (state->density < 25) return 25;
|
return 60;
|
||||||
else if (state->density < 30) return 20;
|
else if (state->density < 20)
|
||||||
else if (state->density < 35) return 15;
|
return 45;
|
||||||
else if (state->density < 45) return 10;
|
else if (state->density < 25)
|
||||||
else if (state->density < 50) return 8;
|
return 25;
|
||||||
else if (state->density < 55) return 7;
|
else if (state->density < 30)
|
||||||
else if (state->density < 65) return 5;
|
return 20;
|
||||||
else if (state->density < 80) return 3;
|
else if (state->density < 35)
|
||||||
else if (state->density < 90) return 2;
|
return 15;
|
||||||
else return 1;
|
else if (state->density < 45)
|
||||||
|
return 10;
|
||||||
|
else if (state->density < 50)
|
||||||
|
return 8;
|
||||||
|
else if (state->density < 55)
|
||||||
|
return 7;
|
||||||
|
else if (state->density < 65)
|
||||||
|
return 5;
|
||||||
|
else if (state->density < 80)
|
||||||
|
return 3;
|
||||||
|
else if (state->density < 90)
|
||||||
|
return 2;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void hack_matrix(m_state * state)
|
||||||
static void hack_matrix (m_state *state) {
|
{
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
|
@ -285,35 +294,36 @@ static void hack_matrix (m_state *state) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void draw_matrix(m_state * state, int d)
|
||||||
void draw_matrix (m_state *state, int d) {
|
{
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
state->density = d;
|
state->density = d;
|
||||||
feed_matrix( state );
|
feed_matrix(state);
|
||||||
hack_matrix( state );
|
hack_matrix(state);
|
||||||
|
|
||||||
for (y = 0; y < state->grid_height; y++) {
|
for (y = 0; y < state->grid_height; y++) {
|
||||||
for (x = 0; x < state->grid_width; x++) {
|
for (x = 0; x < state->grid_width; x++) {
|
||||||
|
|
||||||
m_cell *cell = &state->cells[state->grid_width * y + x];
|
m_cell *cell = &state->cells[state->grid_width * y + x];
|
||||||
|
|
||||||
if ( cell->glyph ) count++;
|
if (cell->glyph)
|
||||||
|
count++;
|
||||||
|
|
||||||
if ( !cell->changed ) continue;
|
if (!cell->changed)
|
||||||
|
continue;
|
||||||
|
|
||||||
if ( cell->glyph == 0 ) {
|
if (cell->glyph == 0) {
|
||||||
|
|
||||||
XFillRectangle( state->dpy, state->window, state->erase_gc,
|
XFillRectangle(state->dpy, state->window, state->erase_gc,
|
||||||
x * state->char_width, y * state->char_height,
|
x * state->char_width, y * state->char_height, state->char_width, state->char_height);
|
||||||
state->char_width, state->char_height );
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
XCopyArea( state->dpy, state->images, state->window, state->draw_gc,
|
XCopyArea(state->dpy, state->images, state->window, state->draw_gc,
|
||||||
(cell->glow ? state->char_width : 0), (cell->glyph - 1) * state->char_height,
|
(cell->glow ? state->char_width : 0), (cell->glyph - 1) * state->char_height,
|
||||||
state->char_width, state->char_height, x * state->char_width, y * state->char_height );
|
state->char_width, state->char_height, x * state->char_width, y * state->char_height);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,25 +339,20 @@ void draw_matrix (m_state *state, int d) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
static int i = 0;
|
static int i = 0;
|
||||||
static int ndens = 0;
|
static int ndens = 0;
|
||||||
static int tdens = 0;
|
static int tdens = 0;
|
||||||
i++;
|
i++;
|
||||||
if (i > 50)
|
if (i > 50) {
|
||||||
{
|
int dens = (100.0 * (((double)count) / ((double)(state->grid_width * state->grid_height))));
|
||||||
int dens = (100.0 *
|
|
||||||
(((double)count) /
|
|
||||||
((double) (state->grid_width * state->grid_height))));
|
|
||||||
tdens += dens;
|
tdens += dens;
|
||||||
ndens++;
|
ndens++;
|
||||||
printf ("density: %d%% (%d%%)\n", dens, (tdens / ndens));
|
printf("density: %d%% (%d%%)\n", dens, (tdens / ndens));
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <X11/xpm.h>
|
#include <X11/xpm.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int glyph;
|
int glyph;
|
||||||
int changed;
|
int changed;
|
||||||
|
@ -36,4 +35,3 @@ typedef struct {
|
||||||
int nglyphs;
|
int nglyphs;
|
||||||
|
|
||||||
} m_state;
|
} m_state;
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
static const char screensaver_id[] =
|
static const char screensaver_id[] = "@(#)xscreensaver 3.17 (15-Jul-99), by Jamie Zawinski (jwz@jwz.org)";
|
||||||
"@(#)xscreensaver 3.17 (15-Jul-99), by Jamie Zawinski (jwz@jwz.org)";
|
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Includes
|
* Includes
|
||||||
*/
|
*/
|
||||||
|
@ -54,20 +53,17 @@
|
||||||
#include "wmMatrix_mask.xbm"
|
#include "wmMatrix_mask.xbm"
|
||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delay between refreshes (in microseconds)
|
* Delay between refreshes (in microseconds)
|
||||||
*/
|
*/
|
||||||
#define DELAY 20000UL /* 0.020000 sec */
|
#define DELAY 20000UL /* 0.020000 sec */
|
||||||
#define WMMATRIX_VERSION "0.2"
|
#define WMMATRIX_VERSION "0.2"
|
||||||
|
|
||||||
|
|
||||||
void ParseCMDLine(int argc, char *argv[]);
|
void ParseCMDLine(int argc, char *argv[]);
|
||||||
void ButtonPressEvent(XButtonEvent *);
|
void ButtonPressEvent(XButtonEvent *);
|
||||||
void print_usage();
|
void print_usage();
|
||||||
m_state *init_matrix( Display *, Window );
|
m_state *init_matrix(Display *, Window);
|
||||||
void draw_matrix( m_state *, int );
|
void draw_matrix(m_state *, int);
|
||||||
|
|
||||||
|
|
||||||
int GotFirstClick1, GotDoubleClick1;
|
int GotFirstClick1, GotDoubleClick1;
|
||||||
int GotFirstClick2, GotDoubleClick2;
|
int GotFirstClick2, GotDoubleClick2;
|
||||||
|
@ -80,35 +76,34 @@ char *progclass = "WMMatrix";
|
||||||
int PixmapSize;
|
int PixmapSize;
|
||||||
char *DoubleClickCmd = NULL;
|
char *DoubleClickCmd = NULL;
|
||||||
char *RDoubleClickCmd = NULL;
|
char *RDoubleClickCmd = NULL;
|
||||||
char* TimeColor = "#ffff00";
|
char *TimeColor = "#ffff00";
|
||||||
char* BackgroundColor = "#181818";
|
char *BackgroundColor = "#181818";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* main
|
* main
|
||||||
*/
|
*/
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
XEvent event;
|
XEvent event;
|
||||||
m_state *state;
|
m_state *state;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse any command line arguments.
|
* Parse any command line arguments.
|
||||||
*/
|
*/
|
||||||
ParseCMDLine(argc, argv);
|
ParseCMDLine(argc, argv);
|
||||||
if(DoubleClickCmd==NULL)
|
if (DoubleClickCmd == NULL)
|
||||||
DoubleClickCmd=strdup("xscreensaver-demo");
|
DoubleClickCmd = strdup("xscreensaver-demo");
|
||||||
if(RDoubleClickCmd==NULL)
|
if (RDoubleClickCmd == NULL)
|
||||||
RDoubleClickCmd=strdup("xscreensaver-command -activate");
|
RDoubleClickCmd = strdup("xscreensaver-command -activate");
|
||||||
initXwindow(argc, argv);
|
initXwindow(argc, argv);
|
||||||
openXwindow(argc, argv, wmMatrix_master, wmMatrix_mask_bits, wmMatrix_mask_width, wmMatrix_mask_height);
|
openXwindow(argc, argv, wmMatrix_master, wmMatrix_mask_bits, wmMatrix_mask_width, wmMatrix_mask_height);
|
||||||
state = init_matrix( display, iconwin );
|
state = init_matrix(display, iconwin);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Loop until we die
|
* Loop until we die
|
||||||
*/
|
*/
|
||||||
while(1) {
|
while (1) {
|
||||||
draw_matrix( state, 40 );
|
draw_matrix(state, 40);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Double Click Delays
|
* Double Click Delays
|
||||||
|
@ -117,9 +112,12 @@ int main(int argc, char *argv[]) {
|
||||||
/* 25 * 0.02 = .5 sec */
|
/* 25 * 0.02 = .5 sec */
|
||||||
if (DblClkDelay > 25) {
|
if (DblClkDelay > 25) {
|
||||||
DblClkDelay = 0;
|
DblClkDelay = 0;
|
||||||
GotFirstClick1 = 0; GotDoubleClick1 = 0;
|
GotFirstClick1 = 0;
|
||||||
GotFirstClick2 = 0; GotDoubleClick2 = 0;
|
GotDoubleClick1 = 0;
|
||||||
GotFirstClick3 = 0; GotDoubleClick3 = 0;
|
GotFirstClick2 = 0;
|
||||||
|
GotDoubleClick2 = 0;
|
||||||
|
GotFirstClick3 = 0;
|
||||||
|
GotDoubleClick3 = 0;
|
||||||
} else {
|
} else {
|
||||||
++DblClkDelay;
|
++DblClkDelay;
|
||||||
}
|
}
|
||||||
|
@ -127,9 +125,9 @@ int main(int argc, char *argv[]) {
|
||||||
/*
|
/*
|
||||||
* Process any pending X events.
|
* Process any pending X events.
|
||||||
*/
|
*/
|
||||||
while(XPending(display)){
|
while (XPending(display)) {
|
||||||
XNextEvent(display, &event);
|
XNextEvent(display, &event);
|
||||||
switch(event.type){
|
switch (event.type) {
|
||||||
case Expose:
|
case Expose:
|
||||||
RedrawWindow();
|
RedrawWindow();
|
||||||
break;
|
break;
|
||||||
|
@ -152,39 +150,39 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ParseCMDLine()
|
* ParseCMDLine()
|
||||||
*/
|
*/
|
||||||
void ParseCMDLine(int argc, char *argv[]) {
|
void ParseCMDLine(int argc, char *argv[])
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
PixmapSize = 2;
|
PixmapSize = 2;
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (!strcmp(argv[i], "-display")){
|
if (!strcmp(argv[i], "-display")) {
|
||||||
++i;
|
++i;
|
||||||
} else if (!strcmp(argv[i], "-c")){
|
} else if (!strcmp(argv[i], "-c")) {
|
||||||
if ((i+1 >= argc)||(argv[i+1][0] == '-')) {
|
if ((i + 1 >= argc) || (argv[i + 1][0] == '-')) {
|
||||||
fprintf(stderr, "wmMatrix: No command given\n");
|
fprintf(stderr, "wmMatrix: No command given\n");
|
||||||
print_usage();
|
print_usage();
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
if(DoubleClickCmd!=NULL)
|
if (DoubleClickCmd != NULL)
|
||||||
free(DoubleClickCmd);
|
free(DoubleClickCmd);
|
||||||
DoubleClickCmd=strdup(argv[++i]);
|
DoubleClickCmd = strdup(argv[++i]);
|
||||||
} else if (!strcmp(argv[i], "-cr")){
|
} else if (!strcmp(argv[i], "-cr")) {
|
||||||
if ((i+1 >= argc)||(argv[i+1][0] == '-')) {
|
if ((i + 1 >= argc) || (argv[i + 1][0] == '-')) {
|
||||||
fprintf(stderr, "wmMatrix: No command given\n");
|
fprintf(stderr, "wmMatrix: No command given\n");
|
||||||
print_usage();
|
print_usage();
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
if(RDoubleClickCmd!=NULL)
|
if (RDoubleClickCmd != NULL)
|
||||||
free(RDoubleClickCmd);
|
free(RDoubleClickCmd);
|
||||||
RDoubleClickCmd=strdup(argv[++i]);
|
RDoubleClickCmd = strdup(argv[++i]);
|
||||||
} else if (!strcmp(argv[i], "-sml")){
|
} else if (!strcmp(argv[i], "-sml")) {
|
||||||
PixmapSize = 1;
|
PixmapSize = 1;
|
||||||
} else if (!strcmp(argv[i], "-med")){
|
} else if (!strcmp(argv[i], "-med")) {
|
||||||
PixmapSize = 2;
|
PixmapSize = 2;
|
||||||
} else if (!strcmp(argv[i], "-lrg")){
|
} else if (!strcmp(argv[i], "-lrg")) {
|
||||||
PixmapSize = 3;
|
PixmapSize = 3;
|
||||||
} else {
|
} else {
|
||||||
print_usage();
|
print_usage();
|
||||||
|
@ -193,8 +191,8 @@ void ParseCMDLine(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_usage()
|
||||||
void print_usage() {
|
{
|
||||||
printf("\nwmMatrix version: %s\n", WMMATRIX_VERSION);
|
printf("\nwmMatrix version: %s\n", WMMATRIX_VERSION);
|
||||||
printf("\t-h\t\tDisplay help screen.\n");
|
printf("\t-h\t\tDisplay help screen.\n");
|
||||||
printf("\t-c cmd\t\tCommand executed on doubleclick.\n");
|
printf("\t-c cmd\t\tCommand executed on doubleclick.\n");
|
||||||
|
@ -204,7 +202,6 @@ void print_usage() {
|
||||||
printf("\t-lrg\t\tUse large size pixmap.\n");
|
printf("\t-lrg\t\tUse large size pixmap.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine handles button presses.
|
* This routine handles button presses.
|
||||||
*
|
*
|
||||||
|
@ -215,20 +212,26 @@ void print_usage() {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void ButtonPressEvent(XButtonEvent *xev){
|
void ButtonPressEvent(XButtonEvent * xev)
|
||||||
|
{
|
||||||
DblClkDelay = 0;
|
DblClkDelay = 0;
|
||||||
if ((xev->button == Button1) && (xev->type == ButtonPress)){
|
if ((xev->button == Button1) && (xev->type == ButtonPress)) {
|
||||||
if (GotFirstClick1) GotDoubleClick1 = 1;
|
if (GotFirstClick1)
|
||||||
else GotFirstClick1 = 1;
|
GotDoubleClick1 = 1;
|
||||||
} else if ((xev->button == Button2) && (xev->type == ButtonPress)){
|
else
|
||||||
if (GotFirstClick2) GotDoubleClick2 = 1;
|
GotFirstClick1 = 1;
|
||||||
else GotFirstClick2 = 1;
|
} else if ((xev->button == Button2) && (xev->type == ButtonPress)) {
|
||||||
} else if ((xev->button == Button3) && (xev->type == ButtonPress)){
|
if (GotFirstClick2)
|
||||||
if (GotFirstClick3) GotDoubleClick3 = 1;
|
GotDoubleClick2 = 1;
|
||||||
else GotFirstClick3 = 1;
|
else
|
||||||
|
GotFirstClick2 = 1;
|
||||||
|
} else if ((xev->button == Button3) && (xev->type == ButtonPress)) {
|
||||||
|
if (GotFirstClick3)
|
||||||
|
GotDoubleClick3 = 1;
|
||||||
|
else
|
||||||
|
GotFirstClick3 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We got a double click on Mouse Button1 (i.e. the left one)
|
* We got a double click on Mouse Button1 (i.e. the left one)
|
||||||
*/
|
*/
|
||||||
|
@ -238,7 +241,6 @@ void ButtonPressEvent(XButtonEvent *xev){
|
||||||
system(DoubleClickCmd);
|
system(DoubleClickCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We got a double click on Mouse Button2 (i.e. the middle one)
|
* We got a double click on Mouse Button2 (i.e. the middle one)
|
||||||
*/
|
*/
|
||||||
|
@ -247,7 +249,6 @@ void ButtonPressEvent(XButtonEvent *xev){
|
||||||
GotDoubleClick2 = 0;
|
GotDoubleClick2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We got a double click on Mouse Button3 (i.e. the right one)
|
* We got a double click on Mouse Button3 (i.e. the right one)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -41,8 +41,6 @@
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include "xutils.h"
|
#include "xutils.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* X11 Variables
|
* X11 Variables
|
||||||
*/
|
*/
|
||||||
|
@ -56,25 +54,20 @@ GC EraseGC;
|
||||||
XpmIcon wmgen;
|
XpmIcon wmgen;
|
||||||
Pixmap pixmask;
|
Pixmap pixmask;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Colors for wmCalClock
|
* Colors for wmCalClock
|
||||||
*/
|
*/
|
||||||
extern char TimeColor[30];
|
extern char TimeColor[30];
|
||||||
extern char BackgroundColor[30];
|
extern char BackgroundColor[30];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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;
|
||||||
|
|
||||||
while (XCheckTypedWindowEvent(display, w, Expose, &dummy))
|
while (XCheckTypedWindowEvent(display, w, Expose, &dummy))
|
||||||
i++;
|
i++;
|
||||||
|
@ -83,79 +76,66 @@ static int flush_expose(Window w) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RedrawWindow
|
* RedrawWindow
|
||||||
* RedrawWindowXY
|
* RedrawWindowXY
|
||||||
*/
|
*/
|
||||||
void RedrawWindow(void) {
|
void RedrawWindow(void)
|
||||||
|
{
|
||||||
|
|
||||||
flush_expose(iconwin);
|
flush_expose(iconwin);
|
||||||
XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, 0,0, wmgen.attributes.width, wmgen.attributes.height, 0, 0);
|
XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, 0, 0, wmgen.attributes.width, wmgen.attributes.height, 0, 0);
|
||||||
|
|
||||||
flush_expose(win);
|
flush_expose(win);
|
||||||
XCopyArea(display, wmgen.pixmap, win, NormalGC, 0,0, wmgen.attributes.width, wmgen.attributes.height, 0, 0);
|
XCopyArea(display, wmgen.pixmap, win, NormalGC, 0, 0, wmgen.attributes.width, wmgen.attributes.height, 0, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RedrawWindowXY(int x, int y) {
|
void RedrawWindowXY(int x, int y)
|
||||||
|
{
|
||||||
|
|
||||||
flush_expose(iconwin);
|
flush_expose(iconwin);
|
||||||
XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, x,y, wmgen.attributes.width, wmgen.attributes.height, 0, 0);
|
XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, x, y, wmgen.attributes.width, wmgen.attributes.height, 0, 0);
|
||||||
|
|
||||||
flush_expose(win);
|
flush_expose(win);
|
||||||
XCopyArea(display, wmgen.pixmap, win, NormalGC, x,y, wmgen.attributes.width, wmgen.attributes.height, 0, 0);
|
XCopyArea(display, wmgen.pixmap, win, NormalGC, x, y, wmgen.attributes.width, wmgen.attributes.height, 0, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* copyXPMArea
|
* copyXPMArea
|
||||||
* copyXBMArea
|
* copyXBMArea
|
||||||
*/
|
*/
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initXwindow
|
* initXwindow
|
||||||
*/
|
*/
|
||||||
void initXwindow(int argc, char *argv[]){
|
void initXwindow(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
char *display_name = NULL;
|
char *display_name = NULL;
|
||||||
|
|
||||||
for (i=1; argv[i]; ++i) {
|
for (i = 1; argv[i]; ++i) {
|
||||||
if (!strcmp(argv[i], "-display")) display_name = argv[i+1];
|
if (!strcmp(argv[i], "-display"))
|
||||||
|
display_name = argv[i + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!(display = XOpenDisplay(display_name))) {
|
if (!(display = XOpenDisplay(display_name))) {
|
||||||
fprintf(stderr, "%s: can't open display %s\n",
|
fprintf(stderr, "%s: can't open display %s\n", argv[0], XDisplayName(display_name));
|
||||||
argv[0], XDisplayName(display_name));
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
screen = DefaultScreen(display);
|
screen = DefaultScreen(display);
|
||||||
Root = RootWindow(display, screen);
|
Root = RootWindow(display, screen);
|
||||||
DisplayDepth = DefaultDepth(display, screen);
|
DisplayDepth = DefaultDepth(display, screen);
|
||||||
|
@ -163,15 +143,11 @@ void initXwindow(int argc, char *argv[]){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* openXwindow
|
* openXwindow
|
||||||
*/
|
*/
|
||||||
void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bits,
|
void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bits, int pixmask_width, int pixmask_height)
|
||||||
int pixmask_width, int pixmask_height) {
|
{
|
||||||
|
|
||||||
unsigned int borderwidth = 1;
|
unsigned int borderwidth = 1;
|
||||||
XClassHint classHint;
|
XClassHint classHint;
|
||||||
|
@ -179,8 +155,8 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
|
||||||
XTextProperty name;
|
XTextProperty name;
|
||||||
XGCValues gcv;
|
XGCValues gcv;
|
||||||
unsigned long gcm;
|
unsigned long gcm;
|
||||||
int dummy=0, red, grn, blu;
|
int dummy = 0, red, grn, blu;
|
||||||
XpmColorSymbol cols[10]={ {"Back", NULL, 0},
|
XpmColorSymbol cols[10] = { {"Back", NULL, 0},
|
||||||
{"Color1", NULL, 0},
|
{"Color1", NULL, 0},
|
||||||
{"Color2", NULL, 0},
|
{"Color2", NULL, 0},
|
||||||
{"Color3", NULL, 0},
|
{"Color3", NULL, 0},
|
||||||
|
@ -189,10 +165,8 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
|
||||||
{"Color6", NULL, 0},
|
{"Color6", NULL, 0},
|
||||||
{"Color7", NULL, 0},
|
{"Color7", NULL, 0},
|
||||||
{"Color8", NULL, 0},
|
{"Color8", NULL, 0},
|
||||||
{"Color9", NULL, 0}};
|
{"Color9", NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create Pixmap
|
* Create Pixmap
|
||||||
|
@ -212,17 +186,12 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
|
||||||
wmgen.attributes.colorsymbols = cols;
|
wmgen.attributes.colorsymbols = cols;
|
||||||
wmgen.attributes.exactColors = False;
|
wmgen.attributes.exactColors = False;
|
||||||
wmgen.attributes.closeness = 40000;
|
wmgen.attributes.closeness = 40000;
|
||||||
wmgen.attributes.valuemask = XpmReturnPixels | XpmReturnExtensions | XpmColorSymbols
|
wmgen.attributes.valuemask = XpmReturnPixels | XpmReturnExtensions | XpmColorSymbols | XpmExactColors | XpmCloseness | XpmSize;
|
||||||
| XpmExactColors | XpmCloseness | XpmSize;
|
if (XpmCreatePixmapFromData(display, Root, pixmap_bytes, &(wmgen.pixmap), &(wmgen.mask), &(wmgen.attributes)) != XpmSuccess) {
|
||||||
if (XpmCreatePixmapFromData(display, Root, pixmap_bytes,
|
|
||||||
&(wmgen.pixmap), &(wmgen.mask), &(wmgen.attributes)) != XpmSuccess){
|
|
||||||
fprintf(stderr, "Not enough free colorcells.\n");
|
fprintf(stderr, "Not enough free colorcells.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a window
|
* Create a window
|
||||||
*/
|
*/
|
||||||
|
@ -234,21 +203,17 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
|
||||||
fore_pix = getColor("white", 1.0, &red, &grn, &blu);
|
fore_pix = getColor("white", 1.0, &red, &grn, &blu);
|
||||||
|
|
||||||
XWMGeometry(display, screen, Geometry, NULL, borderwidth, &mysizehints,
|
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.width = 64;
|
||||||
mysizehints.height = 64;
|
mysizehints.height = 64;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
win = XCreateSimpleWindow(display, Root, mysizehints.x, mysizehints.y,
|
win = XCreateSimpleWindow(display, Root, mysizehints.x, mysizehints.y,
|
||||||
mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix);
|
mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix);
|
||||||
|
|
||||||
iconwin = XCreateSimpleWindow(display, win, mysizehints.x, mysizehints.y,
|
iconwin = XCreateSimpleWindow(display, win, mysizehints.x, mysizehints.y,
|
||||||
mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix);
|
mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Activate hints
|
* Activate hints
|
||||||
*/
|
*/
|
||||||
|
@ -257,8 +222,6 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
|
||||||
classHint.res_class = wname;
|
classHint.res_class = wname;
|
||||||
XSetClassHint(display, win, &classHint);
|
XSetClassHint(display, win, &classHint);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up the xevents that you want the relevent windows to inherit
|
* Set up the xevents that you want the relevent windows to inherit
|
||||||
* Currently, its seems that setting KeyPress events here has no
|
* Currently, its seems that setting KeyPress events here has no
|
||||||
|
@ -266,19 +229,15 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
|
||||||
* it after you are done...
|
* it after you are done...
|
||||||
*/
|
*/
|
||||||
XSelectInput(display, win, ButtonPressMask | ExposureMask | ButtonReleaseMask
|
XSelectInput(display, win, ButtonPressMask | ExposureMask | ButtonReleaseMask
|
||||||
| PointerMotionMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask
|
| PointerMotionMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask | KeyPressMask | KeyReleaseMask);
|
||||||
| KeyPressMask | KeyReleaseMask);
|
|
||||||
XSelectInput(display, iconwin, ButtonPressMask | ExposureMask | ButtonReleaseMask
|
XSelectInput(display, iconwin, ButtonPressMask | ExposureMask | ButtonReleaseMask
|
||||||
| PointerMotionMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask
|
| PointerMotionMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask | KeyPressMask | KeyReleaseMask);
|
||||||
| KeyPressMask | KeyReleaseMask);
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XSetWMName(display, win, &name);
|
XSetWMName(display, win, &name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -299,13 +258,10 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
|
||||||
gcv.graphics_exposures = 0;
|
gcv.graphics_exposures = 0;
|
||||||
EraseGC = XCreateGC(display, Root, gcm, &gcv);
|
EraseGC = XCreateGC(display, Root, gcm, &gcv);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pixmask = XCreateBitmapFromData(display, win, pixmask_bits, pixmask_width, pixmask_height);
|
pixmask = XCreateBitmapFromData(display, win, pixmask_bits, pixmask_width, pixmask_height);
|
||||||
XShapeCombineMask(display, win, ShapeBounding, 0, 0, pixmask, ShapeSet);
|
XShapeCombineMask(display, win, ShapeBounding, 0, 0, pixmask, ShapeSet);
|
||||||
XShapeCombineMask(display, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet);
|
XShapeCombineMask(display, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet);
|
||||||
|
|
||||||
|
|
||||||
mywmhints.initial_state = WithdrawnState;
|
mywmhints.initial_state = WithdrawnState;
|
||||||
mywmhints.icon_window = iconwin;
|
mywmhints.icon_window = iconwin;
|
||||||
mywmhints.icon_x = mysizehints.x;
|
mywmhints.icon_x = mysizehints.x;
|
||||||
|
@ -313,16 +269,15 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
|
||||||
mywmhints.window_group = win;
|
mywmhints.window_group = win;
|
||||||
mywmhints.flags = StateHint | IconWindowHint | IconPositionHint | WindowGroupHint;
|
mywmhints.flags = StateHint | IconWindowHint | IconPositionHint | WindowGroupHint;
|
||||||
|
|
||||||
|
|
||||||
XSetWMHints(display, win, &mywmhints);
|
XSetWMHints(display, win, &mywmhints);
|
||||||
|
|
||||||
|
|
||||||
XSetCommand(display, win, argv, argc);
|
XSetCommand(display, win, argv, argc);
|
||||||
XMapWindow(display, win);
|
XMapWindow(display, win);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long getColor(char *ColorName, float fac, int *red, int *grn, int *blu) {
|
unsigned long getColor(char *ColorName, float fac, int *red, int *grn, int *blu)
|
||||||
|
{
|
||||||
|
|
||||||
XColor Color;
|
XColor Color;
|
||||||
XWindowAttributes Attributes;
|
XWindowAttributes Attributes;
|
||||||
|
@ -331,13 +286,12 @@ unsigned long getColor(char *ColorName, float fac, int *red, int *grn, int *blu)
|
||||||
Color.pixel = 0;
|
Color.pixel = 0;
|
||||||
|
|
||||||
XParseColor(display, Attributes.colormap, ColorName, &Color);
|
XParseColor(display, Attributes.colormap, ColorName, &Color);
|
||||||
Color.red = (unsigned short)(fac*(Color.red-24) + 24);
|
Color.red = (unsigned short)(fac * (Color.red - 24) + 24);
|
||||||
Color.blue = (unsigned short)(fac*(Color.blue-24) + 24);
|
Color.blue = (unsigned short)(fac * (Color.blue - 24) + 24);
|
||||||
Color.green = (unsigned short)(fac*(Color.green-24) + 24);
|
Color.green = (unsigned short)(fac * (Color.green - 24) + 24);
|
||||||
Color.flags = DoRed | DoGreen | DoBlue;
|
Color.flags = DoRed | DoGreen | DoBlue;
|
||||||
XAllocColor(display, Attributes.colormap, &Color);
|
XAllocColor(display, Attributes.colormap, &Color);
|
||||||
|
|
||||||
|
|
||||||
*red = Color.red;
|
*red = Color.red;
|
||||||
*grn = Color.green;
|
*grn = Color.green;
|
||||||
*blu = Color.blue;
|
*blu = Color.blue;
|
||||||
|
@ -345,7 +299,8 @@ unsigned long getColor(char *ColorName, float fac, int *red, int *grn, int *blu)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long getBlendedColor(char *ColorName, float fac, int red, int grn, int blu) {
|
unsigned long getBlendedColor(char *ColorName, float fac, int red, int grn, int blu)
|
||||||
|
{
|
||||||
|
|
||||||
XColor Color;
|
XColor Color;
|
||||||
XWindowAttributes Attributes;
|
XWindowAttributes Attributes;
|
||||||
|
@ -354,9 +309,9 @@ unsigned long getBlendedColor(char *ColorName, float fac, int red, int grn, int
|
||||||
Color.pixel = 0;
|
Color.pixel = 0;
|
||||||
|
|
||||||
XParseColor(display, Attributes.colormap, ColorName, &Color);
|
XParseColor(display, Attributes.colormap, ColorName, &Color);
|
||||||
Color.red = (unsigned short)(fac*(Color.red-red) + red);
|
Color.red = (unsigned short)(fac * (Color.red - red) + red);
|
||||||
Color.blue = (unsigned short)(fac*(Color.blue-grn) + grn);
|
Color.blue = (unsigned short)(fac * (Color.blue - grn) + grn);
|
||||||
Color.green = (unsigned short)(fac*(Color.green-blu) + blu);
|
Color.green = (unsigned short)(fac * (Color.green - blu) + blu);
|
||||||
Color.flags = DoRed | DoGreen | DoBlue;
|
Color.flags = DoRed | DoGreen | DoBlue;
|
||||||
XAllocColor(display, Attributes.colormap, &Color);
|
XAllocColor(display, Attributes.colormap, &Color);
|
||||||
|
|
||||||
|
@ -364,11 +319,11 @@ unsigned long getBlendedColor(char *ColorName, float fac, int red, int grn, int
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Here is a faster version of usleep using select()
|
* Here is a faster version of usleep using select()
|
||||||
*/
|
*/
|
||||||
void uusleep(unsigned long usecs) {
|
void uusleep(unsigned long usecs)
|
||||||
|
{
|
||||||
|
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
|
@ -385,7 +340,8 @@ void uusleep(unsigned long usecs) {
|
||||||
* will be less than 1 second. This allows us to save on a div operation.
|
* will be less than 1 second. This allows us to save on a div operation.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void short_uusleep(unsigned long usecs) {
|
void short_uusleep(unsigned long usecs)
|
||||||
|
{
|
||||||
|
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
|
@ -396,4 +352,3 @@ void short_uusleep(unsigned long usecs) {
|
||||||
select(x_fd + 1, &fds, NULL, NULL, &tv);
|
select(x_fd + 1, &fds, NULL, NULL, &tv);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#ifndef WMGENERAL_H_INCLUDED
|
#ifndef WMGENERAL_H_INCLUDED
|
||||||
#define WMGENERAL_H_INCLUDED
|
#define WMGENERAL_H_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Typedefs
|
* Typedefs
|
||||||
*/
|
*/
|
||||||
|
@ -12,9 +10,6 @@ typedef struct {
|
||||||
XpmAttributes attributes;
|
XpmAttributes attributes;
|
||||||
} XpmIcon;
|
} XpmIcon;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Global variable
|
* Global variable
|
||||||
*/
|
*/
|
||||||
|
@ -24,10 +19,6 @@ Window iconwin, win;
|
||||||
int screen;
|
int screen;
|
||||||
int DisplayDepth;
|
int DisplayDepth;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function Prototypes
|
* Function Prototypes
|
||||||
*/
|
*/
|
||||||
|
@ -43,9 +34,7 @@ void setMaskXY(int, int);
|
||||||
unsigned long getColor(char *, float, int *, int *, int *);
|
unsigned long getColor(char *, float, int *, int *, int *);
|
||||||
unsigned long getBlendedColor(char *, float, int, int, int);
|
unsigned long getBlendedColor(char *, float, int, int, int);
|
||||||
void RedrawWindow(void);
|
void RedrawWindow(void);
|
||||||
void uusleep( unsigned long );
|
void uusleep(unsigned long);
|
||||||
void short_uusleep( unsigned long );
|
void short_uusleep(unsigned long);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,15 +42,13 @@
|
||||||
Irix 6.2; Indy r5k; SGI cc version 6; gcc version 2.7.2.1.
|
Irix 6.2; Indy r5k; SGI cc version 6; gcc version 2.7.2.1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
# include <unistd.h> /* for getpid() */
|
#include <unistd.h> /* for getpid() */
|
||||||
#endif
|
#endif
|
||||||
#include <sys/time.h> /* for gettimeofday() */
|
#include <sys/time.h> /* for gettimeofday() */
|
||||||
|
|
||||||
#include "yarandom.h"
|
#include "yarandom.h"
|
||||||
|
|
||||||
|
|
||||||
/* The following 'random' numbers are taken from CRC, 18th Edition, page 622.
|
/* The following 'random' numbers are taken from CRC, 18th Edition, page 622.
|
||||||
Each array element was taken from the corresponding line in the table,
|
Each array element was taken from the corresponding line in the table,
|
||||||
except that a[0] was from line 100. 8s and 9s in the table were simply
|
except that a[0] was from line 100. 8s and 9s in the table were simply
|
||||||
|
@ -73,22 +71,21 @@ static unsigned int a[VectorSize] = {
|
||||||
|
|
||||||
static int i1, i2;
|
static int i1, i2;
|
||||||
|
|
||||||
unsigned int
|
unsigned int ya_random(void)
|
||||||
ya_random (void)
|
|
||||||
{
|
{
|
||||||
register int ret = a[i1] + a[i2];
|
register int ret = a[i1] + a[i2];
|
||||||
a[i1] = ret;
|
a[i1] = ret;
|
||||||
if (++i1 >= VectorSize) i1 = 0;
|
if (++i1 >= VectorSize)
|
||||||
if (++i2 >= VectorSize) i2 = 0;
|
i1 = 0;
|
||||||
|
if (++i2 >= VectorSize)
|
||||||
|
i2 = 0;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ya_rand_init(unsigned int seed)
|
||||||
ya_rand_init(unsigned int seed)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (seed == 0)
|
if (seed == 0) {
|
||||||
{
|
|
||||||
struct timeval tp;
|
struct timeval tp;
|
||||||
#ifdef GETTIMEOFDAY_TWO_ARGS
|
#ifdef GETTIMEOFDAY_TWO_ARGS
|
||||||
struct timezone tzp;
|
struct timezone tzp;
|
||||||
|
@ -97,13 +94,12 @@ ya_rand_init(unsigned int seed)
|
||||||
gettimeofday(&tp);
|
gettimeofday(&tp);
|
||||||
#endif
|
#endif
|
||||||
/* ignore overflow */
|
/* ignore overflow */
|
||||||
seed = (999*tp.tv_sec) + (1001*tp.tv_usec) + (1003 * getpid());
|
seed = (999 * tp.tv_sec) + (1001 * tp.tv_usec) + (1003 * getpid());
|
||||||
}
|
}
|
||||||
|
|
||||||
a[0] += seed;
|
a[0] += seed;
|
||||||
for (i = 1; i < VectorSize; i++)
|
for (i = 1; i < VectorSize; i++) {
|
||||||
{
|
seed = a[i - 1] * 1001 + seed * 999;
|
||||||
seed = a[i-1]*1001 + seed*999;
|
|
||||||
a[i] += seed;
|
a[i] += seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,29 +22,28 @@
|
||||||
#undef RAND_MAX
|
#undef RAND_MAX
|
||||||
|
|
||||||
#ifdef VMS
|
#ifdef VMS
|
||||||
# include "vms-gtod.h"
|
#include "vms-gtod.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define random() ya_random()
|
#define random() ya_random()
|
||||||
#define srandom(i) ya_rand_init(0)
|
#define srandom(i) ya_rand_init(0)
|
||||||
#define RAND_MAX 0x7FFFFFFF
|
#define RAND_MAX 0x7FFFFFFF
|
||||||
|
|
||||||
extern unsigned int ya_random (void);
|
extern unsigned int ya_random(void);
|
||||||
extern void ya_rand_init (unsigned int);
|
extern void ya_rand_init(unsigned int);
|
||||||
|
|
||||||
|
|
||||||
#if defined (__GNUC__) && (__GNUC__ >= 2)
|
#if defined (__GNUC__) && (__GNUC__ >= 2)
|
||||||
/* Implement frand using GCC's statement-expression extension. */
|
/* Implement frand using GCC's statement-expression extension. */
|
||||||
|
|
||||||
# define frand(f) \
|
#define frand(f) \
|
||||||
({ double tmp = (((double) random()) / \
|
({ double tmp = (((double) random()) / \
|
||||||
(((double) ((unsigned int)~0)) / ((double) (f)))); \
|
(((double) ((unsigned int)~0)) / ((double) (f)))); \
|
||||||
tmp < 0 ? (-tmp) : tmp; })
|
tmp < 0 ? (-tmp) : tmp; })
|
||||||
|
|
||||||
#else /* not GCC2 - implement frand using a global variable.*/
|
#else /* not GCC2 - implement frand using a global variable. */
|
||||||
|
|
||||||
static double _frand_tmp_;
|
static double _frand_tmp_;
|
||||||
# define frand(f) \
|
#define frand(f) \
|
||||||
(_frand_tmp_ = (((double) random()) / \
|
(_frand_tmp_ = (((double) random()) / \
|
||||||
(((double) ((unsigned int)~0)) / ((double) (f)))), \
|
(((double) ((unsigned int)~0)) / ((double) (f)))), \
|
||||||
_frand_tmp_ < 0 ? (-_frand_tmp_) : _frand_tmp_)
|
_frand_tmp_ < 0 ? (-_frand_tmp_) : _frand_tmp_)
|
||||||
|
|
Loading…
Reference in a new issue