Mercurial > sdl-ios-xcode
diff src/video/x11/SDL_x11window.c @ 2185:2032348afed1
This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
available and to keep people form having to install yet another library I have added the essential parts of Xmu in
src/video/extensions/XmuStdCmap and an include file in src/video/extensions. The support makes use of standard X11 mechanisms to
create color maps and make sure that an application uses the same color map for each window/visual combination. This should make it
possible for gamma support to be implemented based on a single color map per application.
Hurm... it looks like "make indent" modified a few extra files. Those are getting committed too.
author | Bob Pendleton <bob@pendleton.com> |
---|---|
date | Thu, 12 Jul 2007 20:00:50 +0000 |
parents | e906da4414a3 |
children | 9462f4408ecb |
line wrap: on
line diff
--- a/src/video/x11/SDL_x11window.c Thu Jul 12 08:07:30 2007 +0000 +++ b/src/video/x11/SDL_x11window.c Thu Jul 12 20:00:50 2007 +0000 @@ -26,7 +26,7 @@ #include "../../events/SDL_keyboard_c.h" #include "SDL_x11video.h" - +#include "../Xext/extensions/StdCmap.h" static int SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) @@ -181,11 +181,40 @@ } xattr.background_pixel = 0; xattr.border_pixel = 0; - if (visual->class == PseudoColor || visual->class == DirectColor) { - xattr.colormap = - XCreateColormap(data->display, - RootWindow(data->display, displaydata->screen), - visual, AllocAll); + if (visual->class == DirectColor || visual->class == TrueColor) { + int nmaps; + XStandardColormap *stdmaps; + int i; + Bool found = False; + + if (0 != XGetRGBColormaps(data->display, + RootWindow(data->display, + displaydata->screen), &stdmaps, + &nmaps, XA_RGB_BEST_MAP)) { + for (i = 0; i < nmaps; i++) { + if (stdmaps[i].visualid == visual->visualid) { + xattr.colormap = stdmaps[i].colormap; + found = True; + break; + } + } + XFree(stdmaps); + } + if (!found) { + int max = visual->map_entries - 1; + XStandardColormap *cmap = + XmuStandardColormap(data->display, displaydata->screen, + visual->visualid, depth, + XA_RGB_BEST_MAP, None, + max, max, max); + if (cmap->visualid = visual->visualid) { + xattr.colormap = cmap->colormap; + } else { + SDL_SetError + ("Couldn't create window:XA_RGB_BEST_MAP not found"); + return -1; + } + } } else { xattr.colormap = XCreateColormap(data->display,