-void screenhack(Display *disp, Window win)
-{
- int iterations = 0;
- int delay = get_integer_resource("delay", "Integer");
- int rate = get_integer_resource("rate", "Integer");
- int box = get_integer_resource("box", "Integer");
- int oily = get_boolean_resource("oily", "Boolean");
- int stir = get_boolean_resource("stir", "Boolean");
- int fluidity = get_integer_resource("fluidity", "Integer");
- transparent = get_boolean_resource("water", "Boolean");
-#ifdef HAVE_XSHM_EXTENSION
- use_shm = get_boolean_resource("useSHM", "Boolean");
-#endif /* HAVE_XSHM_EXTENSION */
- light = get_integer_resource("light", "Integer");
-
- if (fluidity <= 1) fluidity = 1;
- if (fluidity > 16) fluidity = 16; /* 16 = sizeof(short) */
- if (light < 0) light = 0;
-
- init_cos_tab();
- setup_X(disp, win);
-
- ncolors = get_integer_resource ("colors", "Colors");
- if (0 == ncolors) /* English spelling? */
- ncolors = get_integer_resource ("colours", "Colors");
-
- if (ncolors > sizeof(ctab)/sizeof(*ctab))
- ncolors = sizeof(ctab)/sizeof(*ctab);
-
- if (oily)
- init_oily_colors();
- else
- init_linear_colors();
-
- if (transparent && light > 0) {
- int maxbits;
- draw_transparent = draw_transparent_light;
- set_mask(visual->red_mask, &rmask, &rshift);
- set_mask(visual->green_mask, &gmask, &gshift);
- set_mask(visual->blue_mask, &bmask, &bshift);
- if (rmask == 0) draw_transparent = draw_transparent_vanilla;
-
- /* Adjust the shift value "light" when we don't have 8 bits per colour */
- maxbits = MIN(MIN(BITCOUNT(rmask), BITCOUNT(gmask)), BITCOUNT(bmask));
- light -= 8-maxbits;
- if (light < 0) light = 0;
- } else
- draw_transparent = draw_transparent_vanilla;
-
- init_ripples(0, -SPLASH); /* Start off without any drops */
-
- /* Main drawing loop */
- while (1) {
- if (rate > 0 && (iterations % rate) == 0)
- add_drop(ripple_blob, -SPLASH);
- if (stir)
- add_drop(ripple_stir, -SPLASH);
- if (box > 0 && (random() % box) == 0)
- add_drop(ripple_box, -SPLASH);
-
- ripple(fluidity);
- DisplayImage();
-
- if (delay)
- usleep(delay);
-
- iterations++;
- }
-}