projects
/
xscreensaver
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
http://ftp.x.org/contrib/applications/xscreensaver-3.06.tar.gz
[xscreensaver]
/
hacks
/
coral.c
diff --git
a/hacks/coral.c
b/hacks/coral.c
index 8ace44d2c1e6787baa00bdca88b0448b4facf269..7621d5eee4818b4b8b830547f9c77fc24535cf46 100644
(file)
--- a/
hacks/coral.c
+++ b/
hacks/coral.c
@@
-21,12
+21,12
@@
static int ncolors = 0;
static int colorindex = 0;
static int colorsloth;
static int colorindex = 0;
static int colorsloth;
-static XPoint *walkers;
+static XPoint *walkers
= 0
;
static int nwalkers;
static int width, widthb;
static int height;
static int nwalkers;
static int width, widthb;
static int height;
-static unsigned int *board;
+static unsigned int *board
= 0
;
#define getdot(x,y) (board[(y*widthb)+(x>>5)] & (1<<(x & 31)))
#define setdot(x,y) (board[(y*widthb)+(x>>5)] |= (1<<(x & 31)))
#define getdot(x,y) (board[(y*widthb)+(x>>5)] & (1<<(x & 31)))
#define setdot(x,y) (board[(y*widthb)+(x>>5)] |= (1<<(x & 31)))
@@
-47,6
+47,7
@@
init_coral(Display *dpy, Window window)
width = xgwa.width;
widthb = ((xgwa.width + 31) >> 5);
height = xgwa.height;
width = xgwa.width;
widthb = ((xgwa.width + 31) >> 5);
height = xgwa.height;
+ if (board) free(board);
board = (unsigned int *)calloc(widthb * xgwa.height, sizeof(unsigned int));
if(!board) exit(1);
cmap = xgwa.colormap;
board = (unsigned int *)calloc(widthb * xgwa.height, sizeof(unsigned int));
if(!board) exit(1);
cmap = xgwa.colormap;
@@
-73,6
+74,7
@@
init_coral(Display *dpy, Window window)
if( density < 1 ) density = 1;
if( density > 100 ) density = 90; /* more like mold than coral */
nwalkers = (width*height*density)/100;
if( density < 1 ) density = 1;
if( density > 100 ) density = 90; /* more like mold than coral */
nwalkers = (width*height*density)/100;
+ if (walkers) free(walkers);
walkers = (XPoint *)calloc(nwalkers, sizeof(XPoint));
if( (XPoint *)0 == walkers ) exit(1);
walkers = (XPoint *)calloc(nwalkers, sizeof(XPoint));
if( (XPoint *)0 == walkers ) exit(1);
@@
-168,7
+170,7
@@
coral(Display *dpy, Window window)
XDrawPoints(dpy, window, draw_gc, pointbuf, npoints,
CoordModeOrigin);
npoints = 0;
XDrawPoints(dpy, window, draw_gc, pointbuf, npoints,
CoordModeOrigin);
npoints = 0;
- XSync(dpy,
Tru
e);
+ XSync(dpy,
Fals
e);
}
if (color) {
}
if (color) {
@@
-179,7
+181,7
@@
coral(Display *dpy, Window window)
}
if( 0 == nwalkers ) {
}
if( 0 == nwalkers ) {
- XSync(dpy,
Tru
e);
+ XSync(dpy,
Fals
e);
free(pointbuf);
return;
}
free(pointbuf);
return;
}
@@
-215,8
+217,9
@@
coral(Display *dpy, Window window)
XDrawPoints(dpy, window, draw_gc, pointbuf, npoints,
CoordModeOrigin);
npoints = 0;
XDrawPoints(dpy, window, draw_gc, pointbuf, npoints,
CoordModeOrigin);
npoints = 0;
- XSync(dpy,
Tru
e);
+ XSync(dpy,
Fals
e);
}
}
+ screenhack_handle_events (dpy);
usleep(delay2);
}
}
usleep(delay2);
}
}
@@
-251,6
+254,7
@@
Window window;
while( 1 ) {
init_coral(dpy, window);
coral(dpy, window);
while( 1 ) {
init_coral(dpy, window);
coral(dpy, window);
+ screenhack_handle_events (dpy);
if( delay ) sleep(delay);
erase_full_window(dpy, window);
}
if( delay ) sleep(delay);
erase_full_window(dpy, window);
}