From 6a32252403781b303d4ebd195932ce39c5b1c08e Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 30 Jul 2019 16:03:58 +0200 Subject: Update to 5.43 --- hacks/hexadrop.c | 54 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 12 deletions(-) (limited to 'hacks/hexadrop.c') diff --git a/hacks/hexadrop.c b/hacks/hexadrop.c index e8c2d65..b1b7d49 100644 --- a/hacks/hexadrop.c +++ b/hacks/hexadrop.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 1999-2018 Jamie Zawinski +/* xscreensaver, Copyright (c) 1999-2019 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -337,7 +337,7 @@ hexadrop_reshape (Display *dpy, Window window, void *closure, static void -hexadrop_free (Display *dpy, Window window, void *closure) +hexadrop_free_1 (Display *dpy, Window window, void *closure) { state *st = (state *) closure; if (st->colors) @@ -356,7 +356,16 @@ hexadrop_free (Display *dpy, Window window, void *closure) XFreeGC (st->dpy, st->gc); st->gc = 0; } - free (st); + + memset (st, 0, sizeof(*st)); +} + + +static void +hexadrop_free (Display *dpy, Window window, void *closure) +{ + hexadrop_free_1 (dpy, window, closure); + free (closure); } @@ -367,15 +376,35 @@ hexadrop_event (Display *dpy, Window window, void *closure, XEvent *event) if (screenhack_event_helper (dpy, window, event)) { - cell *c = st->cells; - int i; - st->cells = 0; - hexadrop_free (st->dpy, st->window, st); - free (st->cells); - st->cells = c; - for (i = 0; i < st->ncells; i++) - st->cells[i].initted_p = False; - hexadrop_init_1 (st->dpy, st->window, st); + if (random() % 5) /* Change everything */ + { + hexadrop_free_1 (st->dpy, st->window, st); + hexadrop_init_1 (dpy, window, st); + } + else /* Change colors only */ + { + /* Save the old geometry */ + cell *c = st->cells; + int n = st->ncells; + int s = st->sides; + int i; + + /* Protect it from being freed */ + st->cells = 0; + hexadrop_free_1 (st->dpy, st->window, st); + hexadrop_init_1 (dpy, window, st); + + /* Reset the old cells */ + for (i = 0; i < n; i++) + c[i].initted_p = False; + + /* Re-init, then put them back. */ + free (st->cells); + st->cells = c; + st->ncells = n; + st->sides = s; + } + return True; } @@ -408,6 +437,7 @@ static XrmOptionDescRec hexadrop_options [] = { { "-ncolors", ".ncolors", XrmoptionSepArg, 0 }, { "-uniform-speed", ".uniform", XrmoptionNoArg, "True" }, { "-no-uniform-speed",".uniform", XrmoptionNoArg, "False" }, + { "-nonuniform-speed",".uniform", XrmoptionNoArg, "False" }, { "-lockstep", ".lockstep", XrmoptionNoArg, "True" }, { "-no-lockstep", ".lockstep", XrmoptionNoArg, "False" }, { 0, 0, 0, 0 } -- cgit v1.2.3-55-g7522