*/
XColor *
-Tk_GetColor(interp, tkwin, colormap, name)
- Tcl_Interp *interp; /* Place to leave error message if
+Tk_GetColor (
+ Tcl_Interp *interp, /* Place to leave error message if
* color can't be found. */
- Tk_Window tkwin; /* Window in which color will be used. */
- Colormap colormap; /* Map from which to allocate color. None
+ Tk_Window tkwin, /* Window in which color will be used. */
+ Colormap colormap, /* Map from which to allocate color. None
* means use default. */
- Tk_Uid name; /* Name of color to allocated (in form
+ Tk_Uid name /* Name of color to allocated (in form
* suitable for passing to XParseColor). */
+)
{
NameKey nameKey;
Tcl_HashEntry *nameHashPtr;
*/
XColor *
-Tk_GetColorByValue(interp, tkwin, colormap, colorPtr)
- Tcl_Interp *interp; /* Place to leave error message if
+Tk_GetColorByValue (
+ Tcl_Interp *interp, /* Place to leave error message if
* color can't be found. */
- Tk_Window tkwin; /* Window in which color will be used. */
- Colormap colormap; /* Map from which to allocate color. None
+ Tk_Window tkwin, /* Window in which color will be used. */
+ Colormap colormap, /* Map from which to allocate color. None
* means use default. */
- XColor *colorPtr; /* Red, green, and blue fields indicate
+ XColor *colorPtr /* Red, green, and blue fields indicate
* desired color. */
+)
{
ValueKey valueKey;
Tcl_HashEntry *valueHashPtr;
*/
char *
-Tk_NameOfColor(colorPtr)
- XColor *colorPtr; /* Color whose name is desired. */
+Tk_NameOfColor (
+ XColor *colorPtr /* Color whose name is desired. */
+)
{
register TkColor *tkColPtr = (TkColor *) colorPtr;
static char string[20];
*----------------------------------------------------------------------
*/
-void
-Tk_FreeColor(colorPtr)
- XColor *colorPtr; /* Color to be released. Must have been
+void
+Tk_FreeColor (
+ XColor *colorPtr /* Color to be released. Must have been
* allocated by Tk_GetColor or
* Tk_GetColorByValue. */
+)
{
register TkColor *tkColPtr = (TkColor *) colorPtr;
Visual *visual;
*----------------------------------------------------------------------
*/
-static void
-ColorInit()
+static void
+ColorInit (void)
{
initialized = 1;
Tcl_InitHashTable(&nameTable, sizeof(NameKey)/sizeof(int));
#else
scrnum = Tk_IndexOfScreen(screen);
vTemplate.screen = scrnum;
- vTemplate.depth = 8;
- vTemplate.class = PseudoColor;
+ vTemplate.class = TrueColor;
visualList =
XGetVisualInfo(DisplayOfScreen(screen),
VisualScreenMask |
- VisualDepthMask |
VisualClassMask,
&vTemplate, &visualsMatched);
- if (visualsMatched > 0) {
- info->visual = visualList[0].visual;
- info->depth = 8;
- info->pixmap = XCreatePixmap(screen->display,
- RootWindowOfScreen(screen),
- 1, 1, 8);
-//fprintf(stderr, "TK_CreateColormap %d\n", TK_CreateColormap);
- if ((TK_CreateColormap == 0) &&
- (info->visual == DefaultVisualOfScreen(screen))) {
- info->colormap = DefaultColormapOfScreen(screen);
- info->gc = DefaultGCOfScreen(screen);
- } else {
- info->colormap =
- XCreateColormap(screen->display,
- RootWindowOfScreen(screen),
- info->visual, AllocNone);
- info->gc =
- XCreateGC(screen->display,
- info->pixmap, 0, &values);
- }
- } else {
+ info->visual = NULL;
+
+ if (visualList != NULL) {
+ int i;
+ for (i = 0; i < visualsMatched; i++) {
+ if (visualList[i].depth > 24)
+ continue; /* Most likely broken */
+
+ info->visual = visualList[i].visual;
+ info->depth = visualList[i].depth;
+
+ break;
+ }
+ }
+
+ if (info->visual == NULL) {
info->visual = XDefaultVisualOfScreen(screen);
info->depth = XDefaultDepthOfScreen(screen);
- info->pixmap = XCreatePixmap(screen->display,
- RootWindowOfScreen(screen),
- 1, 1, info->depth);
info->colormap = XDefaultColormapOfScreen(screen);
info->gc = DefaultGCOfScreen(screen);
+
+ if (info->depth == 8) {
+ vTemplate.screen = scrnum;
+ vTemplate.class = PseudoColor;
+ vTemplate.depth = 8;
+ visualList = XGetVisualInfo(DisplayOfScreen(screen),
+ VisualScreenMask |
+ VisualDepthMask |
+ VisualClassMask,
+ &vTemplate, &visualsMatched);
+
+ if (visualsMatched > 0) {
+ info->visual = visualList[0].visual;
+ info->depth = visualList[0].depth;
+
+ }
+ }
+ }
+
+ info->pixmap = XCreatePixmap(screen->display,
+ RootWindowOfScreen(screen),
+ 1, 1, info->depth);
+
+ if ((TK_CreateColormap == 0) &&
+ (info->visual == DefaultVisualOfScreen(screen))) {
+ info->colormap = DefaultColormapOfScreen(screen);
+ info->gc = DefaultGCOfScreen(screen);
+ } else {
+ info->colormap =
+ XCreateColormap(screen->display,
+ RootWindowOfScreen(screen),
+ info->visual, AllocNone);
+ info->gc =
+ XCreateGC(screen->display,
+ info->pixmap, 0, &values);
}
XFree((char *)visualList);