projects
/
xscreensaver
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver]
/
hacks
/
wander.c
diff --git
a/hacks/wander.c
b/hacks/wander.c
index 9cdd090bd182a4ba06b0ac0afd2b0e5a277a43d9..1ac0c6cff2dabd4ee93d525f3fc22f1d5448b3a1 100644
(file)
--- a/
hacks/wander.c
+++ b/
hacks/wander.c
@@
-33,6
+33,7
@@
struct state {
int height;
unsigned int length;
unsigned int reset;
int height;
unsigned int length;
unsigned int reset;
+ Bool reset_p;
unsigned int size;
int width;
int delay;
unsigned int size;
int width;
int delay;
@@
-64,12
+65,13
@@
wander_init (Display *dpy, Window window)
st->color_map = attributes.colormap;
if (st->color_count)
{
st->color_map = attributes.colormap;
if (st->color_count)
{
- free_colors (st->dpy, st->color_map, st->colors, st->color_count);
+ free_colors (attributes.screen, st->color_map,
+ st->colors, st->color_count);
st->color_count = 0;
}
st->context = XCreateGC (st->dpy, st->window, 0, &values);
st->color_count = MAXIMUM_COLOR_COUNT;
st->color_count = 0;
}
st->context = XCreateGC (st->dpy, st->window, 0, &values);
st->color_count = MAXIMUM_COLOR_COUNT;
- make_color_loop (
st->dpy
, st->color_map,
+ make_color_loop (
attributes.screen, attributes.visual
, st->color_map,
0, 1, 1,
120, 1, 1,
240, 1, 1,
0, 1, 1,
120, 1, 1,
240, 1, 1,
@@
-82,7
+84,7
@@
wander_init (Display *dpy, Window window)
XAllocColor (st->dpy, st->color_map, &st->colors [0]);
XAllocColor (st->dpy, st->color_map, &st->colors [1]);
}
XAllocColor (st->dpy, st->color_map, &st->colors [0]);
XAllocColor (st->dpy, st->color_map, &st->colors [1]);
}
- st->color_index =
random () % st->color_count
;
+ st->color_index =
NRAND (st->color_count)
;
st->advance = get_integer_resource (st->dpy, "advance", "Integer");
st->density = get_integer_resource (st->dpy, "density", "Integer");
st->advance = get_integer_resource (st->dpy, "advance", "Integer");
st->density = get_integer_resource (st->dpy, "density", "Integer");
@@
-99,16
+101,16
@@
wander_init (Display *dpy, Window window)
XSetForeground (st->dpy, st->context, st->colors [st->color_index].pixel);
XSetForeground (st->dpy, st->context, st->colors [st->color_index].pixel);
- st->x =
random () % st->width
;
- st->y =
random () % st->height
;
+ st->x =
NRAND (st->width)
;
+ st->y =
NRAND (st->height)
;
st->last_x = st->x;
st->last_y = st->y;
st->width_1 = st->width - 1;
st->height_1 = st->height - 1;
st->length_limit = st->length;
st->reset_limit = st->reset;
st->last_x = st->x;
st->last_y = st->y;
st->width_1 = st->width - 1;
st->height_1 = st->height - 1;
st->length_limit = st->length;
st->reset_limit = st->reset;
- st->color_index =
random () % st->color_count
;
- st->color = st->colors [
random () % st->color_count
].pixel;
+ st->color_index =
NRAND (st->color_count)
;
+ st->color = st->colors [
NRAND (st->color_count)
].pixel;
st->pixmap = XCreatePixmap (st->dpy, window, st->size,
st->size, st->depth);
st->pixmap = XCreatePixmap (st->dpy, window, st->size,
st->size, st->depth);
@@
-136,7
+138,7
@@
wander_draw (Display *dpy, Window window, void *closure)
for (i = 0; i < 2000; i++)
{
for (i = 0; i < 2000; i++)
{
- if (
random () % st->density
)
+ if (
NRAND (st->density)
)
{
st->x = st->last_x;
st->y = st->last_y;
{
st->x = st->last_x;
st->y = st->last_y;
@@
-145,15
+147,19
@@
wander_draw (Display *dpy, Window window, void *closure)
{
st->last_x = st->x;
st->last_y = st->y;
{
st->last_x = st->x;
st->last_y = st->y;
- st->x = (st->x + st->width_1 + (random () % 3)) % st->width;
- st->y = (st->y + st->height_1 + (random () % 3)) % st->height;
+ st->x += st->width_1 + NRAND (3);
+ while (st->x >= st->width)
+ st->x -= st->width;
+ st->y += st->height_1 + NRAND (3);
+ while (st->y >= st->height)
+ st->y -= st->height;
}
}
- if (
(random () %
st->length_limit) == 0)
+ if (
NRAND (
st->length_limit) == 0)
{
if (st->advance == 0)
{
{
if (st->advance == 0)
{
- st->color_index =
random () % st->color_count
;
+ st->color_index =
NRAND (st->color_count)
;
}
else
{
}
else
{
@@
-168,12
+174,13
@@
wander_draw (Display *dpy, Window window, void *closure)
}
}
}
}
- if (
(random () %
st->reset_limit) == 0)
+ if (
st->reset_p || NRAND (
st->reset_limit) == 0)
{
{
+ st->reset_p = 0;
st->eraser = erase_window (st->dpy, st->window, st->eraser);
st->eraser = erase_window (st->dpy, st->window, st->eraser);
- st->color = st->colors [
random () % st->color_count
].pixel;
- st->x =
random () % st->width
;
- st->y =
random () % st->height
;
+ st->color = st->colors [
NRAND (st->color_count)
].pixel;
+ st->x =
NRAND (st->width)
;
+ st->y =
NRAND (st->height)
;
st->last_x = st->x;
st->last_y = st->y;
if (st->circles)
st->last_x = st->x;
st->last_y = st->y;
if (st->circles)
@@
-210,23
+217,38
@@
static void
wander_reshape (Display *dpy, Window window, void *closure,
unsigned int w, unsigned int h)
{
wander_reshape (Display *dpy, Window window, void *closure,
unsigned int w, unsigned int h)
{
+ struct state *st = (struct state *) closure;
+ st->width = w / st->size;
+ st->height = h / st->size;
+ st->width_1 = st->width - 1;
+ st->height_1 = st->height - 1;
}
static Bool
wander_event (Display *dpy, Window window, void *closure, XEvent *event)
{
}
static Bool
wander_event (Display *dpy, Window window, void *closure, XEvent *event)
{
+ struct state *st = (struct state *) closure;
+ if (screenhack_event_helper (dpy, window, event))
+ {
+ st->reset_p = 1;
+ return True;
+ }
return False;
}
static void
wander_free (Display *dpy, Window window, void *closure)
{
return False;
}
static void
wander_free (Display *dpy, Window window, void *closure)
{
+ struct state *st = (struct state *) closure;
+ XFreeGC (st->dpy, st->context);
+ free (st);
}
static const char *wander_defaults [] =
{
".background: black",
".foreground: white",
}
static const char *wander_defaults [] =
{
".background: black",
".foreground: white",
+ ".fpsSolid: true",
".advance: 1",
".density: 2",
".length: 25000",
".advance: 1",
".density: 2",
".length: 25000",
@@
-234,6
+256,9
@@
static const char *wander_defaults [] =
".reset: 2500000",
".circles: False",
".size: 1",
".reset: 2500000",
".circles: False",
".size: 1",
+#ifdef HAVE_MOBILE
+ "*ignoreRotation: True",
+#endif
0
};
0
};