X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fmaze.c;h=a0007ddb72eca06028567ba3230347a2a567dd07;hb=78add6e627ee5f10e1fa6f3852602ea5066eee5a;hp=8576386b2ae9c4aba0af4c135c21830fcef9ce89;hpb=f8cf5ac7b2f53510f80a0eaf286a25298be17bfe;p=xscreensaver diff --git a/hacks/maze.c b/hacks/maze.c index 8576386b..a0007ddb 100644 --- a/hacks/maze.c +++ b/hacks/maze.c @@ -89,14 +89,18 @@ #include "screenhack.h" #include "erase.h" +#include "ximage-loader.h" +#include "images/gen/logo-50_png.h" +#include "images/gen/logo-180_png.h" #include /* #include */ +/* #define gray1_width 2 #define gray1_height 2 static const char gray1_bits[] = { 0x01, 0x02 }; - +*/ #define MAX_MAZE_SIZE_X 1000 #define MAX_MAZE_SIZE_Y 1000 @@ -870,8 +874,10 @@ static int backup (struct state *st) /* back up a move */ { st->sqnum--; - st->cur_sq_x = st->move_list[st->sqnum].x; - st->cur_sq_y = st->move_list[st->sqnum].y; + if (st->sqnum >= 0) { + st->cur_sq_x = st->move_list[st->sqnum].x; + st->cur_sq_y = st->move_list[st->sqnum].y; + } return ( st->sqnum ); } @@ -1467,28 +1473,28 @@ maze_init (Display *dpy_arg, Window window_arg) XSetForeground (st->dpy, st->erase_gc, bg); XSetBackground (st->dpy, st->erase_gc, bg); +# ifdef HAVE_JWXYZ + jwxyz_XSetAntiAliasing (st->dpy, st->gc, False); +# endif + { - Window r; - int x, y; - unsigned int w, h, bbw, d; - unsigned long *pixels; - int npixels; Pixmap logo_mask = 0; - st->logo_map = xscreensaver_logo (xgwa.screen, xgwa.visual, st->window, - xgwa.colormap, bg, - &pixels, &npixels, &logo_mask, - xgwa.width > 800 || xgwa.height > 800); + if (xgwa.width > 900 || xgwa.height > 900) + st->logo_map = image_data_to_pixmap (st->dpy, st->window, + logo_180_png, sizeof(logo_180_png), + &st->logo_width, &st->logo_height, + &logo_mask); + else + st->logo_map = image_data_to_pixmap (st->dpy, st->window, + logo_50_png, sizeof(logo_50_png), + &st->logo_width, &st->logo_height, + &logo_mask); if (logo_mask) { XSetClipMask (st->dpy, st->logo_gc, logo_mask); XFreePixmap (st->dpy, logo_mask); } - if (pixels) free (pixels); - XGetGeometry (st->dpy, st->logo_map, &r, &x, &y, &w, &h, &bbw, &d); - st->logo_width = w; - st->logo_height = h; } - st->restart = 0; st->sync_p = 1; @@ -1588,6 +1594,9 @@ maze_draw (Display *dpy, Window window, void *closure) st->stop = 0; st->state = 1; + if (st->solve_state && st->solve_state->running) + st->solve_state->running = 0; + st->sync_p = ((random() % 4) != 0); size = get_integer_resource (st->dpy, "gridSize", "Dimension"); @@ -1608,9 +1617,8 @@ static Bool maze_event (Display *dpy, Window window, void *closure, XEvent *event) { struct state *st = (struct state *) closure; - switch (event->type) + if (event->type == ButtonPress) { - case ButtonPress: switch (event->xbutton.button) { case 2: @@ -1627,14 +1635,17 @@ maze_event (Display *dpy, Window window, void *closure, XEvent *event) st->stop = 0 ; return True; } - break; - - case Expose: + } + else if (event->type == Expose) + { st->restart = 1; - break; - - default: - break; + return False; + } + else if (screenhack_event_helper (dpy, window, event)) + { + st->restart = 1 ; + st->stop = 0 ; + return True; } return False; }