1 //----------------------------------------------------------------------------
2 // This module contains code to interface original xlock savers to
7 #include <qapplication.h>
14 perscreen Scr
[MAXSCREENS
];
21 Dr. Park's algorithm published in the Oct. '88 ACM
22 "Random Number Generators: Good Ones Are Hard To Find"
23 His version available at ftp://cs.wm.edu/pub/rngs.tar
24 Present form by many authors.
27 static int Seed
= 1; /* This is required to be 32 bits long */
30 * Given an integer, this routine initializes the RNG seed.
38 * Returns an integer between 0 and 2147483647, inclusive.
42 if ((Seed
= Seed
% 44488 * 48271 - Seed
/ 44488 * 3399) < 0)
44 return (long) (Seed
- 1);
48 allocpixel(Colormap cmap
, const char *name
, const char *def
)
52 XParseColor(dsp
, cmap
, name
, &col
);
53 if (!XAllocColor(dsp
, cmap
, &col
))
55 fprintf(stderr
, "couldn't allocate: %s, using %s instead\n", name
, def
);
56 XAllocNamedColor(dsp
, cmap
, def
, &col
, &tmp
);
62 void initXLock( GC gc
)
66 dsp
= QX11Info::display();
67 screen
= qt_xscreen();
69 Screen
*scr
= ScreenOfDisplay(dsp
, screen
);
72 Scr
[0].npixels
= NUMCOLORS
;
75 Colormap cmap
= DefaultColormapOfScreen(scr
);
76 Scr
[0].bgcol
= allocpixel(cmap
, "background", "White");
77 Scr
[0].bgcol
= allocpixel(cmap
, "foreground", "Black");
81 for ( int i
= 0; i
< NUMCOLORS
; i
++ )
83 color
.setHsv( i
* 360 / NUMCOLORS
, 255, 255 );
84 Scr
[0].pixels
[i
] = color
.alloc();