comparison 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
comparison
equal deleted inserted replaced
2184:8f8516e79a13 2185:2032348afed1
24 #include "SDL_syswm.h" 24 #include "SDL_syswm.h"
25 #include "../SDL_sysvideo.h" 25 #include "../SDL_sysvideo.h"
26 #include "../../events/SDL_keyboard_c.h" 26 #include "../../events/SDL_keyboard_c.h"
27 27
28 #include "SDL_x11video.h" 28 #include "SDL_x11video.h"
29 29 #include "../Xext/extensions/StdCmap.h"
30 30
31 static int 31 static int
32 SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) 32 SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
33 { 33 {
34 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; 34 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
179 } else { 179 } else {
180 xattr.override_redirect = False; 180 xattr.override_redirect = False;
181 } 181 }
182 xattr.background_pixel = 0; 182 xattr.background_pixel = 0;
183 xattr.border_pixel = 0; 183 xattr.border_pixel = 0;
184 if (visual->class == PseudoColor || visual->class == DirectColor) { 184 if (visual->class == DirectColor || visual->class == TrueColor) {
185 xattr.colormap = 185 int nmaps;
186 XCreateColormap(data->display, 186 XStandardColormap *stdmaps;
187 RootWindow(data->display, displaydata->screen), 187 int i;
188 visual, AllocAll); 188 Bool found = False;
189
190 if (0 != XGetRGBColormaps(data->display,
191 RootWindow(data->display,
192 displaydata->screen), &stdmaps,
193 &nmaps, XA_RGB_BEST_MAP)) {
194 for (i = 0; i < nmaps; i++) {
195 if (stdmaps[i].visualid == visual->visualid) {
196 xattr.colormap = stdmaps[i].colormap;
197 found = True;
198 break;
199 }
200 }
201 XFree(stdmaps);
202 }
203 if (!found) {
204 int max = visual->map_entries - 1;
205 XStandardColormap *cmap =
206 XmuStandardColormap(data->display, displaydata->screen,
207 visual->visualid, depth,
208 XA_RGB_BEST_MAP, None,
209 max, max, max);
210 if (cmap->visualid = visual->visualid) {
211 xattr.colormap = cmap->colormap;
212 } else {
213 SDL_SetError
214 ("Couldn't create window:XA_RGB_BEST_MAP not found");
215 return -1;
216 }
217 }
189 } else { 218 } else {
190 xattr.colormap = 219 xattr.colormap =
191 XCreateColormap(data->display, 220 XCreateColormap(data->display,
192 RootWindow(data->display, displaydata->screen), 221 RootWindow(data->display, displaydata->screen),
193 visual, AllocNone); 222 visual, AllocNone);