- XGCValues gcValues;
- XWindowAttributes XWinAttribs;
- int bpp;
-
- /* Create the Image for drawing */
- XGetWindowAttributes( pDisplay, Win, &XWinAttribs );
-
- /* Find the preferred bits-per-pixel. */
- {
- int i, pfvc = 0;
- XPixmapFormatValues *pfv = XListPixmapFormats (pDisplay, &pfvc);
- for (i = 0; i < pfvc; i++)
- if (pfv[i].depth == XWinAttribs.depth)
- {
- bpp = pfv[i].bits_per_pixel;
- break;
- }
- if (pfv)
- XFree (pfv);
- }
-
- /* Create the GC. */
- *pGC = XCreateGC( pDisplay, Win, 0, &gcValues );
-
- memset (pXImage, 0, sizeof(*pXImage));
- pXImage->width = XWinAttribs.width; /* Width of image */
- pXImage->height = XWinAttribs.height; /* Height of image */
- pXImage->format = ZPixmap; /* XYBitmap, XYPixmap, ZPixmap */
-
- /* Pointer to image data */
- pXImage->byte_order = ImageByteOrder(pDisplay);
- pXImage->bitmap_unit = BitmapUnit(pDisplay);
- pXImage->bitmap_bit_order = BitmapBitOrder(pDisplay);
- pXImage->bitmap_pad = BitmapPad(pDisplay);
- pXImage->depth = XWinAttribs.depth;
- pXImage->bytes_per_line = 0; /* Accelerator to next line */
- pXImage->bits_per_pixel = bpp;
- XInitImage( pXImage );
- pXImage->data = calloc(pXImage->bytes_per_line, pXImage->height);
-
- /* These are precalculations used in Execute(). */
- nMaxExtentX = ( XWinAttribs.width / 2 ) - 20;
- nMaxExtentY = ( XWinAttribs.height / 2 ) - 20;
- nMinExtentX = nMaxExtentX / 3;
- nMinExtentY = nMaxExtentY / 3;
- nHalfWidth = ( XWinAttribs.width / 2 ) - 16;
- nHalfHeight = ( XWinAttribs.height / 2 ) - 16;
-
- /* Create the Sin and Cosine lookup tables. */
- nDegreeCount = get_integer_resource( "degrees", "Integer" );
- if( nDegreeCount < 90 ) nDegreeCount = 90;
- if( nDegreeCount > 5400 ) nDegreeCount = 5400;
- CreateTables( nDegreeCount );
-
- /* Get the colors. */
- sColor = get_string_resource( "color", "Color" );
- if( sColor == NULL)
- SetPalette( pDisplay, Win, "random", ncolorsP, aXColors );
- else
- SetPalette( pDisplay, Win, sColor, ncolorsP, aXColors );
+ XGCValues gcValues;
+ XWindowAttributes XWinAttribs;
+ /*int iBitsPerPixel;*/
+
+ /* Create the Image for drawing */
+ XGetWindowAttributes( st->dpy, st->window, &XWinAttribs );
+
+#if 0
+ /* Find the preferred bits-per-pixel. (jwz) */
+ {
+ int i, pfvc = 0;
+ XPixmapFormatValues *pfv = XListPixmapFormats( st->dpy, &pfvc );
+ for( i=0; i<pfvc; i++ )
+ if( pfv[ i ].depth == XWinAttribs.depth )
+ {
+ iBitsPerPixel = pfv[ i ].bits_per_pixel;
+ break;
+ }
+ if( pfv )
+ XFree (pfv);
+ }
+#endif
+
+ /* Create the GC. */
+ st->gc = XCreateGC( st->dpy, st->window, 0, &gcValues );
+
+ st->pImage = XCreateImage( st->dpy, XWinAttribs.visual, XWinAttribs.depth, ZPixmap, 0, NULL,
+ XWinAttribs.width, XWinAttribs.height, 8 /*BitmapPad( st->dpy )*/, 0 );
+ st->pImage->data = calloc((st->pImage)->bytes_per_line, (st->pImage)->height);
+
+ st->iWinWidth = XWinAttribs.width;
+ st->iWinHeight = XWinAttribs.height;
+
+ /* These are precalculations used in Execute(). */
+ st->iBobDiameter = ( ( st->iWinWidth < st->iWinHeight ) ? st->iWinWidth : st->iWinHeight ) / 25;
+ st->iBobRadius = st->iBobDiameter / 2;
+#ifdef VERBOSE
+ printf( "%s: Bob Diameter = %d\n", progname, st->iBobDiameter );
+#endif
+
+ st->iWinCenterX = ( XWinAttribs.width / 2 ) - st->iBobRadius;
+ st->iWinCenterY = ( XWinAttribs.height / 2 ) - st->iBobRadius;
+
+ st->iVelocity = ( ( st->iWinWidth < st->iWinHeight ) ? st->iWinWidth : st->iWinHeight ) / 150;
+
+ /* Create the Sin and Cosine lookup tables. */
+ st->iDegreeCount = get_integer_resource(st->dpy, "degrees", "Integer" );
+ if( st->iDegreeCount == 0 ) st->iDegreeCount = ( XWinAttribs.width / 6 ) + 400;
+ else if( st->iDegreeCount < 90 ) st->iDegreeCount = 90;
+ else if( st->iDegreeCount > 5400 ) st->iDegreeCount = 5400;
+ CreateTables( st, st->iDegreeCount );
+#ifdef VERBOSE
+ printf( "%s: Using a %d degree circle.\n", progname, st->iDegreeCount );
+#endif /* VERBOSE */
+
+ /* Get the base color. */
+ st->sColor = get_string_resource(st->dpy, "color", "Color" );