X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fslip.c;h=04a306371f72d6d46aafc607fbec0a8a75927cc8;hb=39809ded547bdbb08207d3e514950425215b4410;hp=0c665ea76e178ce13d75cb73320be73f2281fcd1;hpb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;p=xscreensaver diff --git a/hacks/slip.c b/hacks/slip.c index 0c665ea7..04a30637 100644 --- a/hacks/slip.c +++ b/hacks/slip.c @@ -30,10 +30,12 @@ static const char sccsid[] = "@(#)slip.c 5.00 2000/11/01 xlockmore"; # define DEFAULTS "*delay: 50000 \n" \ "*count: 35 \n" \ "*cycles: 50 \n" \ - "*ncolors: 200 \n" + "*ncolors: 200 \n" \ + "*fpsSolid: true \n" \ + "*ignoreRotation: True \n" \ -# define refresh_slip 0 -# define slip_handle_event 0 +# define free_slip 0 +# define release_slip 0 # include "xlockmore.h" /* in xscreensaver distribution */ #else /* STANDALONE */ # include "xlock.h" /* in xlockmore distribution */ @@ -46,7 +48,7 @@ ENTRYPOINT ModeSpecOpt slip_opts = #ifdef USE_MODULES ModStruct slip_description = -{"slip", "init_slip", "draw_slip", "release_slip", +{"slip", "init_slip", "draw_slip", (char *) NULL, "init_slip", "init_slip", (char *) NULL, &slip_opts, 50000, 35, 50, 1, 64, 1.0, "", "Shows slipping blits", 0, NULL}; @@ -116,7 +118,7 @@ image_loaded_cb (Screen *screen, Window w, Drawable d, } #endif /* STANDALONE */ -static void +static Bool prepare_screen(ModeInfo * mi, slipstruct * sp) { @@ -127,12 +129,17 @@ prepare_screen(ModeInfo * mi, slipstruct * sp) sp->backwards = (int) (LRAND() & 1); /* jwz: go the other way sometimes */ - if (sp->first_time || !halfrandom(sp, 10)) { - MI_CLEARWINDOW(mi); + if (sp->first_time) { + XClearWindow (display, MI_WINDOW(mi)); n = 300; + } else if (!sp->image_loading_p && !halfrandom(sp, 10)) { + sp->first_time = 1; + sp->nblits_remaining = 0; + MI_CLEARWINDOW(mi); + return False; } else { if (halfrandom(sp, 5)) - return; + return True; if (halfrandom(sp, 5)) n = 100; else @@ -178,6 +185,8 @@ prepare_screen(ModeInfo * mi, slipstruct * sp) MI_WINDOW(mi), p, image_loaded_cb, mi); } #endif + + return True; } static int @@ -209,11 +218,7 @@ init_slip (ModeInfo * mi) { slipstruct *sp; - if (slips == NULL) { - if ((slips = (slipstruct *) calloc(MI_NUM_SCREENS(mi), - sizeof (slipstruct))) == NULL) - return; - } + MI_INIT (mi, slips); sp = &slips[MI_SCREEN(mi)]; sp->nblits_remaining = 0; @@ -241,8 +246,6 @@ draw_slip (ModeInfo * mi) timer = MI_COUNT(mi) * MI_CYCLES(mi); - MI_IS_DRAWN(mi) = True; - while (timer--) { int xi = halfrandom(sp, MAX(sp->width - sp->blit_width, 1)); int yi = halfrandom(sp, MAX(sp->height - sp->blit_height, 1)); @@ -251,7 +254,9 @@ draw_slip (ModeInfo * mi) if (0 == sp->nblits_remaining--) { static const int lut[] = {0, 0, 0, 1, 1, 1, 2}; - prepare_screen(mi, sp); + if (!prepare_screen(mi, sp)) + break; + MI_IS_DRAWN(mi) = True; sp->nblits_remaining = MI_COUNT(mi) * (2000 + halfrandom(sp, 1000) + halfrandom(sp, 1000)); if (sp->mode == 2) @@ -352,13 +357,17 @@ X Error of failed request: BadDrawable (invalid Pixmap or Window parameter) } } -ENTRYPOINT void -release_slip (ModeInfo * mi) +ENTRYPOINT Bool +slip_handle_event (ModeInfo *mi, XEvent *event) { - if (slips != NULL) { - (void) free((void *) slips); - slips = (slipstruct *) NULL; - } + slipstruct *sp = &slips[MI_SCREEN(mi)]; + if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event)) + { + sp->first_time = 1; + sp->nblits_remaining = 0; + return True; + } + return False; } XSCREENSAVER_MODULE ("Slip", slip)