src/SDL12_compat.c
changeset 19 bb548168a73b
parent 18 221a624a97fb
child 20 c4f19f562177
     1.1 --- a/src/SDL12_compat.c	Sun Mar 31 22:19:24 2013 -0400
     1.2 +++ b/src/SDL12_compat.c	Sun Mar 31 22:20:07 2013 -0400
     1.3 @@ -317,11 +317,11 @@
     1.4  } SDL12_Event;
     1.5  
     1.6  static SDL12_VideoInfo VideoInfo;
     1.7 -static SDL_Window *VideoWindow = NULL;
     1.8 -static SDL_Surface *WindowSurface = NULL;
     1.9 -static SDL_Surface *VideoSurface = NULL;
    1.10 -static SDL_Surface *ShadowSurface = NULL;
    1.11 -static SDL_Surface *PublicSurface = NULL;
    1.12 +static SDL_Window *VideoWindow20 = NULL;
    1.13 +static SDL12_Surface *WindowSurface = NULL;
    1.14 +static SDL12_Surface *VideoSurface = NULL;
    1.15 +static SDL12_Surface *ShadowSurface = NULL;
    1.16 +static SDL12_Surface *PublicSurface = NULL;
    1.17  static SDL_GLContext *VideoContext = NULL;
    1.18  static Uint32 VideoFlags = 0;
    1.19  static SDL_Rect VideoViewport;
    1.20 @@ -342,12 +342,15 @@
    1.21  
    1.22  /* Obviously we can't use SDL_LoadObject() to load SDL2.  :)  */
    1.23  #if defined(_WINDOWS)
    1.24 +    #define WIN32_LEAN_AND_MEAN 1
    1.25 +    #include <windows.h>
    1.26      #define SDL20_LIBNAME "SDL2.dll"
    1.27      static HANDLE Loaded_SDL20 = NULL;
    1.28      #define LoadSDL20Library() ((Loaded_SDL20 = LoadLibraryA(SDL20_LIBNAME)) != NULL)
    1.29      #define LookupSDL20Sym(sym) GetProcAddress(Loaded_SDL20, sym)
    1.30      #define CloseSDL20Library() { { if (Loaded_SDL20) { FreeLibrary(Loaded_SDL20); Loaded_SDL20 = NULL; } }
    1.31 -#elif defined(unix)
    1.32 +#elif defined(unix) || defined(__APPLE__)
    1.33 +    #include <dlfcn.h>
    1.34      #ifdef __APPLE__
    1.35      #define SDL20_LIBNAME "libSDL2.dylib"
    1.36      #else
    1.37 @@ -430,7 +433,7 @@
    1.38      if (!LoadSDL20())
    1.39          return -1;
    1.40  
    1.41 -    #define SETFLAG(x) if (sdl12flags & SDL12_INIT_##flag) sdl20flags |= SDL_INIT_##flag)
    1.42 +    #define SETFLAG(flag) if (sdl12flags & SDL12_INIT_##flag) sdl20flags |= SDL_INIT_##flag
    1.43      SETFLAG(TIMER);
    1.44      SETFLAG(AUDIO);
    1.45      SETFLAG(VIDEO);
    1.46 @@ -475,7 +478,7 @@
    1.47      Uint32 sdl20flags = 0;
    1.48      Uint32 extraflags = 0;
    1.49  
    1.50 -    #define SETFLAG(x) if (sdl12flags & SDL12_INIT_##flag) sdl20flags |= SDL_INIT_##flag)
    1.51 +    #define SETFLAG(flag) if (sdl12flags & SDL12_INIT_##flag) sdl20flags |= SDL_INIT_##flag
    1.52      SETFLAG(TIMER);
    1.53      SETFLAG(AUDIO);
    1.54      SETFLAG(VIDEO);
    1.55 @@ -497,7 +500,7 @@
    1.56  {
    1.57      Uint32 sdl20flags = 0;
    1.58  
    1.59 -    #define SETFLAG(x) if (sdl12flags & SDL12_INIT_##flag) sdl20flags |= SDL_INIT_##flag)
    1.60 +    #define SETFLAG(flag) if (sdl12flags & SDL12_INIT_##flag) sdl20flags |= SDL_INIT_##flag
    1.61      SETFLAG(TIMER);
    1.62      SETFLAG(AUDIO);
    1.63      SETFLAG(VIDEO);
    1.64 @@ -555,12 +558,12 @@
    1.65      }
    1.66  }
    1.67  
    1.68 -char *
    1.69 +const char *
    1.70  SDL_GetError(void)
    1.71  {
    1.72      if (!Loaded_SDL20)
    1.73      {
    1.74 -        static char noload_errstr[] = "Failed to load SDL 2.0 shared library";
    1.75 +        static const char noload_errstr[] = "Failed to load SDL 2.0 shared library";
    1.76          return noload_errstr;
    1.77      }
    1.78      return SDL20_GetError();
    1.79 @@ -1184,11 +1187,11 @@
    1.80              SDL20_MapRGB(ShadowSurface->format, 0, 0, 0));
    1.81      }
    1.82      SDL20_FillRect(WindowSurface, NULL, 0);
    1.83 -    SDL20_UpdateWindowSurface(VideoWindow);
    1.84 +    SDL20_UpdateWindowSurface(VideoWindow20);
    1.85  }
    1.86  
    1.87  static void
    1.88 -SetupScreenSaver(int flags)
    1.89 +SetupScreenSaver(int flags12)
    1.90  {
    1.91      const char *env;
    1.92      SDL_bool allow_screensaver;
    1.93 @@ -1197,7 +1200,7 @@
    1.94      env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER");
    1.95      if (env) {
    1.96          allow_screensaver = SDL_atoi(env) ? SDL_TRUE : SDL_FALSE;
    1.97 -    } else if (flags & SDL_FULLSCREEN) {
    1.98 +    } else if (flags12 & SDL12_FULLSCREEN) {
    1.99          allow_screensaver = SDL_FALSE;
   1.100      } else {
   1.101          allow_screensaver = SDL_TRUE;
   1.102 @@ -1210,7 +1213,7 @@
   1.103  }
   1.104  
   1.105  static int
   1.106 -ResizeVideoMode(int width, int height, int bpp, Uint32 flags)
   1.107 +ResizeVideoMode(int width, int height, int bpp, Uint32 flags12)
   1.108  {
   1.109      int w, h;
   1.110  
   1.111 @@ -1220,12 +1223,12 @@
   1.112      }
   1.113  
   1.114      /* We probably have to recreate the window in fullscreen mode */
   1.115 -    if (flags & SDL_FULLSCREEN) {
   1.116 +    if (flags12 & SDL12_FULLSCREEN) {
   1.117          return -1;
   1.118      }
   1.119  
   1.120      /* I don't think there's any change we can gracefully make in flags */
   1.121 -    if (flags != VideoFlags) {
   1.122 +    if (flags12 != VideoFlags) {
   1.123          return -1;
   1.124      }
   1.125      if (bpp != VideoSurface->format->BitsPerPixel) {
   1.126 @@ -1233,19 +1236,19 @@
   1.127      }
   1.128  
   1.129      /* Resize the window */
   1.130 -    SDL_GetWindowSize(VideoWindow, &w, &h);
   1.131 +    SDL20_GetWindowSize(VideoWindow20, &w, &h);
   1.132      if (w != width || h != height) {
   1.133 -        SDL_SetWindowSize(VideoWindow, width, height);
   1.134 +        SDL20_SetWindowSize(VideoWindow20, width, height);
   1.135      }
   1.136  
   1.137      /* If we're in OpenGL mode, just resize the stub surface and we're done! */
   1.138 -    if (flags & SDL_OPENGL) {
   1.139 +    if (flags12 & SDL12_OPENGL) {
   1.140          VideoSurface->w = width;
   1.141          VideoSurface->h = height;
   1.142          return 0;
   1.143      }
   1.144  
   1.145 -    WindowSurface = SDL_GetWindowSurface(VideoWindow);
   1.146 +    WindowSurface = SDL20_GetWindowSurface(VideoWindow20);
   1.147      if (!WindowSurface) {
   1.148          return -1;
   1.149      }
   1.150 @@ -1256,17 +1259,17 @@
   1.151      VideoSurface->h = height;
   1.152      VideoSurface->pixels = WindowSurface->pixels;
   1.153      VideoSurface->pitch = WindowSurface->pitch;
   1.154 -    SDL_SetClipRect(VideoSurface, NULL);
   1.155 +    SDL20_SetClipRect(VideoSurface, NULL);
   1.156  
   1.157      if (ShadowSurface) {
   1.158          ShadowSurface->w = width;
   1.159          ShadowSurface->h = height;
   1.160 -        ShadowSurface->pitch = SDL_CalculatePitch(ShadowSurface);
   1.161 +        ShadowSurface->pitch = SDL20_CalculatePitch(ShadowSurface);
   1.162          ShadowSurface->pixels =
   1.163 -            SDL_realloc(ShadowSurface->pixels,
   1.164 +            SDL20_realloc(ShadowSurface->pixels,
   1.165                          ShadowSurface->h * ShadowSurface->pitch);
   1.166 -        SDL_SetClipRect(ShadowSurface, NULL);
   1.167 -        SDL_InvalidateMap(ShadowSurface->map);
   1.168 +        SDL20_SetClipRect(ShadowSurface, NULL);
   1.169 +        SDL20_InvalidateMap(ShadowSurface->map);
   1.170      } else {
   1.171          PublicSurface = VideoSurface;
   1.172      }
   1.173 @@ -1277,7 +1280,7 @@
   1.174  }
   1.175  
   1.176  SDL_Surface *
   1.177 -SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
   1.178 +SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags12)
   1.179  {
   1.180      SDL_DisplayMode desktop_mode;
   1.181      int display = VideoDisplayIndex;
   1.182 @@ -1285,16 +1288,16 @@
   1.183      int window_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(display);
   1.184      int window_w;
   1.185      int window_h;
   1.186 -    Uint32 window_flags;
   1.187 -    Uint32 surface_flags;
   1.188 -
   1.189 -    if (!SDL_GetVideoDevice()) {
   1.190 -        if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) {
   1.191 +    Uint32 window_flags20;
   1.192 +    Uint32 surface_flags12;
   1.193 +
   1.194 +    if (!SDL20_WasInit(SDL_INIT_VIDEO)) {
   1.195 +        if (SDL_Init(SDL12_INIT_VIDEO | SDL12_INIT_NOPARACHUTE) < 0) {
   1.196              return NULL;
   1.197          }
   1.198      }
   1.199  
   1.200 -    SDL_GetDesktopDisplayMode(display, &desktop_mode);
   1.201 +    SDL20_GetDesktopDisplayMode(display, &desktop_mode);
   1.202  
   1.203      if (width == 0) {
   1.204          width = desktop_mode.w;
   1.205 @@ -1307,7 +1310,7 @@
   1.206      }
   1.207  
   1.208      /* See if we can simply resize the existing window and surface */
   1.209 -    if (ResizeVideoMode(width, height, bpp, flags) == 0) {
   1.210 +    if (ResizeVideoMode(width, height, bpp, flags12) == 0) {
   1.211          return PublicSurface;
   1.212      }
   1.213  
   1.214 @@ -1315,78 +1318,73 @@
   1.215      PublicSurface = NULL;
   1.216      if (ShadowSurface) {
   1.217          ShadowSurface->flags &= ~SDL_DONTFREE;
   1.218 -        SDL_FreeSurface(ShadowSurface);
   1.219 +        SDL20_FreeSurface(ShadowSurface);
   1.220          ShadowSurface = NULL;
   1.221      }
   1.222      if (VideoSurface) {
   1.223          VideoSurface->flags &= ~SDL_DONTFREE;
   1.224 -        SDL_FreeSurface(VideoSurface);
   1.225 +        SDL20_FreeSurface(VideoSurface);
   1.226          VideoSurface = NULL;
   1.227      }
   1.228      if (VideoContext) {
   1.229          /* SDL_GL_MakeCurrent(0, NULL); *//* Doesn't do anything */
   1.230 -        SDL_GL_DeleteContext(VideoContext);
   1.231 +        SDL20_GL_DeleteContext(VideoContext);
   1.232          VideoContext = NULL;
   1.233      }
   1.234 -    if (VideoWindow) {
   1.235 -        SDL_GetWindowPosition(VideoWindow, &window_x, &window_y);
   1.236 -        SDL_DestroyWindow(VideoWindow);
   1.237 +    if (VideoWindow20) {
   1.238 +        SDL20_GetWindowPosition(VideoWindow20, &window_x, &window_y);
   1.239 +        SDL20_DestroyWindow(VideoWindow20);
   1.240      }
   1.241  
   1.242 -    /* Set up the event filter */
   1.243 -    if (!SDL_GetEventFilter(NULL, NULL)) {
   1.244 -        SDL_SetEventFilter(SDL_CompatEventFilter, NULL);
   1.245 +    /* Create a new window */
   1.246 +    window_flags20 = SDL_WINDOW_SHOWN;
   1.247 +    if (flags12 & SDL12_FULLSCREEN) {
   1.248 +        window_flags20 |= SDL_WINDOW_FULLSCREEN;
   1.249      }
   1.250 -
   1.251 -    /* Create a new window */
   1.252 -    window_flags = SDL_WINDOW_SHOWN;
   1.253 -    if (flags & SDL_FULLSCREEN) {
   1.254 -        window_flags |= SDL_WINDOW_FULLSCREEN;
   1.255 +    if (flags12 & SDL12_OPENGL) {
   1.256 +        window_flags20 |= SDL_WINDOW_OPENGL;
   1.257      }
   1.258 -    if (flags & SDL_OPENGL) {
   1.259 -        window_flags |= SDL_WINDOW_OPENGL;
   1.260 +    if (flags12 & SDL12_RESIZABLE) {
   1.261 +        window_flags20 |= SDL_WINDOW_RESIZABLE;
   1.262      }
   1.263 -    if (flags & SDL_RESIZABLE) {
   1.264 -        window_flags |= SDL_WINDOW_RESIZABLE;
   1.265 -    }
   1.266 -    if (flags & SDL_NOFRAME) {
   1.267 -        window_flags |= SDL_WINDOW_BORDERLESS;
   1.268 +    if (flags12 & SDL12_NOFRAME) {
   1.269 +        window_flags20 |= SDL_WINDOW_BORDERLESS;
   1.270      }
   1.271      GetEnvironmentWindowPosition(width, height, &window_x, &window_y);
   1.272 -    VideoWindow =
   1.273 -        SDL_CreateWindow(WindowTitle, window_x, window_y, width, height,
   1.274 -                         window_flags);
   1.275 -    if (!VideoWindow) {
   1.276 +    VideoWindow20 =
   1.277 +        SDL20_CreateWindow(WindowTitle, window_x, window_y, width, height,
   1.278 +                         window_flags20);
   1.279 +    if (!VideoWindow20) {
   1.280          return NULL;
   1.281      }
   1.282 -    SDL_SetWindowIcon(VideoWindow, VideoIcon);
   1.283 -
   1.284 -    SetupScreenSaver(flags);
   1.285 -
   1.286 -    window_flags = SDL_GetWindowFlags(VideoWindow);
   1.287 -    surface_flags = 0;
   1.288 -    if (window_flags & SDL_WINDOW_FULLSCREEN) {
   1.289 -        surface_flags |= SDL_FULLSCREEN;
   1.290 +    SDL20_SetWindowIcon(VideoWindow20, VideoIcon);
   1.291 +
   1.292 +    SetupScreenSaver(flags12);
   1.293 +
   1.294 +    window_flags20 = SDL_GetWindowFlags(VideoWindow20);
   1.295 +    surface_flags12 = 0;
   1.296 +    if (window_flags20 & SDL_WINDOW_FULLSCREEN) {
   1.297 +        surface_flags12 |= SDL_FULLSCREEN;
   1.298      }
   1.299 -    if ((window_flags & SDL_WINDOW_OPENGL) && (flags & SDL_OPENGL)) {
   1.300 -        surface_flags |= SDL_OPENGL;
   1.301 +    if ((window_flags & SDL_WINDOW_OPENGL) && (flags12 & SDL_OPENGL)) {
   1.302 +        surface_flags12 |= SDL_OPENGL;
   1.303      }
   1.304      if (window_flags & SDL_WINDOW_RESIZABLE) {
   1.305 -        surface_flags |= SDL_RESIZABLE;
   1.306 +        surface_flags12 |= SDL_RESIZABLE;
   1.307      }
   1.308      if (window_flags & SDL_WINDOW_BORDERLESS) {
   1.309 -        surface_flags |= SDL_NOFRAME;
   1.310 +        surface_flags12 |= SDL_NOFRAME;
   1.311      }
   1.312  
   1.313 -    VideoFlags = flags;
   1.314 +    VideoFlags = flags12;
   1.315  
   1.316      /* If we're in OpenGL mode, just create a stub surface and we're done! */
   1.317 -    if (flags & SDL_OPENGL) {
   1.318 -        VideoContext = SDL_GL_CreateContext(VideoWindow);
   1.319 +    if (flags12 & SDL_OPENGL) {
   1.320 +        VideoContext = SDL_GL_CreateContext(VideoWindow20);
   1.321          if (!VideoContext) {
   1.322              return NULL;
   1.323          }
   1.324 -        if (SDL_GL_MakeCurrent(VideoWindow, VideoContext) < 0) {
   1.325 +        if (SDL_GL_MakeCurrent(VideoWindow20, VideoContext) < 0) {
   1.326              return NULL;
   1.327          }
   1.328          VideoSurface =
   1.329 @@ -1394,27 +1392,27 @@
   1.330          if (!VideoSurface) {
   1.331              return NULL;
   1.332          }
   1.333 -        VideoSurface->flags |= surface_flags;
   1.334 +        VideoSurface->flags |= surface_flags12;
   1.335          PublicSurface = VideoSurface;
   1.336          return PublicSurface;
   1.337      }
   1.338  
   1.339      /* Create the screen surface */
   1.340 -    WindowSurface = SDL_GetWindowSurface(VideoWindow);
   1.341 +    WindowSurface = SDL_GetWindowSurface(VideoWindow20);
   1.342      if (!WindowSurface) {
   1.343          return NULL;
   1.344      }
   1.345  
   1.346      /* Center the public surface in the window surface */
   1.347 -    SDL_GetWindowSize(VideoWindow, &window_w, &window_h);
   1.348 +    SDL_GetWindowSize(VideoWindow20, &window_w, &window_h);
   1.349      VideoViewport.x = (window_w - width)/2;
   1.350      VideoViewport.y = (window_h - height)/2;
   1.351      VideoViewport.w = width;
   1.352      VideoViewport.h = height;
   1.353  
   1.354      VideoSurface = SDL_CreateRGBSurfaceFrom(NULL, 0, 0, 32, 0, 0, 0, 0, 0);
   1.355 -    VideoSurface->flags |= surface_flags;
   1.356 -    VideoSurface->flags |= SDL_DONTFREE;
   1.357 +    VideoSurface->flags |= surface_flags12;
   1.358 +    VideoSurface->flags |= SDL12_DONTFREE;
   1.359      SDL_FreeFormat(VideoSurface->format);
   1.360      VideoSurface->format = WindowSurface->format;
   1.361      VideoSurface->format->refcount++;
   1.362 @@ -1428,18 +1426,18 @@
   1.363  
   1.364      /* Create a shadow surface if necessary */
   1.365      if ((bpp != VideoSurface->format->BitsPerPixel)
   1.366 -        && !(flags & SDL_ANYFORMAT)) {
   1.367 +        && !(flags12 & SDL12_ANYFORMAT)) {
   1.368          ShadowSurface =
   1.369              SDL_CreateRGBSurface(0, width, height, bpp, 0, 0, 0, 0);
   1.370          if (!ShadowSurface) {
   1.371              return NULL;
   1.372          }
   1.373 -        ShadowSurface->flags |= surface_flags;
   1.374 -        ShadowSurface->flags |= SDL_DONTFREE;
   1.375 +        ShadowSurface->flags |= surface_flags12;
   1.376 +        ShadowSurface->flags |= SDL12_DONTFREE;
   1.377  
   1.378          /* 8-bit ShadowSurface surfaces report that they have exclusive palette */
   1.379          if (ShadowSurface->format->palette) {
   1.380 -            ShadowSurface->flags |= SDL_HWPALETTE;
   1.381 +            ShadowSurface->flags |= SDL12_HWPALETTE;
   1.382              SDL_DitherColors(ShadowSurface->format->palette->colors,
   1.383                               ShadowSurface->format->BitsPerPixel);
   1.384          }
   1.385 @@ -1480,23 +1478,23 @@
   1.386      return 0;
   1.387  }
   1.388  
   1.389 -SDL_Surface *
   1.390 -SDL_DisplayFormat(SDL_Surface * surface)
   1.391 +SDL12_Surface *
   1.392 +SDL_DisplayFormat(SDL12_Surface *surface12)
   1.393  {
   1.394 -    SDL_PixelFormat *format;
   1.395 +    SDL12_PixelFormat *format;
   1.396  
   1.397      if (!PublicSurface) {
   1.398 -        SDL_SetError("No video mode has been set");
   1.399 +        SDL20_SetError("No video mode has been set");
   1.400          return NULL;
   1.401      }
   1.402      format = PublicSurface->format;
   1.403  
   1.404      /* Set the flags appropriate for copying to display surface */
   1.405 -    return SDL_ConvertSurface(surface, format, SDL_RLEACCEL);
   1.406 +    return SDL_ConvertSurface(surface, format, SDL12_RLEACCEL);
   1.407  }
   1.408  
   1.409 -SDL_Surface *
   1.410 -SDL_DisplayFormatAlpha(SDL_Surface * surface)
   1.411 +SDL12_Surface *
   1.412 +SDL_DisplayFormatAlpha(SDL12_Surface *surface)
   1.413  {
   1.414      SDL_PixelFormat *vf;
   1.415      SDL_PixelFormat *format;
   1.416 @@ -1603,10 +1601,10 @@
   1.417                  stackrect->w = rect->w;
   1.418                  stackrect->h = rect->h;
   1.419              }
   1.420 -            SDL_UpdateWindowSurfaceRects(VideoWindow, stackrects, numrects);
   1.421 +            SDL_UpdateWindowSurfaceRects(VideoWindow20, stackrects, numrects);
   1.422              SDL_stack_free(stackrects);
   1.423          } else {
   1.424 -            SDL_UpdateWindowSurfaceRects(VideoWindow, rects, numrects);
   1.425 +            SDL_UpdateWindowSurfaceRects(VideoWindow20, rects, numrects);
   1.426          }
   1.427      }
   1.428  }
   1.429 @@ -1622,7 +1620,7 @@
   1.430      }
   1.431      WindowTitle = title ? SDL_strdup(title) : NULL;
   1.432      WindowIconTitle = icon ? SDL_strdup(icon) : NULL;
   1.433 -    SDL_SetWindowTitle(VideoWindow, WindowTitle);
   1.434 +    SDL_SetWindowTitle(VideoWindow20, WindowTitle);
   1.435  }
   1.436  
   1.437  void
   1.438 @@ -1647,7 +1645,7 @@
   1.439  int
   1.440  SDL_WM_IconifyWindow(void)
   1.441  {
   1.442 -    SDL_MinimizeWindow(VideoWindow);
   1.443 +    SDL_MinimizeWindow(VideoWindow20);
   1.444      return 0;
   1.445  }
   1.446  
   1.447 @@ -1680,27 +1678,27 @@
   1.448      }
   1.449  
   1.450      /* Do the physical mode switch */
   1.451 -    if (SDL_GetWindowFlags(VideoWindow) & SDL_WINDOW_FULLSCREEN) {
   1.452 -        if (SDL_SetWindowFullscreen(VideoWindow, 0) < 0) {
   1.453 +    if (SDL_GetWindowFlags(VideoWindow20) & SDL_WINDOW_FULLSCREEN) {
   1.454 +        if (SDL_SetWindowFullscreen(VideoWindow20, 0) < 0) {
   1.455              return 0;
   1.456          }
   1.457          PublicSurface->flags &= ~SDL_FULLSCREEN;
   1.458      } else {
   1.459 -        if (SDL_SetWindowFullscreen(VideoWindow, 1) < 0) {
   1.460 +        if (SDL_SetWindowFullscreen(VideoWindow20, 1) < 0) {
   1.461              return 0;
   1.462          }
   1.463          PublicSurface->flags |= SDL_FULLSCREEN;
   1.464      }
   1.465  
   1.466      /* Recreate the screen surface */
   1.467 -    WindowSurface = SDL_GetWindowSurface(VideoWindow);
   1.468 +    WindowSurface = SDL_GetWindowSurface(VideoWindow20);
   1.469      if (!WindowSurface) {
   1.470          /* We're totally hosed... */
   1.471          return 0;
   1.472      }
   1.473  
   1.474      /* Center the public surface in the window surface */
   1.475 -    SDL_GetWindowSize(VideoWindow, &window_w, &window_h);
   1.476 +    SDL_GetWindowSize(VideoWindow20, &window_w, &window_h);
   1.477      VideoViewport.x = (window_w - VideoSurface->w)/2;
   1.478      VideoViewport.y = (window_h - VideoSurface->h)/2;
   1.479      VideoViewport.w = VideoSurface->w;
   1.480 @@ -1775,15 +1773,15 @@
   1.481  SDL_WM_GrabInput(SDL_GrabMode mode)
   1.482  {
   1.483      if (mode != SDL_GRAB_QUERY) {
   1.484 -        SDL_SetWindowGrab(VideoWindow, mode);
   1.485 +        SDL_SetWindowGrab(VideoWindow20, mode);
   1.486      }
   1.487 -    return (SDL_GrabMode) SDL_GetWindowGrab(VideoWindow);
   1.488 +    return (SDL_GrabMode) SDL_GetWindowGrab(VideoWindow20);
   1.489  }
   1.490  
   1.491  void
   1.492  SDL_WarpMouse(Uint16 x, Uint16 y)
   1.493  {
   1.494 -    SDL_WarpMouseInWindow(VideoWindow, x, y);
   1.495 +    SDL_WarpMouseInWindow(VideoWindow20, x, y);
   1.496  }
   1.497  
   1.498  Uint8
   1.499 @@ -1792,7 +1790,7 @@
   1.500      Uint8 state = 0;
   1.501      Uint32 flags = 0;
   1.502  
   1.503 -    flags = SDL_GetWindowFlags(VideoWindow);
   1.504 +    flags = SDL_GetWindowFlags(VideoWindow20);
   1.505      if ((flags & SDL_WINDOW_SHOWN) && !(flags & SDL_WINDOW_MINIMIZED)) {
   1.506          state |= SDL_APPACTIVE;
   1.507      }
   1.508 @@ -1835,7 +1833,7 @@
   1.509  int
   1.510  SDL_GetWMInfo(SDL_SysWMinfo * info)
   1.511  {
   1.512 -    return SDL_GetWindowWMInfo(VideoWindow, info);
   1.513 +    return SDL_GetWindowWMInfo(VideoWindow20, info);
   1.514  }
   1.515  
   1.516  #if 0
   1.517 @@ -2494,7 +2492,7 @@
   1.518                              pixels, display->pitch) < 0) {
   1.519          return -1;
   1.520      }
   1.521 -    SDL_UpdateWindowSurface(VideoWindow);
   1.522 +    SDL_UpdateWindowSurface(VideoWindow20);
   1.523      return 0;
   1.524  }
   1.525  
   1.526 @@ -2516,7 +2514,7 @@
   1.527  void
   1.528  SDL_GL_SwapBuffers(void)
   1.529  {
   1.530 -    SDL_GL_SwapWindow(VideoWindow);
   1.531 +    SDL_GL_SwapWindow(VideoWindow20);
   1.532  }
   1.533  
   1.534  int
   1.535 @@ -2537,19 +2535,19 @@
   1.536      } else {
   1.537          SDL_CalculateGammaRamp(blue, blue_ramp);
   1.538      }
   1.539 -    return SDL_SetWindowGammaRamp(VideoWindow, red_ramp, green_ramp, blue_ramp);
   1.540 +    return SDL_SetWindowGammaRamp(VideoWindow20, red_ramp, green_ramp, blue_ramp);
   1.541  }
   1.542  
   1.543  int
   1.544  SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green, const Uint16 * blue)
   1.545  {
   1.546 -    return SDL_SetWindowGammaRamp(VideoWindow, red, green, blue);
   1.547 +    return SDL_SetWindowGammaRamp(VideoWindow20, red, green, blue);
   1.548  }
   1.549  
   1.550  int
   1.551  SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue)
   1.552  {
   1.553 -    return SDL_GetWindowGammaRamp(VideoWindow, red, green, blue);
   1.554 +    return SDL_GetWindowGammaRamp(VideoWindow20, red, green, blue);
   1.555  }
   1.556  
   1.557  int
   1.558 @@ -2569,6 +2567,9 @@
   1.559      }
   1.560  }
   1.561  
   1.562 +
   1.563 +
   1.564 +
   1.565  int
   1.566  SDL_EnableUNICODE(int enable)
   1.567  {