changeset 2945:e38423786728

Fixed DirectColor visual window creation problem
author Sam Lantinga <slouken@libsdl.org>
date Thu, 01 Jan 2009 18:58:26 +0000
parents 7dac01628a8b
children 29e1f863a844
files TODO src/video/x11/SDL_x11modes.c src/video/x11/SDL_x11window.c
diffstat 3 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/TODO	Thu Jan 01 18:49:43 2009 +0000
+++ b/TODO	Thu Jan 01 18:58:26 2009 +0000
@@ -7,7 +7,6 @@
  * Implement icon support (with translucency?)
  * Add diagonal line clipping to SDL_IntersectRectAndLine()
  * Add OpenGL 3.0 context support
- * Have Bob look at why DirectColor visuals fail with XA_RGB_BEST_MAP error
  * Verify mouse grab support
  * Properly handle mouse grab with Vista DPI scaling
  * Make sure the mouse is where it's supposed to be when un-grabbed
--- a/src/video/x11/SDL_x11modes.c	Thu Jan 01 18:49:43 2009 +0000
+++ b/src/video/x11/SDL_x11modes.c	Thu Jan 01 18:58:26 2009 +0000
@@ -32,13 +32,9 @@
 get_visualinfo(Display * display, int screen, XVisualInfo * vinfo)
 {
     const char *visual_id = SDL_getenv("SDL_VIDEO_X11_VISUALID");
-    /* FIXME FIXME FIXME
-     * Window creation fails in the colormap code on DirectColor visuals:
-     *      XA_RGB_BEST_MAP not found and could not be created
-     * I'm disabling this for now until Bob can look at it.  We don't need
-     * it until we implement the gamma fading using DirectColor RGB ramps
-     */
-    int use_directcolor = 0;
+    /* We really don't need DirectColor visuals until we implement
+     * gamma ramps, but we'll leave it on for now to catch bugs */
+    int use_directcolor = 1;
     int depth;
 
     /* Look for an exact visual, if requested */
--- a/src/video/x11/SDL_x11window.c	Thu Jan 01 18:49:43 2009 +0000
+++ b/src/video/x11/SDL_x11window.c	Thu Jan 01 18:58:26 2009 +0000
@@ -212,7 +212,7 @@
     xattr.background_pixel = 0;
     xattr.border_pixel = 0;
 
-    if (visual->class == DirectColor || visual->class == PseudoColor) {
+    if (visual->class == PseudoColor) {
         int nmaps;
         XStandardColormap cmap;
         XStandardColormap *stdmaps;
@@ -299,6 +299,12 @@
             X11_TrackColormap(data->display, displaydata->screen, colormap,
                               &cmap, visual);
         }
+    } else if (visual->class == DirectColor) {
+        /* FIXME: Allocate a read-write colormap for gamma fading someday */
+        xattr.colormap =
+            XCreateColormap(data->display,
+                            RootWindow(data->display, displaydata->screen),
+                            visual, AllocNone);
     } else {
         xattr.colormap =
             XCreateColormap(data->display,