X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fswirl.c;h=49529f6eace625348344374a7968245616883e96;hb=aa75c7476aeaa84cf3abc192b376a8b03c325213;hp=ba959ac692045fc483901291d73a469433863312;hpb=6f5482d73adb0165c0130bb47d852644ab0c4869;p=xscreensaver diff --git a/hacks/swirl.c b/hacks/swirl.c index ba959ac6..49529f6e 100644 --- a/hacks/swirl.c +++ b/hacks/swirl.c @@ -35,10 +35,10 @@ static const char sccsid[] = "@(#)swirl.c 4.00 97/01/01 xlockmore"; "*ncolors: 200 \n" \ "*useSHM: True \n" \ "*fpsSolid: true \n" \ + "*ignoreRotation: True \n" \ # define SMOOTH_COLORS # define WRITABLE_COLORS -# define swirl_handle_event 0 # include "xlockmore.h" /* from the xscreensaver distribution */ # ifdef HAVE_XSHM_EXTENSION # include "xshm.h" @@ -1352,82 +1352,81 @@ draw_swirl(ModeInfo * mi) if (swirl->drawing) { #ifdef STANDALONE if (mi->writable_p) - rotate_colors(MI_DISPLAY(mi), MI_COLORMAP(mi), + rotate_colors(mi->xgwa.screen, MI_COLORMAP(mi), swirl->rgb_values, swirl->colours, 1); #else /* !STANDALONE */ - /* rotate the colours */ - install_map(MI_DISPLAY(mi), swirl, swirl->dshift); + /* rotate the colours */ + install_map(MI_DISPLAY(mi), swirl, swirl->dshift); #endif /* !STANDALONE */ - /* draw a batch of points */ - swirl->batch_todo = BATCH_DRAW; - while ((swirl->batch_todo > 0) && swirl->drawing) { - /* draw a point */ - draw_point(mi, swirl); + /* draw a batch of points */ + swirl->batch_todo = BATCH_DRAW; + while ((swirl->batch_todo > 0) && swirl->drawing) { + /* draw a point */ + draw_point(mi, swirl); - /* move to the next point */ - next_point(swirl); + /* move to the next point */ + next_point(swirl); - /* done a point */ - swirl->batch_todo--; - } + /* done a point */ + swirl->batch_todo--; + } } else { #ifdef STANDALONE if (mi->writable_p) - rotate_colors(MI_DISPLAY(mi), MI_COLORMAP(mi), + rotate_colors(mi->xgwa.screen, MI_COLORMAP(mi), swirl->rgb_values, swirl->colours, 1); #else /* !STANDALONE */ - /* rotate the colours */ - install_map(MI_DISPLAY(mi), swirl, swirl->shift); + /* rotate the colours */ + install_map(MI_DISPLAY(mi), swirl, swirl->shift); #endif /* !STANDALONE */ - /* time for a higher resolution? */ - if (swirl->resolution > swirl->max_resolution) { - /* move to higher resolution */ - swirl->resolution--; - - /* calculate the pixel step for this resulution */ - swirl->r = (1 << (swirl->resolution - 1)); - - /* start drawing again */ - swirl->drawing = True; - - /* start in the middle of the screen */ - swirl->x = (swirl->width - swirl->r) / 2; - swirl->y = (swirl->height - swirl->r) / 2; - - /* initialise spiral drawing parameters */ - swirl->direction = DRAW_RIGHT; - swirl->dir_todo = 1; - swirl->dir_done = 0; - } else { - /* all done, decide when to restart */ - if (swirl->start_again == -1) { - /* start the counter */ - swirl->start_again = RESTART; - } else if (swirl->start_again == 0) { - /* reset the counter */ - swirl->start_again = -1; + /* time for a higher resolution? */ + if (swirl->resolution > swirl->max_resolution) { + /* move to higher resolution */ + swirl->resolution--; + + /* calculate the pixel step for this resulution */ + swirl->r = (1 << (swirl->resolution - 1)); + + /* start drawing again */ + swirl->drawing = True; + + /* start in the middle of the screen */ + swirl->x = (swirl->width - swirl->r) / 2; + swirl->y = (swirl->height - swirl->r) / 2; + + /* initialise spiral drawing parameters */ + swirl->direction = DRAW_RIGHT; + swirl->dir_todo = 1; + swirl->dir_done = 0; + } else { + /* all done, decide when to restart */ + if (swirl->start_again == -1) { + /* start the counter */ + swirl->start_again = RESTART; + } else if (swirl->start_again == 0) { + /* reset the counter */ + swirl->start_again = -1; #ifdef STANDALONE - /* Pick a new colormap! */ - XClearWindow (MI_DISPLAY(mi), MI_WINDOW(mi)); - free_colors (MI_DISPLAY(mi), MI_COLORMAP(mi), - mi->colors, mi->npixels); - make_smooth_colormap (MI_DISPLAY(mi), - MI_VISUAL(mi), - MI_COLORMAP(mi), - mi->colors, &mi->npixels, True, - &mi->writable_p, True); - swirl->colours = mi->npixels; + /* Pick a new colormap! */ + XClearWindow (MI_DISPLAY(mi), MI_WINDOW(mi)); + free_colors (mi->xgwa.screen, MI_COLORMAP(mi), + mi->colors, mi->npixels); + make_smooth_colormap (mi->xgwa.screen, MI_VISUAL(mi), + MI_COLORMAP(mi), + mi->colors, &mi->npixels, True, + &mi->writable_p, True); + swirl->colours = mi->npixels; #endif /* STANDALONE */ - /* start again */ - init_swirl(mi); - } else - /* decrement the counter */ - swirl->start_again--; - } + /* start again */ + init_swirl(mi); + } else + /* decrement the counter */ + swirl->start_again--; + } } } } @@ -1485,4 +1484,15 @@ refresh_swirl (ModeInfo * mi) } } +ENTRYPOINT Bool +swirl_handle_event (ModeInfo *mi, XEvent *event) +{ + if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event)) + { + reshape_swirl (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); + return True; + } + return False; +} + XSCREENSAVER_MODULE ("Swirl", swirl)