Work in progress on multi-display support:
authorSam Lantinga <slouken@libsdl.org>
Tue, 01 Dec 2009 05:57:15 +0000
changeset 35004b594623401b
parent 3499 4cf8a1423d57
child 3501 467e67d301f3
Work in progress on multi-display support:
* Added display parameter to many internal functions so video modes can be set on displays that aren't the public current one.
* The fullscreen mode is associated with fullscreen windows - not displays, so different windows more naturally have a mode associated with them based on their width and height. It's no longer necessary to specify a fullscreen mode, a default one will be picked automatically for fullscreen windows.
include/SDL_video.h
src/SDL_compat.c
src/video/SDL_gamma.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/cocoa/SDL_cocoamodes.h
src/video/cocoa/SDL_cocoamodes.m
src/video/directfb/SDL_DirectFB_modes.c
src/video/directfb/SDL_DirectFB_modes.h
src/video/directfb/SDL_DirectFB_render.c
src/video/directfb/SDL_DirectFB_video.c
src/video/pandora/SDL_pandora.c
src/video/photon/SDL_photon.c
src/video/photon/SDL_photon_input.c
src/video/photon/SDL_photon_render.c
src/video/ps3/SDL_ps3modes.c
src/video/ps3/SDL_ps3modes_c.h
src/video/qnxgf/SDL_gf_input.c
src/video/qnxgf/SDL_gf_render.c
src/video/qnxgf/SDL_qnxgf.c
src/video/win32/SDL_win32gamma.c
src/video/win32/SDL_win32gamma.h
src/video/win32/SDL_win32modes.c
src/video/win32/SDL_win32modes.h
src/video/x11/SDL_x11gamma.c
src/video/x11/SDL_x11gamma.h
src/video/x11/SDL_x11modes.c
src/video/x11/SDL_x11modes.h
test/common.c
     1.1 --- a/include/SDL_video.h	Mon Nov 30 21:04:25 2009 +0000
     1.2 +++ b/include/SDL_video.h	Tue Dec 01 05:57:15 2009 +0000
     1.3 @@ -50,7 +50,8 @@
     1.4   *  \sa SDL_GetDesktopDisplayMode()
     1.5   *  \sa SDL_GetCurrentDisplayMode()
     1.6   *  \sa SDL_GetClosestDisplayMode()
     1.7 - *  \sa SDL_SetDisplayMode()
     1.8 + *  \sa SDL_SetWindowDisplayMode()
     1.9 + *  \sa SDL_GetWindowDisplayMode()
    1.10   */
    1.11  typedef struct
    1.12  {
    1.13 @@ -427,23 +428,25 @@
    1.14  
    1.15  /**
    1.16   *  \brief Set the display mode used when a fullscreen window is visible
    1.17 - *         on the currently selected display.
    1.18 + *         on the currently selected display.  By default the window's
    1.19 + *         dimensions and the desktop format and refresh rate are used.
    1.20   *  
    1.21 - *  \param mode The mode to use, or NULL for the desktop mode.
    1.22 + *  \param mode The mode to use, or NULL for the default mode.
    1.23   *  
    1.24   *  \return 0 on success, or -1 if setting the display mode failed.
    1.25   *  
    1.26   *  \sa SDL_SetWindowFullscreen()
    1.27   */
    1.28 -extern DECLSPEC int SDLCALL SDL_SetFullscreenDisplayMode(const SDL_DisplayMode
    1.29 +extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_WindowID windowID,
    1.30 +                                                     const SDL_DisplayMode
    1.31                                                           * mode);
    1.32  
    1.33  /**
    1.34   *  \brief Fill in information about the display mode used when a fullscreen
    1.35   *         window is visible on the currently selected display.
    1.36   */
    1.37 -extern DECLSPEC int SDLCALL SDL_GetFullscreenDisplayMode(SDL_DisplayMode *
    1.38 -                                                         mode);
    1.39 +extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_WindowID windowID,
    1.40 +                                                     SDL_DisplayMode * mode);
    1.41  
    1.42  /**
    1.43   *  \brief Set the palette entries for indexed display modes.
    1.44 @@ -680,7 +683,7 @@
    1.45   *  
    1.46   *  \return 0 on success, or -1 if setting the display mode failed.
    1.47   *  
    1.48 - *  \sa SDL_SetFullscreenDisplayMode()
    1.49 + *  \sa SDL_WindowDisplayMode()
    1.50   */
    1.51  extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_WindowID windowID,
    1.52                                                      int fullscreen);
     2.1 --- a/src/SDL_compat.c	Mon Nov 30 21:04:25 2009 +0000
     2.2 +++ b/src/SDL_compat.c	Tue Dec 01 05:57:15 2009 +0000
     2.3 @@ -482,7 +482,6 @@
     2.4  SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
     2.5  {
     2.6      SDL_DisplayMode desktop_mode;
     2.7 -    SDL_DisplayMode mode;
     2.8      int window_x = SDL_WINDOWPOS_UNDEFINED;
     2.9      int window_y = SDL_WINDOWPOS_UNDEFINED;
    2.10      Uint32 window_flags;
    2.11 @@ -552,7 +551,6 @@
    2.12          window_flags |= SDL_WINDOW_BORDERLESS;
    2.13      }
    2.14      GetEnvironmentWindowPosition(width, height, &window_x, &window_y);
    2.15 -    SDL_SetFullscreenDisplayMode(NULL);
    2.16      SDL_VideoWindow =
    2.17          SDL_CreateWindow(wm_title, window_x, window_y, width, height,
    2.18                           window_flags);
    2.19 @@ -611,14 +609,14 @@
    2.20              return NULL;
    2.21          }
    2.22      }
    2.23 -    mode.format = desired_format;
    2.24 -    mode.w = width;
    2.25 -    mode.h = height;
    2.26 -    mode.refresh_rate = 0;
    2.27  
    2.28 -    /* Set the desired display mode */
    2.29 +    /* Set up the desired display mode */
    2.30      if (flags & SDL_FULLSCREEN) {
    2.31 -        if (SDL_SetFullscreenDisplayMode(&mode) < 0) {
    2.32 +        SDL_DisplayMode mode;
    2.33 +
    2.34 +        SDL_zero(mode);
    2.35 +        mode.format = desired_format;
    2.36 +        if (SDL_SetWindowDisplayMode(SDL_VideoWindow, &mode) < 0) {
    2.37              return NULL;
    2.38          }
    2.39      }
     3.1 --- a/src/video/SDL_gamma.c	Mon Nov 30 21:04:25 2009 +0000
     3.2 +++ b/src/video/SDL_gamma.c	Tue Dec 01 05:57:15 2009 +0000
     3.3 @@ -113,30 +113,39 @@
     3.4      return succeeded;
     3.5  }
     3.6  
     3.7 +static void
     3.8 +SDL_UninitializedVideo()
     3.9 +{
    3.10 +    SDL_SetError("Video subsystem has not been initialized");
    3.11 +}
    3.12 +
    3.13  int
    3.14 -SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green,
    3.15 -                 const Uint16 * blue)
    3.16 +SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue)
    3.17  {
    3.18      SDL_VideoDevice *_this = SDL_GetVideoDevice();
    3.19      int succeeded;
    3.20  
    3.21 +    if (!_this) {
    3.22 +        SDL_UninitializedVideo();
    3.23 +        return -1;
    3.24 +    }
    3.25 +
    3.26      /* Lazily allocate the gamma tables */
    3.27 -    if (!SDL_CurrentDisplay.gamma) {
    3.28 -        SDL_GetGammaRamp(NULL, NULL, NULL);
    3.29 +    if (!display->gamma) {
    3.30 +        if (SDL_GetGammaRampForDisplay(display, NULL, NULL, NULL) < 0) {
    3.31 +            return -1;
    3.32 +        }
    3.33      }
    3.34  
    3.35      /* Fill the gamma table with the new values */
    3.36      if (red) {
    3.37 -        SDL_memcpy(&SDL_CurrentDisplay.gamma[0 * 256], red,
    3.38 -                   256 * sizeof(*SDL_CurrentDisplay.gamma));
    3.39 +        SDL_memcpy(&display->gamma[0 * 256], red, 256 * sizeof(*display->gamma));
    3.40      }
    3.41      if (green) {
    3.42 -        SDL_memcpy(&SDL_CurrentDisplay.gamma[1 * 256], green,
    3.43 -                   256 * sizeof(*SDL_CurrentDisplay.gamma));
    3.44 +        SDL_memcpy(&display->gamma[1 * 256], green, 256 * sizeof(*display->gamma));
    3.45      }
    3.46      if (blue) {
    3.47 -        SDL_memcpy(&SDL_CurrentDisplay.gamma[2 * 256], blue,
    3.48 -                   256 * sizeof(*SDL_CurrentDisplay.gamma));
    3.49 +        SDL_memcpy(&display->gamma[2 * 256], blue, 256 * sizeof(*display->gamma));
    3.50      }
    3.51  
    3.52      /* Try to set the gamma ramp in the driver */
    3.53 @@ -144,7 +153,7 @@
    3.54      if (_this && _this->SetDisplayGammaRamp) {
    3.55          if (SDL_GetFocusWindow()) {
    3.56              succeeded =
    3.57 -                _this->SetDisplayGammaRamp(_this, SDL_CurrentDisplay.gamma);
    3.58 +                _this->SetDisplayGammaRamp(_this, display, display->gamma);
    3.59          } else {
    3.60              succeeded = 0;
    3.61          }
    3.62 @@ -155,50 +164,73 @@
    3.63  }
    3.64  
    3.65  int
    3.66 -SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue)
    3.67 +SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green, const Uint16 * blue)
    3.68 +{
    3.69 +    SDL_VideoDevice *_this = SDL_GetVideoDevice();
    3.70 +    if (!_this) {
    3.71 +        SDL_UninitializedVideo();
    3.72 +        return -1;
    3.73 +    }
    3.74 +    return SDL_SetGammaRampForDisplay(&SDL_CurrentDisplay, red, green, blue);
    3.75 +}
    3.76 +
    3.77 +int
    3.78 +SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue)
    3.79  {
    3.80      SDL_VideoDevice *_this = SDL_GetVideoDevice();
    3.81  
    3.82 +    if (!_this) {
    3.83 +        SDL_UninitializedVideo();
    3.84 +        return -1;
    3.85 +    }
    3.86 +
    3.87      /* Lazily allocate the gamma table */
    3.88 -    if (!SDL_CurrentDisplay.gamma) {
    3.89 -        size_t rampsize = (3 * 256 * sizeof(*SDL_CurrentDisplay.gamma));
    3.90 +    if (!display->gamma) {
    3.91 +        size_t rampsize = (3 * 256 * sizeof(*display->gamma));
    3.92  
    3.93 -        SDL_CurrentDisplay.gamma = SDL_malloc(rampsize * 2);
    3.94 -        if (!SDL_CurrentDisplay.gamma) {
    3.95 +        display->gamma = SDL_malloc(rampsize * 2);
    3.96 +        if (!display->gamma) {
    3.97              SDL_OutOfMemory();
    3.98              return -1;
    3.99          }
   3.100          if (_this && _this->GetDisplayGammaRamp) {
   3.101              /* Get the real hardware gamma */
   3.102 -            _this->GetDisplayGammaRamp(_this, SDL_CurrentDisplay.gamma);
   3.103 +            _this->GetDisplayGammaRamp(_this, display, display->gamma);
   3.104          } else {
   3.105              /* Assume an identity gamma */
   3.106              int i;
   3.107              for (i = 0; i < 256; ++i) {
   3.108 -                SDL_CurrentDisplay.gamma[0 * 256 + i] = (i << 8) | i;
   3.109 -                SDL_CurrentDisplay.gamma[1 * 256 + i] = (i << 8) | i;
   3.110 -                SDL_CurrentDisplay.gamma[2 * 256 + i] = (i << 8) | i;
   3.111 +                display->gamma[0 * 256 + i] = (i << 8) | i;
   3.112 +                display->gamma[1 * 256 + i] = (i << 8) | i;
   3.113 +                display->gamma[2 * 256 + i] = (i << 8) | i;
   3.114              }
   3.115          }
   3.116 -        SDL_CurrentDisplay.saved_gamma = SDL_CurrentDisplay.gamma + (3 * 256);
   3.117 -        SDL_memcpy(SDL_CurrentDisplay.saved_gamma, SDL_CurrentDisplay.gamma,
   3.118 -                   rampsize);
   3.119 +        display->saved_gamma = display->gamma + (3 * 256);
   3.120 +        SDL_memcpy(display->saved_gamma, display->gamma, rampsize);
   3.121      }
   3.122  
   3.123      /* Just copy from our internal table */
   3.124      if (red) {
   3.125 -        SDL_memcpy(red, &SDL_CurrentDisplay.gamma[0 * 256],
   3.126 -                   256 * sizeof(*red));
   3.127 +        SDL_memcpy(red, &display->gamma[0 * 256], 256 * sizeof(*red));
   3.128      }
   3.129      if (green) {
   3.130 -        SDL_memcpy(green, &SDL_CurrentDisplay.gamma[1 * 256],
   3.131 -                   256 * sizeof(*green));
   3.132 +        SDL_memcpy(green, &display->gamma[1 * 256], 256 * sizeof(*green));
   3.133      }
   3.134      if (blue) {
   3.135 -        SDL_memcpy(blue, &SDL_CurrentDisplay.gamma[2 * 256],
   3.136 -                   256 * sizeof(*blue));
   3.137 +        SDL_memcpy(blue, &display->gamma[2 * 256], 256 * sizeof(*blue));
   3.138      }
   3.139      return 0;
   3.140  }
   3.141  
   3.142 +int
   3.143 +SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue)
   3.144 +{
   3.145 +    SDL_VideoDevice *_this = SDL_GetVideoDevice();
   3.146 +    if (!_this) {
   3.147 +        SDL_UninitializedVideo();
   3.148 +        return -1;
   3.149 +    }
   3.150 +    return SDL_GetGammaRampForDisplay(&SDL_CurrentDisplay, red, green, blue);
   3.151 +}
   3.152 +
   3.153  /* vi: set ts=4 sw=4 expandtab: */
     4.1 --- a/src/video/SDL_sysvideo.h	Mon Nov 30 21:04:25 2009 +0000
     4.2 +++ b/src/video/SDL_sysvideo.h	Tue Dec 01 05:57:15 2009 +0000
     4.3 @@ -139,6 +139,8 @@
     4.4      int display;
     4.5      SDL_Renderer *renderer;
     4.6  
     4.7 +    SDL_DisplayMode fullscreen_mode;
     4.8 +
     4.9      void *userdata;
    4.10      void *driverdata;
    4.11  };
    4.12 @@ -158,7 +160,6 @@
    4.13      SDL_DisplayMode *display_modes;
    4.14      SDL_DisplayMode desktop_mode;
    4.15      SDL_DisplayMode current_mode;
    4.16 -    SDL_DisplayMode fullscreen_mode;
    4.17      SDL_Palette *palette;
    4.18  
    4.19      Uint16 *gamma;
    4.20 @@ -213,7 +214,7 @@
    4.21       * Get a list of the available display modes. e.g.
    4.22       * SDL_AddDisplayMode(_this->current_display, mode)
    4.23       */
    4.24 -    void (*GetDisplayModes) (_THIS);
    4.25 +    void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display);
    4.26  
    4.27      /*
    4.28       * Setting the display mode is independent of creating windows, so
    4.29 @@ -221,19 +222,19 @@
    4.30       * their data updated accordingly, including the display surfaces
    4.31       * associated with them.
    4.32       */
    4.33 -    int (*SetDisplayMode) (_THIS, SDL_DisplayMode * mode);
    4.34 +    int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    4.35  
    4.36      /* Set the color entries of the display palette */
    4.37 -    int (*SetDisplayPalette) (_THIS, SDL_Palette * palette);
    4.38 +    int (*SetDisplayPalette) (_THIS, SDL_VideoDisplay * display, SDL_Palette * palette);
    4.39  
    4.40      /* Get the color entries of the display palette */
    4.41 -    int (*GetDisplayPalette) (_THIS, SDL_Palette * palette);
    4.42 +    int (*GetDisplayPalette) (_THIS, SDL_VideoDisplay * display, SDL_Palette * palette);
    4.43  
    4.44      /* Set the gamma ramp */
    4.45 -    int (*SetDisplayGammaRamp) (_THIS, Uint16 * ramp);
    4.46 +    int (*SetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
    4.47  
    4.48      /* Get the gamma ramp */
    4.49 -    int (*GetDisplayGammaRamp) (_THIS, Uint16 * ramp);
    4.50 +    int (*GetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
    4.51  
    4.52      /* * * */
    4.53      /*
    4.54 @@ -405,10 +406,19 @@
    4.55  extern SDL_VideoDevice *SDL_GetVideoDevice();
    4.56  extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
    4.57  extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
    4.58 -extern SDL_bool
    4.59 -SDL_AddDisplayMode(int displayIndex, const SDL_DisplayMode * mode);
    4.60 -extern void
    4.61 -SDL_AddRenderDriver(int displayIndex, const SDL_RenderDriver * driver);
    4.62 +extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
    4.63 +extern int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display);
    4.64 +extern int SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayMode * mode);
    4.65 +extern int SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    4.66 +extern int SDL_GetCurrentDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    4.67 +extern SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
    4.68 +extern int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode);
    4.69 +extern int SDL_SetDisplayPaletteForDisplay(SDL_VideoDisplay * display, const SDL_Color * colors, int firstcolor, int ncolors);
    4.70 +extern int SDL_GetDisplayPaletteForDisplay(SDL_VideoDisplay * display, SDL_Color * colors, int firstcolor, int ncolors);
    4.71 +extern void SDL_AddRenderDriver(SDL_VideoDisplay *display, const SDL_RenderDriver * driver);
    4.72 +
    4.73 +extern int SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue);
    4.74 +extern int SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue);
    4.75  
    4.76  extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
    4.77  extern SDL_Window *SDL_GetWindowFromID(SDL_WindowID windowID);
     5.1 --- a/src/video/SDL_video.c	Mon Nov 30 21:04:25 2009 +0000
     5.2 +++ b/src/video/SDL_video.c	Tue Dec 01 05:57:15 2009 +0000
     5.3 @@ -256,16 +256,17 @@
     5.4      }
     5.5      /* The software renderer is always available */
     5.6      for (i = 0; i < _this->num_displays; ++i) {
     5.7 +        SDL_VideoDisplay *display = &_this->displays[i];
     5.8          if (_this->GL_CreateContext) {
     5.9  #if SDL_VIDEO_RENDER_OGL
    5.10 -            SDL_AddRenderDriver(i, &GL_RenderDriver);
    5.11 +            SDL_AddRenderDriver(display, &GL_RenderDriver);
    5.12  #endif
    5.13  #if SDL_VIDEO_RENDER_OGL_ES
    5.14 -            SDL_AddRenderDriver(i, &GL_ES_RenderDriver);
    5.15 +            SDL_AddRenderDriver(display, &GL_ES_RenderDriver);
    5.16  #endif
    5.17          }
    5.18 -        if (_this->displays[i].num_render_drivers > 0) {
    5.19 -            SDL_AddRenderDriver(i, &SW_RenderDriver);
    5.20 +        if (display->num_render_drivers > 0) {
    5.21 +            SDL_AddRenderDriver(display, &SW_RenderDriver);
    5.22          }
    5.23      }
    5.24  
    5.25 @@ -360,9 +361,8 @@
    5.26  }
    5.27  
    5.28  SDL_bool
    5.29 -SDL_AddDisplayMode(int displayIndex, const SDL_DisplayMode * mode)
    5.30 +SDL_AddDisplayMode(SDL_VideoDisplay * display,  const SDL_DisplayMode * mode)
    5.31  {
    5.32 -    SDL_VideoDisplay *display = &_this->displays[displayIndex];
    5.33      SDL_DisplayMode *modes;
    5.34      int i, nmodes;
    5.35  
    5.36 @@ -397,16 +397,35 @@
    5.37  }
    5.38  
    5.39  int
    5.40 +SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display)
    5.41 +{
    5.42 +    if (!display->num_display_modes && _this->GetDisplayModes) {
    5.43 +        _this->GetDisplayModes(_this, display);
    5.44 +        SDL_qsort(display->display_modes, display->num_display_modes,
    5.45 +                  sizeof(SDL_DisplayMode), cmpmodes);
    5.46 +    }
    5.47 +    return display->num_display_modes;
    5.48 +}
    5.49 +
    5.50 +int
    5.51  SDL_GetNumDisplayModes()
    5.52  {
    5.53      if (_this) {
    5.54 -        SDL_VideoDisplay *display = &SDL_CurrentDisplay;
    5.55 -        if (!display->num_display_modes && _this->GetDisplayModes) {
    5.56 -            _this->GetDisplayModes(_this);
    5.57 -            SDL_qsort(display->display_modes, display->num_display_modes,
    5.58 -                      sizeof(SDL_DisplayMode), cmpmodes);
    5.59 -        }
    5.60 -        return display->num_display_modes;
    5.61 +        return SDL_GetNumDisplayModesForDisplay(&SDL_CurrentDisplay);
    5.62 +    }
    5.63 +    return 0;
    5.64 +}
    5.65 +
    5.66 +int
    5.67 +SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayMode * mode)
    5.68 +{
    5.69 +    if (index < 0 || index >= SDL_GetNumDisplayModesForDisplay(display)) {
    5.70 +        SDL_SetError("index must be in the range of 0 - %d",
    5.71 +                     SDL_GetNumDisplayModesForDisplay(display) - 1);
    5.72 +        return -1;
    5.73 +    }
    5.74 +    if (mode) {
    5.75 +        *mode = display->display_modes[index];
    5.76      }
    5.77      return 0;
    5.78  }
    5.79 @@ -414,13 +433,14 @@
    5.80  int
    5.81  SDL_GetDisplayMode(int index, SDL_DisplayMode * mode)
    5.82  {
    5.83 -    if (index < 0 || index >= SDL_GetNumDisplayModes()) {
    5.84 -        SDL_SetError("index must be in the range of 0 - %d",
    5.85 -                     SDL_GetNumDisplayModes() - 1);
    5.86 -        return -1;
    5.87 -    }
    5.88 +    return SDL_GetDisplayModeForDisplay(&SDL_CurrentDisplay, index, mode);
    5.89 +}
    5.90 +
    5.91 +int
    5.92 +SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode)
    5.93 +{
    5.94      if (mode) {
    5.95 -        *mode = SDL_CurrentDisplay.display_modes[index];
    5.96 +        *mode = display->desktop_mode;
    5.97      }
    5.98      return 0;
    5.99  }
   5.100 @@ -432,8 +452,14 @@
   5.101          SDL_UninitializedVideo();
   5.102          return -1;
   5.103      }
   5.104 +    return SDL_GetDesktopDisplayModeForDisplay(&SDL_CurrentDisplay, mode);
   5.105 +}
   5.106 +
   5.107 +int
   5.108 +SDL_GetCurrentDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode)
   5.109 +{
   5.110      if (mode) {
   5.111 -        *mode = SDL_CurrentDisplay.desktop_mode;
   5.112 +        *mode = display->current_mode;
   5.113      }
   5.114      return 0;
   5.115  }
   5.116 @@ -445,41 +471,41 @@
   5.117          SDL_UninitializedVideo();
   5.118          return -1;
   5.119      }
   5.120 -    if (mode) {
   5.121 -        *mode = SDL_CurrentDisplay.current_mode;
   5.122 -    }
   5.123 -    return 0;
   5.124 +    return SDL_GetCurrentDisplayModeForDisplay(&SDL_CurrentDisplay, mode);
   5.125  }
   5.126  
   5.127  SDL_DisplayMode *
   5.128 -SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode,
   5.129 -                          SDL_DisplayMode * closest)
   5.130 +SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display,
   5.131 +                                    const SDL_DisplayMode * mode,
   5.132 +                                    SDL_DisplayMode * closest)
   5.133  {
   5.134      Uint32 target_format;
   5.135      int target_refresh_rate;
   5.136      int i;
   5.137      SDL_DisplayMode *current, *match;
   5.138  
   5.139 -    if (!_this || !mode || !closest) {
   5.140 +    if (!mode || !closest) {
   5.141 +        SDL_SetError("Missing desired mode or closest mode parameter");
   5.142          return NULL;
   5.143      }
   5.144 +
   5.145      /* Default to the desktop format */
   5.146      if (mode->format) {
   5.147          target_format = mode->format;
   5.148      } else {
   5.149 -        target_format = SDL_CurrentDisplay.desktop_mode.format;
   5.150 +        target_format = display->desktop_mode.format;
   5.151      }
   5.152  
   5.153      /* Default to the desktop refresh rate */
   5.154      if (mode->refresh_rate) {
   5.155          target_refresh_rate = mode->refresh_rate;
   5.156      } else {
   5.157 -        target_refresh_rate = SDL_CurrentDisplay.desktop_mode.refresh_rate;
   5.158 +        target_refresh_rate = display->desktop_mode.refresh_rate;
   5.159      }
   5.160  
   5.161      match = NULL;
   5.162 -    for (i = 0; i < SDL_GetNumDisplayModes(); ++i) {
   5.163 -        current = &SDL_CurrentDisplay.display_modes[i];
   5.164 +    for (i = 0; i < SDL_GetNumDisplayModesForDisplay(display); ++i) {
   5.165 +        current = &display->display_modes[i];
   5.166  
   5.167          if (current->w && (current->w < mode->w)) {
   5.168              /* Out of sorted modes large enough here */
   5.169 @@ -555,19 +581,24 @@
   5.170      return NULL;
   5.171  }
   5.172  
   5.173 +SDL_DisplayMode *
   5.174 +SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode,
   5.175 +                          SDL_DisplayMode * closest)
   5.176 +{
   5.177 +    if (!_this) {
   5.178 +        SDL_UninitializedVideo();
   5.179 +        return NULL;
   5.180 +    }
   5.181 +    return SDL_GetClosestDisplayModeForDisplay(&SDL_CurrentDisplay, mode, closest);
   5.182 +}
   5.183 +
   5.184  int
   5.185 -SDL_SetDisplayMode(const SDL_DisplayMode * mode)
   5.186 +SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode)
   5.187  {
   5.188 -    SDL_VideoDisplay *display;
   5.189      SDL_DisplayMode display_mode;
   5.190      SDL_DisplayMode current_mode;
   5.191      int i, ncolors;
   5.192  
   5.193 -    if (!_this) {
   5.194 -        SDL_UninitializedVideo();
   5.195 -        return -1;
   5.196 -    }
   5.197 -    display = &SDL_CurrentDisplay;
   5.198      if (!mode) {
   5.199          mode = &display->desktop_mode;
   5.200      }
   5.201 @@ -586,19 +617,22 @@
   5.202      if (!display_mode.refresh_rate) {
   5.203          display_mode.refresh_rate = display->current_mode.refresh_rate;
   5.204      }
   5.205 +
   5.206      /* Get a good video mode, the closest one possible */
   5.207 -    if (!SDL_GetClosestDisplayMode(&display_mode, &display_mode)) {
   5.208 +    if (!SDL_GetClosestDisplayModeForDisplay(display, &display_mode, &display_mode)) {
   5.209          SDL_SetError("No video mode large enough for %dx%d",
   5.210                       display_mode.w, display_mode.h);
   5.211          return -1;
   5.212      }
   5.213 +
   5.214      /* See if there's anything left to do */
   5.215 -    SDL_GetCurrentDisplayMode(&current_mode);
   5.216 +    SDL_GetCurrentDisplayModeForDisplay(display, &current_mode);
   5.217      if (SDL_memcmp(&display_mode, &current_mode, sizeof(display_mode)) == 0) {
   5.218          return 0;
   5.219      }
   5.220 +
   5.221      /* Actually change the display mode */
   5.222 -    if (_this->SetDisplayMode(_this, &display_mode) < 0) {
   5.223 +    if (_this->SetDisplayMode(_this, display, &display_mode) < 0) {
   5.224          return -1;
   5.225      }
   5.226      display->current_mode = display_mode;
   5.227 @@ -624,96 +658,115 @@
   5.228                               SDL_BITSPERPIXEL(display_mode.format));
   5.229          }
   5.230      }
   5.231 -    /* Move any fullscreen windows into position */
   5.232 -    for (i = 0; i < display->num_windows; ++i) {
   5.233 -        SDL_Window *window = &display->windows[i];
   5.234 -        if (FULLSCREEN_VISIBLE(window)) {
   5.235 -            SDL_SetWindowPosition(window->id, window->x, window->y);
   5.236 -        }
   5.237 -    }
   5.238  
   5.239      return 0;
   5.240  }
   5.241  
   5.242  int
   5.243 -SDL_SetFullscreenDisplayMode(const SDL_DisplayMode * mode)
   5.244 -{
   5.245 -    SDL_VideoDisplay *display;
   5.246 -    SDL_DisplayMode fullscreen_mode;
   5.247 -    int i;
   5.248 -
   5.249 -    if (!_this) {
   5.250 -        SDL_UninitializedVideo();
   5.251 -        return -1;
   5.252 -    }
   5.253 -    display = &SDL_CurrentDisplay;
   5.254 -    if (!mode) {
   5.255 -        mode = &display->desktop_mode;
   5.256 -    }
   5.257 -    if (!SDL_GetClosestDisplayMode(mode, &fullscreen_mode)) {
   5.258 -        SDL_SetError("Couldn't find display mode match");
   5.259 -        return -1;
   5.260 -    }
   5.261 -
   5.262 -    if (SDL_memcmp
   5.263 -        (&fullscreen_mode, &display->fullscreen_mode,
   5.264 -         sizeof(fullscreen_mode)) == 0) {
   5.265 -        /* Nothing to do... */
   5.266 -        return 0;
   5.267 -    }
   5.268 -    display->fullscreen_mode = fullscreen_mode;
   5.269 -
   5.270 -    /* Actually set the mode if we have a fullscreen window visible */
   5.271 -    for (i = 0; i < display->num_windows; ++i) {
   5.272 -        SDL_Window *window = &display->windows[i];
   5.273 -        if (FULLSCREEN_VISIBLE(window)) {
   5.274 -            if (SDL_SetDisplayMode(&display->fullscreen_mode) < 0) {
   5.275 -                return -1;
   5.276 -            }
   5.277 -        }
   5.278 -        if (window->flags & SDL_WINDOW_FULLSCREEN) {
   5.279 -            SDL_OnWindowResized(window);
   5.280 -        }
   5.281 -    }
   5.282 -    return 0;
   5.283 -}
   5.284 -
   5.285 -int
   5.286 -SDL_GetFullscreenDisplayMode(SDL_DisplayMode * mode)
   5.287 +SDL_SetDisplayMode(const SDL_DisplayMode * mode)
   5.288  {
   5.289      if (!_this) {
   5.290          SDL_UninitializedVideo();
   5.291          return -1;
   5.292      }
   5.293 +    return SDL_SetDisplayModeForDisplay(&SDL_CurrentDisplay, mode);
   5.294 +}
   5.295 +
   5.296 +int
   5.297 +SDL_SetWindowDisplayMode(SDL_WindowID windowID, const SDL_DisplayMode * mode)
   5.298 +{
   5.299 +    SDL_Window *window = SDL_GetWindowFromID(windowID);
   5.300 +
   5.301 +    if (!window) {
   5.302 +        return -1;
   5.303 +    }
   5.304 +
   5.305      if (mode) {
   5.306 -        *mode = SDL_CurrentDisplay.fullscreen_mode;
   5.307 +        window->fullscreen_mode = *mode;
   5.308 +    } else {
   5.309 +        SDL_zero(window->fullscreen_mode);
   5.310 +    }
   5.311 +}
   5.312 +
   5.313 +int
   5.314 +SDL_GetWindowDisplayMode(SDL_WindowID windowID, SDL_DisplayMode * mode)
   5.315 +{
   5.316 +    SDL_Window *window = SDL_GetWindowFromID(windowID);
   5.317 +    SDL_DisplayMode fullscreen_mode;
   5.318 +
   5.319 +    if (!window) {
   5.320 +        return -1;
   5.321 +    }
   5.322 +
   5.323 +    fullscreen_mode = window->fullscreen_mode;
   5.324 +    if (!fullscreen_mode.w) {
   5.325 +        fullscreen_mode.w = window->w;
   5.326 +    }
   5.327 +    if (!fullscreen_mode.h) {
   5.328 +        fullscreen_mode.h = window->h;
   5.329 +    }
   5.330 +
   5.331 +    if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayFromWindow(window),
   5.332 +                                             &fullscreen_mode,
   5.333 +                                             &fullscreen_mode)) {
   5.334 +        SDL_SetError("Couldn't find display mode match");
   5.335 +        return -1;
   5.336 +    }
   5.337 +
   5.338 +    if (mode) {
   5.339 +        *mode = fullscreen_mode;
   5.340      }
   5.341      return 0;
   5.342  }
   5.343  
   5.344  int
   5.345 +SDL_SetDisplayPaletteForDisplay(SDL_VideoDisplay * display, const SDL_Color * colors, int firstcolor, int ncolors)
   5.346 +{
   5.347 +    SDL_Palette *palette;
   5.348 +    int status = 0;
   5.349 +
   5.350 +    palette = display->palette;
   5.351 +    if (!palette) {
   5.352 +        SDL_SetError("Display mode does not have a palette");
   5.353 +        return -1;
   5.354 +    }
   5.355 +    status = SDL_SetPaletteColors(palette, colors, firstcolor, ncolors);
   5.356 +
   5.357 +    if (_this->SetDisplayPalette) {
   5.358 +        if (_this->SetDisplayPalette(_this, display, palette) < 0) {
   5.359 +            status = -1;
   5.360 +        }
   5.361 +    }
   5.362 +    return status;
   5.363 +}
   5.364 +
   5.365 +int
   5.366  SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors)
   5.367  {
   5.368 -    SDL_Palette *palette;
   5.369 -    int status = 0;
   5.370 -
   5.371      if (!_this) {
   5.372          SDL_UninitializedVideo();
   5.373          return -1;
   5.374      }
   5.375 -    palette = SDL_CurrentDisplay.palette;
   5.376 -    if (!palette) {
   5.377 +    return SDL_SetDisplayPaletteForDisplay(&SDL_CurrentDisplay, colors, firstcolor, ncolors);
   5.378 +}
   5.379 +
   5.380 +int
   5.381 +SDL_GetDisplayPaletteForDisplay(SDL_VideoDisplay * display, SDL_Color * colors, int firstcolor, int ncolors)
   5.382 +{
   5.383 +    SDL_Palette *palette;
   5.384 +
   5.385 +    palette = display->palette;
   5.386 +    if (!palette || !palette->ncolors) {
   5.387          SDL_SetError("Display mode does not have a palette");
   5.388          return -1;
   5.389      }
   5.390 -    status = SDL_SetPaletteColors(palette, colors, firstcolor, ncolors);
   5.391 -
   5.392 -    if (_this->SetDisplayPalette) {
   5.393 -        if (_this->SetDisplayPalette(_this, palette) < 0) {
   5.394 -            status = -1;
   5.395 -        }
   5.396 -    }
   5.397 -    return status;
   5.398 +    if (firstcolor < 0 || (firstcolor + ncolors) > palette->ncolors) {
   5.399 +        SDL_SetError("Palette indices are out of range");
   5.400 +        return -1;
   5.401 +    }
   5.402 +    SDL_memcpy(colors, &palette->colors[firstcolor],
   5.403 +               ncolors * sizeof(*colors));
   5.404 +    return 0;
   5.405  }
   5.406  
   5.407  int
   5.408 @@ -725,18 +778,7 @@
   5.409          SDL_UninitializedVideo();
   5.410          return -1;
   5.411      }
   5.412 -    palette = SDL_CurrentDisplay.palette;
   5.413 -    if (!palette->ncolors) {
   5.414 -        SDL_SetError("Display mode does not have a palette");
   5.415 -        return -1;
   5.416 -    }
   5.417 -    if (firstcolor < 0 || (firstcolor + ncolors) > palette->ncolors) {
   5.418 -        SDL_SetError("Palette indices are out of range");
   5.419 -        return -1;
   5.420 -    }
   5.421 -    SDL_memcpy(colors, &palette->colors[firstcolor],
   5.422 -               ncolors * sizeof(*colors));
   5.423 -    return 0;
   5.424 +    return SDL_GetDisplayPaletteForDisplay(&SDL_CurrentDisplay, colors, firstcolor, ncolors);
   5.425  }
   5.426  
   5.427  SDL_WindowID
   5.428 @@ -835,6 +877,7 @@
   5.429          _this->CreateWindowFrom(_this, &window, data) < 0) {
   5.430          return 0;
   5.431      }
   5.432 +    /* FIXME: Find out what display this window is actually on... */
   5.433      display = &SDL_CurrentDisplay;
   5.434      num_windows = display->num_windows;
   5.435      windows =
   5.436 @@ -1248,6 +1291,7 @@
   5.437  
   5.438          if (FULLSCREEN_VISIBLE(window)) {
   5.439              SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   5.440 +            SDL_DisplayMode fullscreen_mode;
   5.441  
   5.442              /* Hide any other fullscreen windows */
   5.443              int i;
   5.444 @@ -1258,7 +1302,9 @@
   5.445                  }
   5.446              }
   5.447  
   5.448 -            SDL_SetDisplayMode(&display->fullscreen_mode);
   5.449 +            if (SDL_GetWindowDisplayMode(windowID, &fullscreen_mode) == 0) {
   5.450 +                SDL_SetDisplayModeForDisplay(display, &fullscreen_mode);
   5.451 +            }
   5.452          }
   5.453      } else {
   5.454          window->flags &= ~SDL_WINDOW_FULLSCREEN;
   5.455 @@ -1336,11 +1382,11 @@
   5.456  {
   5.457      SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   5.458  
   5.459 -    if (window->flags & SDL_WINDOW_FULLSCREEN) {
   5.460 -        SDL_SetDisplayMode(&display->fullscreen_mode);
   5.461 +    if (FULLSCREEN_VISIBLE(window)) {
   5.462 +        SDL_SetDisplayMode(&window->fullscreen_mode);
   5.463      }
   5.464      if (display->gamma && _this->SetDisplayGammaRamp) {
   5.465 -        _this->SetDisplayGammaRamp(_this, display->gamma);
   5.466 +        _this->SetDisplayGammaRamp(_this, display, display->gamma);
   5.467      }
   5.468      if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN))
   5.469          && _this->SetWindowGrab) {
   5.470 @@ -1353,12 +1399,12 @@
   5.471  {
   5.472      SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   5.473  
   5.474 -    if (window->flags & SDL_WINDOW_FULLSCREEN) {
   5.475 +    if (FULLSCREEN_VISIBLE(window)) {
   5.476          SDL_MinimizeWindow(window->id);
   5.477          SDL_SetDisplayMode(NULL);
   5.478      }
   5.479      if (display->gamma && _this->SetDisplayGammaRamp) {
   5.480 -        _this->SetDisplayGammaRamp(_this, display->saved_gamma);
   5.481 +        _this->SetDisplayGammaRamp(_this, display, display->saved_gamma);
   5.482      }
   5.483      if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN))
   5.484          && _this->SetWindowGrab) {
   5.485 @@ -1430,16 +1476,10 @@
   5.486  }
   5.487  
   5.488  void
   5.489 -SDL_AddRenderDriver(int displayIndex, const SDL_RenderDriver * driver)
   5.490 +SDL_AddRenderDriver(SDL_VideoDisplay * display, const SDL_RenderDriver * driver)
   5.491  {
   5.492 -    SDL_VideoDisplay *display;
   5.493      SDL_RenderDriver *render_drivers;
   5.494  
   5.495 -    if (displayIndex >= _this->num_displays) {
   5.496 -        return;
   5.497 -    }
   5.498 -    display = &_this->displays[displayIndex];
   5.499 -
   5.500      render_drivers =
   5.501          SDL_realloc(display->render_drivers,
   5.502                      (display->num_render_drivers +
     6.1 --- a/src/video/cocoa/SDL_cocoamodes.h	Mon Nov 30 21:04:25 2009 +0000
     6.2 +++ b/src/video/cocoa/SDL_cocoamodes.h	Tue Dec 01 05:57:15 2009 +0000
     6.3 @@ -35,8 +35,8 @@
     6.4  } SDL_DisplayModeData;
     6.5  
     6.6  extern void Cocoa_InitModes(_THIS);
     6.7 -extern void Cocoa_GetDisplayModes(_THIS);
     6.8 -extern int Cocoa_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
     6.9 +extern void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
    6.10 +extern int Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    6.11  extern void Cocoa_QuitModes(_THIS);
    6.12  
    6.13  #endif /* _SDL_cocoamodes_h */
     7.1 --- a/src/video/cocoa/SDL_cocoamodes.m	Mon Nov 30 21:04:25 2009 +0000
     7.2 +++ b/src/video/cocoa/SDL_cocoamodes.m	Tue Dec 01 05:57:15 2009 +0000
     7.3 @@ -190,18 +190,18 @@
     7.4  static void
     7.5  AddDisplayMode(const void *moderef, void *context)
     7.6  {
     7.7 -    SDL_VideoDevice *_this = (SDL_VideoDevice *) context;
     7.8 +    SDL_VideoDisplay *display = (SDL_VideoDisplay *) context;
     7.9      SDL_DisplayMode mode;
    7.10  
    7.11      if (GetDisplayMode(moderef, &mode)) {
    7.12 -        SDL_AddDisplayMode(_this->current_display, &mode);
    7.13 +        SDL_AddDisplayMode(display, &mode);
    7.14      }
    7.15  }
    7.16  
    7.17  void
    7.18 -Cocoa_GetDisplayModes(_THIS)
    7.19 +Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
    7.20  {
    7.21 -    SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
    7.22 +    SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
    7.23      CFArrayRef modes;
    7.24      CFRange range;
    7.25  
    7.26 @@ -211,13 +211,13 @@
    7.27      }
    7.28      range.location = 0;
    7.29      range.length = CFArrayGetCount(modes);
    7.30 -    CFArrayApplyFunction(modes, range, AddDisplayMode, _this);
    7.31 +    CFArrayApplyFunction(modes, range, AddDisplayMode, display);
    7.32  }
    7.33  
    7.34  int
    7.35 -Cocoa_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
    7.36 +Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
    7.37  {
    7.38 -    SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
    7.39 +    SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
    7.40      SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
    7.41      CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken;
    7.42      CGError result;
    7.43 @@ -279,21 +279,17 @@
    7.44  void
    7.45  Cocoa_QuitModes(_THIS)
    7.46  {
    7.47 -    int i, saved_display;
    7.48 +    int i;
    7.49  
    7.50 -    saved_display = _this->current_display;
    7.51      for (i = 0; i < _this->num_displays; ++i) {
    7.52          SDL_VideoDisplay *display = &_this->displays[i];
    7.53  
    7.54          if (display->current_mode.driverdata != display->desktop_mode.driverdata) {
    7.55 -            _this->current_display = i;
    7.56 -            Cocoa_SetDisplayMode(_this, &display->desktop_mode);
    7.57 +            Cocoa_SetDisplayMode(_this, display, &display->desktop_mode);
    7.58          }
    7.59      }
    7.60      CGReleaseAllDisplays();
    7.61      ShowMenuBar();
    7.62 -
    7.63 -    _this->current_display = saved_display;
    7.64  }
    7.65  
    7.66  /* vi: set ts=4 sw=4 expandtab: */
     8.1 --- a/src/video/directfb/SDL_DirectFB_modes.c	Mon Nov 30 21:04:25 2009 +0000
     8.2 +++ b/src/video/directfb/SDL_DirectFB_modes.c	Tue Dec 01 05:57:15 2009 +0000
     8.3 @@ -197,7 +197,7 @@
     8.4  }
     8.5  
     8.6  static void
     8.7 -CheckSetDisplayMode(_THIS, DFB_DisplayData * data, SDL_DisplayMode * mode)
     8.8 +CheckSetDisplayMode(_THIS, SDL_VideoDisplay * display, DFB_DisplayData * data, SDL_DisplayMode * mode)
     8.9  {
    8.10      SDL_DFB_DEVICEDATA(_this);
    8.11      DFBDisplayLayerConfig config;
    8.12 @@ -219,7 +219,7 @@
    8.13      SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer,
    8.14                                                        DLSCL_SHARED));
    8.15      if (failed == 0)
    8.16 -        SDL_AddDisplayMode(_this->current_display, mode);
    8.17 +        SDL_AddDisplayMode(display, mode);
    8.18      else
    8.19          SDL_DFB_DEBUG("Mode %d x %d not available: %x\n", mode->w,
    8.20                        mode->h, failed);
    8.21 @@ -356,11 +356,10 @@
    8.22  }
    8.23  
    8.24  void
    8.25 -DirectFB_GetDisplayModes(_THIS)
    8.26 +DirectFB_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
    8.27  {
    8.28      SDL_DFB_DEVICEDATA(_this);
    8.29 -    DFB_DisplayData *dispdata =
    8.30 -        (DFB_DisplayData *) SDL_CurrentDisplay.driverdata;
    8.31 +    DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
    8.32      SDL_DisplayMode mode;
    8.33      struct modes_callback_t data;
    8.34      int i;
    8.35 @@ -376,25 +375,23 @@
    8.36          mode = data.modelist[i];
    8.37  
    8.38          mode.format = SDL_PIXELFORMAT_ARGB8888;
    8.39 -        CheckSetDisplayMode(_this, dispdata, &mode);
    8.40 +        CheckSetDisplayMode(_this, display, dispdata, &mode);
    8.41          mode.format = SDL_PIXELFORMAT_RGB888;
    8.42 -        CheckSetDisplayMode(_this, dispdata, &mode);
    8.43 +        CheckSetDisplayMode(_this, display, dispdata, &mode);
    8.44          mode.format = SDL_PIXELFORMAT_RGB24;
    8.45 -        CheckSetDisplayMode(_this, dispdata, &mode);
    8.46 +        CheckSetDisplayMode(_this, display, dispdata, &mode);
    8.47          mode.format = SDL_PIXELFORMAT_RGB565;
    8.48 -        CheckSetDisplayMode(_this, dispdata, &mode);
    8.49 +        CheckSetDisplayMode(_this, display, dispdata, &mode);
    8.50          mode.format = SDL_PIXELFORMAT_INDEX8;
    8.51 -        CheckSetDisplayMode(_this, dispdata, &mode);
    8.52 +        CheckSetDisplayMode(_this, display, dispdata, &mode);
    8.53      }
    8.54 -    SDL_DFB_FREE(data.modelist);
    8.55 -    return;
    8.56 -  error:
    8.57 +
    8.58      SDL_DFB_FREE(data.modelist);
    8.59      return;
    8.60  }
    8.61  
    8.62  int
    8.63 -DirectFB_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
    8.64 +DirectFB_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
    8.65  {
    8.66      /*
    8.67       * FIXME: video mode switch is currently broken for 1.2.0
    8.68 @@ -402,7 +399,7 @@
    8.69       */
    8.70  
    8.71      SDL_DFB_DEVICEDATA(_this);
    8.72 -    DFB_DisplayData *data = (DFB_DisplayData *) SDL_CurrentDisplay.driverdata;
    8.73 +    DFB_DisplayData *data = (DFB_DisplayData *) display->driverdata;
    8.74      DFBDisplayLayerConfig config, rconfig;
    8.75      DFBDisplayLayerConfigFlags fail = 0;
    8.76      DFBResult ret;
    8.77 @@ -459,7 +456,7 @@
    8.78      data->pixelformat = rconfig.pixelformat;
    8.79      data->cw = config.width;
    8.80      data->ch = config.height;
    8.81 -    SDL_CurrentDisplay.current_mode = *mode;
    8.82 +    display->current_mode = *mode;
    8.83  
    8.84      return 0;
    8.85    error:
    8.86 @@ -474,18 +471,16 @@
    8.87      DFBResult ret;
    8.88      int i;
    8.89  
    8.90 -    SDL_SelectVideoDisplay(0);
    8.91 +    for (i = 0; i < _this->num_displays; ++i) {
    8.92 +        SDL_VideoDisplay *display = &_this->displays[i];
    8.93 +        DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
    8.94  
    8.95 -    SDL_GetDesktopDisplayMode(&tmode);
    8.96 -    tmode.format = SDL_PIXELFORMAT_UNKNOWN;
    8.97 -    DirectFB_SetDisplayMode(_this, &tmode);
    8.98 +        SDL_GetDesktopDisplayModeForDisplay(display, &tmode);
    8.99 +        tmode.format = SDL_PIXELFORMAT_UNKNOWN;
   8.100 +        DirectFB_SetDisplayMode(_this, display, &tmode);
   8.101  
   8.102 -    SDL_GetDesktopDisplayMode(&tmode);
   8.103 -    DirectFB_SetDisplayMode(_this, &tmode);
   8.104 -
   8.105 -    for (i = 0; i < SDL_GetNumVideoDisplays(); i++) {
   8.106 -        DFB_DisplayData *dispdata =
   8.107 -            (DFB_DisplayData *) _this->displays[i].driverdata;
   8.108 +        SDL_GetDesktopDisplayModeForDisplay(display, &tmode);
   8.109 +        DirectFB_SetDisplayMode(_this, display, &tmode);
   8.110  
   8.111          if (dispdata->layer) {
   8.112              SDL_DFB_CHECK(dispdata->
     9.1 --- a/src/video/directfb/SDL_DirectFB_modes.h	Mon Nov 30 21:04:25 2009 +0000
     9.2 +++ b/src/video/directfb/SDL_DirectFB_modes.h	Tue Dec 01 05:57:15 2009 +0000
     9.3 @@ -48,8 +48,8 @@
     9.4  
     9.5  
     9.6  extern void DirectFB_InitModes(_THIS);
     9.7 -extern void DirectFB_GetDisplayModes(_THIS);
     9.8 -extern int DirectFB_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
     9.9 +extern void DirectFB_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
    9.10 +extern int DirectFB_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    9.11  extern void DirectFB_QuitModes(_THIS);
    9.12  
    9.13  #endif /* _SDL_directfb_modes_h */
    10.1 --- a/src/video/directfb/SDL_DirectFB_render.c	Mon Nov 30 21:04:25 2009 +0000
    10.2 +++ b/src/video/directfb/SDL_DirectFB_render.c	Tue Dec 01 05:57:15 2009 +0000
    10.3 @@ -234,7 +234,7 @@
    10.4  {
    10.5      int i;
    10.6      for (i = 0; i < _this->num_displays; i++)
    10.7 -        SDL_AddRenderDriver(i, &DirectFB_RenderDriver);
    10.8 +        SDL_AddRenderDriver(&_this->displays[i], &DirectFB_RenderDriver);
    10.9  }
   10.10  
   10.11  static int
   10.12 @@ -264,6 +264,8 @@
   10.13      SDL_DFB_CHECKERR(surfpal->SetEntries(surfpal, entries, ncolors, 0));
   10.14      return 0;
   10.15    error:
   10.16 +#else
   10.17 +    SDL_Unsupported();
   10.18  #endif
   10.19      return -1;
   10.20  }
    11.1 --- a/src/video/directfb/SDL_DirectFB_video.c	Mon Nov 30 21:04:25 2009 +0000
    11.2 +++ b/src/video/directfb/SDL_DirectFB_video.c	Tue Dec 01 05:57:15 2009 +0000
    11.3 @@ -56,11 +56,6 @@
    11.4  static int DirectFB_Available(void);
    11.5  static SDL_VideoDevice *DirectFB_CreateDevice(int devindex);
    11.6  
    11.7 -#if 0
    11.8 -static int DirectFB_SetDisplayGammaRamp(_THIS, Uint16 * ramp);
    11.9 -static int DirectFB_GetDisplayGammaRamp(_THIS, Uint16 * ramp);
   11.10 -#endif
   11.11 -
   11.12  VideoBootStrap DirectFB_bootstrap = {
   11.13      "directfb", "DirectFB",
   11.14      DirectFB_Available, DirectFB_CreateDevice
   11.15 @@ -103,13 +98,6 @@
   11.16      device->VideoQuit = DirectFB_VideoQuit;
   11.17      device->GetDisplayModes = DirectFB_GetDisplayModes;
   11.18      device->SetDisplayMode = DirectFB_SetDisplayMode;
   11.19 -#if 0
   11.20 -    device->SetDisplayGammaRamp = DirectFB_SetDisplayGammaRamp;
   11.21 -    device->GetDisplayGammaRamp = DirectFB_GetDisplayGammaRamp;
   11.22 -#else
   11.23 -    device->SetDisplayGammaRamp = NULL;
   11.24 -    device->GetDisplayGammaRamp = NULL;
   11.25 -#endif
   11.26      device->PumpEvents = DirectFB_PumpEventsWindow;
   11.27      device->CreateWindow = DirectFB_CreateWindow;
   11.28      device->CreateWindowFrom = DirectFB_CreateWindowFrom;
   11.29 @@ -300,17 +288,3 @@
   11.30  
   11.31      devdata->initialized = 0;
   11.32  }
   11.33 -
   11.34 -#if 0
   11.35 -static int
   11.36 -DirectFB_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
   11.37 -{
   11.38 -    return -1;
   11.39 -}
   11.40 -
   11.41 -static int
   11.42 -DirectFB_GetDisplayGammaRamp(_THIS, Uint16 * ramp)
   11.43 -{
   11.44 -    return -1;
   11.45 -}
   11.46 -#endif
    12.1 --- a/src/video/pandora/SDL_pandora.c	Mon Nov 30 21:04:25 2009 +0000
    12.2 +++ b/src/video/pandora/SDL_pandora.c	Tue Dec 01 05:57:15 2009 +0000
    12.3 @@ -108,10 +108,6 @@
    12.4      device->VideoQuit = PND_videoquit;
    12.5      device->GetDisplayModes = PND_getdisplaymodes;
    12.6      device->SetDisplayMode = PND_setdisplaymode;
    12.7 -    device->SetDisplayPalette = PND_setdisplaypalette;
    12.8 -    device->GetDisplayPalette = PND_getdisplaypalette;
    12.9 -    device->SetDisplayGammaRamp = PND_setdisplaygammaramp;
   12.10 -    device->GetDisplayGammaRamp = PND_getdisplaygammaramp;
   12.11      device->CreateWindow = PND_createwindow;
   12.12      device->CreateWindowFrom = PND_createwindowfrom;
   12.13      device->SetWindowTitle = PND_setwindowtitle;
   12.14 @@ -191,55 +187,18 @@
   12.15  }
   12.16  
   12.17  void
   12.18 -PND_getdisplaymodes(_THIS)
   12.19 +PND_getdisplaymodes(_THIS, SDL_VideoDisplay * display)
   12.20  {
   12.21  
   12.22  }
   12.23  
   12.24  int
   12.25 -PND_setdisplaymode(_THIS, SDL_DisplayMode * mode)
   12.26 +PND_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
   12.27  {
   12.28      return 0;
   12.29  }
   12.30  
   12.31  int
   12.32 -PND_setdisplaypalette(_THIS, SDL_Palette * palette)
   12.33 -{
   12.34 -    SDL_DisplayData *didata =
   12.35 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
   12.36 -
   12.37 -    /* Setting display palette operation has been failed */
   12.38 -    return -1;
   12.39 -}
   12.40 -
   12.41 -int
   12.42 -PND_getdisplaypalette(_THIS, SDL_Palette * palette)
   12.43 -{
   12.44 -    SDL_DisplayData *didata =
   12.45 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
   12.46 -
   12.47 -    /* Getting display palette operation has been failed */
   12.48 -    return -1;
   12.49 -}
   12.50 -
   12.51 -int
   12.52 -PND_setdisplaygammaramp(_THIS, Uint16 * ramp)
   12.53 -{
   12.54 -    SDL_DisplayData *didata =
   12.55 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
   12.56 -
   12.57 -    /* Setting display gamma ramp operation has been failed */
   12.58 -    return -1;
   12.59 -}
   12.60 -
   12.61 -int
   12.62 -PND_getdisplaygammaramp(_THIS, Uint16 * ramp)
   12.63 -{
   12.64 -    /* Getting display gamma ramp operation has been failed */
   12.65 -    return -1;
   12.66 -}
   12.67 -
   12.68 -int
   12.69  PND_createwindow(_THIS, SDL_Window * window)
   12.70  {
   12.71      SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
   12.72 @@ -458,7 +417,7 @@
   12.73      SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
   12.74      SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
   12.75      SDL_DisplayData *didata =
   12.76 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
   12.77 +        (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
   12.78      EGLBoolean status;
   12.79      int32_t gfstatus;
   12.80      EGLint configs;
   12.81 @@ -857,7 +816,7 @@
   12.82      SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
   12.83      SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
   12.84      SDL_DisplayData *didata =
   12.85 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
   12.86 +        (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
   12.87  
   12.88  
   12.89      if (phdata->egl_initialized != SDL_TRUE) {
    13.1 --- a/src/video/photon/SDL_photon.c	Mon Nov 30 21:04:25 2009 +0000
    13.2 +++ b/src/video/photon/SDL_photon.c	Tue Dec 01 05:57:15 2009 +0000
    13.3 @@ -269,10 +269,6 @@
    13.4      device->VideoQuit = photon_videoquit;
    13.5      device->GetDisplayModes = photon_getdisplaymodes;
    13.6      device->SetDisplayMode = photon_setdisplaymode;
    13.7 -    device->SetDisplayPalette = photon_setdisplaypalette;
    13.8 -    device->GetDisplayPalette = photon_getdisplaypalette;
    13.9 -    device->SetDisplayGammaRamp = photon_setdisplaygammaramp;
   13.10 -    device->GetDisplayGammaRamp = photon_getdisplaygammaramp;
   13.11      device->CreateWindow = photon_createwindow;
   13.12      device->CreateWindowFrom = photon_createwindowfrom;
   13.13      device->SetWindowTitle = photon_setwindowtitle;
   13.14 @@ -524,11 +520,10 @@
   13.15  }
   13.16  
   13.17  void
   13.18 -photon_getdisplaymodes(_THIS)
   13.19 +photon_getdisplaymodes(_THIS, SDL_VideoDisplay * display)
   13.20  {
   13.21      SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
   13.22 -    SDL_DisplayData *didata =
   13.23 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
   13.24 +    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
   13.25      SDL_DisplayMode mode;
   13.26      PgVideoModes_t modes;
   13.27      PgVideoModeInfo_t modeinfo;
   13.28 @@ -569,7 +564,7 @@
   13.29                  mode.refresh_rate = modeinfo.refresh_rates[jt];
   13.30                  mode.format = photon_image_to_sdl_pixelformat(modeinfo.type);
   13.31                  mode.driverdata = NULL;
   13.32 -                SDL_AddDisplayMode(_this->current_display, &mode);
   13.33 +                SDL_AddDisplayMode(display, &mode);
   13.34  
   13.35                  /* If mode is RGBA8888, add the same mode as RGBx888 */
   13.36                  if (modeinfo.type == Pg_IMAGE_DIRECT_8888) {
   13.37 @@ -578,7 +573,7 @@
   13.38                      mode.refresh_rate = modeinfo.refresh_rates[jt];
   13.39                      mode.format = SDL_PIXELFORMAT_RGB888;
   13.40                      mode.driverdata = NULL;
   13.41 -                    SDL_AddDisplayMode(_this->current_display, &mode);
   13.42 +                    SDL_AddDisplayMode(display, &mode);
   13.43                  }
   13.44  
   13.45                  /* If mode is RGBA1555, add the same mode as RGBx555 */
   13.46 @@ -588,7 +583,7 @@
   13.47                      mode.refresh_rate = modeinfo.refresh_rates[jt];
   13.48                      mode.format = SDL_PIXELFORMAT_RGB555;
   13.49                      mode.driverdata = NULL;
   13.50 -                    SDL_AddDisplayMode(_this->current_display, &mode);
   13.51 +                    SDL_AddDisplayMode(display, &mode);
   13.52                  }
   13.53  
   13.54                  jt++;
   13.55 @@ -600,11 +595,10 @@
   13.56  }
   13.57  
   13.58  int
   13.59 -photon_setdisplaymode(_THIS, SDL_DisplayMode * mode)
   13.60 +photon_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
   13.61  {
   13.62      SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
   13.63 -    SDL_DisplayData *didata =
   13.64 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
   13.65 +    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
   13.66      PgVideoModes_t modes;
   13.67      PgVideoModeInfo_t modeinfo;
   13.68      PgDisplaySettings_t modesettings;
   13.69 @@ -651,15 +645,15 @@
   13.70          tempmode.refresh_rate = 0x0000FFFF;
   13.71  
   13.72          /* Check if window width and height matches one of our modes */
   13.73 -        for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) {
   13.74 -            if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) &&
   13.75 -                (SDL_CurrentDisplay.display_modes[it].h == mode->h) &&
   13.76 -                (SDL_CurrentDisplay.display_modes[it].format == mode->format))
   13.77 +        for (it = 0; it < display->num_display_modes; it++) {
   13.78 +            if ((display->display_modes[it].w == mode->w) &&
   13.79 +                (display->display_modes[it].h == mode->h) &&
   13.80 +                (display->display_modes[it].format == mode->format))
   13.81              {
   13.82                  /* Find the lowest refresh rate available */
   13.83                  if (tempmode.refresh_rate >
   13.84 -                    SDL_CurrentDisplay.display_modes[it].refresh_rate) {
   13.85 -                    tempmode = SDL_CurrentDisplay.display_modes[it];
   13.86 +                    display->display_modes[it].refresh_rate) {
   13.87 +                    tempmode = display->display_modes[it];
   13.88                  }
   13.89              }
   13.90          }
   13.91 @@ -680,21 +674,21 @@
   13.92          tempmode.refresh_rate = 0x0000FFFF;
   13.93  
   13.94          /* Check if window width and height matches one of our modes */
   13.95 -        for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) {
   13.96 -            if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) &&
   13.97 -                (SDL_CurrentDisplay.display_modes[it].h == mode->h) &&
   13.98 -                (SDL_CurrentDisplay.display_modes[it].format == mode->format))
   13.99 +        for (it = 0; it < display->num_display_modes; it++) {
  13.100 +            if ((display->display_modes[it].w == mode->w) &&
  13.101 +                (display->display_modes[it].h == mode->h) &&
  13.102 +                (display->display_modes[it].format == mode->format))
  13.103              {
  13.104                  /* Find the lowest refresh rate available */
  13.105                  if (tempmode.refresh_rate >
  13.106 -                    SDL_CurrentDisplay.display_modes[it].refresh_rate) {
  13.107 -                    tempmode = SDL_CurrentDisplay.display_modes[it];
  13.108 +                    display->display_modes[it].refresh_rate) {
  13.109 +                    tempmode = display->display_modes[it];
  13.110                  }
  13.111  
  13.112                  /* Check if requested refresh rate found */
  13.113                  if (refresh_rate ==
  13.114 -                    SDL_CurrentDisplay.display_modes[it].refresh_rate) {
  13.115 -                    tempmode = SDL_CurrentDisplay.display_modes[it];
  13.116 +                    display->display_modes[it].refresh_rate) {
  13.117 +                    tempmode = display->display_modes[it];
  13.118                      break;
  13.119                  }
  13.120              }
  13.121 @@ -779,48 +773,11 @@
  13.122  }
  13.123  
  13.124  int
  13.125 -photon_setdisplaypalette(_THIS, SDL_Palette * palette)
  13.126 -{
  13.127 -    SDL_DisplayData *didata =
  13.128 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
  13.129 -
  13.130 -    /* Setting display palette operation has been failed */
  13.131 -    return -1;
  13.132 -}
  13.133 -
  13.134 -int
  13.135 -photon_getdisplaypalette(_THIS, SDL_Palette * palette)
  13.136 -{
  13.137 -    SDL_DisplayData *didata =
  13.138 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
  13.139 -
  13.140 -    /* Getting display palette operation has been failed */
  13.141 -    return -1;
  13.142 -}
  13.143 -
  13.144 -int
  13.145 -photon_setdisplaygammaramp(_THIS, Uint16 * ramp)
  13.146 -{
  13.147 -    SDL_DisplayData *didata =
  13.148 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
  13.149 -
  13.150 -    /* Setting display gamma ramp operation has been failed */
  13.151 -    return -1;
  13.152 -}
  13.153 -
  13.154 -int
  13.155 -photon_getdisplaygammaramp(_THIS, Uint16 * ramp)
  13.156 -{
  13.157 -    /* Getting display gamma ramp operation has been failed */
  13.158 -    return -1;
  13.159 -}
  13.160 -
  13.161 -int
  13.162  photon_createwindow(_THIS, SDL_Window * window)
  13.163  {
  13.164      SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
  13.165      SDL_DisplayData *didata =
  13.166 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
  13.167 +        (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
  13.168      SDL_WindowData *wdata;
  13.169      PhDim_t winsize;
  13.170      PhPoint_t winpos;
  13.171 @@ -1098,7 +1055,7 @@
  13.172  {
  13.173      SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
  13.174      SDL_DisplayData *didata =
  13.175 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
  13.176 +        (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
  13.177      PhPoint_t winpos;
  13.178      int32_t status;
  13.179  
  13.180 @@ -1266,7 +1223,7 @@
  13.181  {
  13.182      SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
  13.183      SDL_DisplayData *didata =
  13.184 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
  13.185 +        (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
  13.186      SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
  13.187      int32_t status;
  13.188  
  13.189 @@ -1457,7 +1414,7 @@
  13.190      SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
  13.191      SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
  13.192      SDL_DisplayData *didata =
  13.193 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
  13.194 +        (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
  13.195      EGLBoolean status;
  13.196      int32_t gfstatus;
  13.197      EGLint configs;
  13.198 @@ -1984,7 +1941,7 @@
  13.199      SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
  13.200      SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
  13.201      SDL_DisplayData *didata =
  13.202 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
  13.203 +        (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
  13.204      PhRect_t dst_rect;
  13.205      PhRect_t src_rect;
  13.206      int32_t status;
  13.207 @@ -2093,7 +2050,7 @@
  13.208      SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
  13.209      SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
  13.210      SDL_DisplayData *didata =
  13.211 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
  13.212 +        (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
  13.213      SDL_bool makecurrent=SDL_FALSE;
  13.214      int32_t gfstatus;
  13.215  
  13.216 @@ -2194,7 +2151,6 @@
  13.217      PhEvent_t *event = (PhEvent_t *) eventbuffer;
  13.218      int32_t status;
  13.219      uint32_t finish = 0;
  13.220 -    uint32_t it;
  13.221      SDL_Window *window;
  13.222      SDL_WindowData *wdata;
  13.223  
  13.224 @@ -2211,23 +2167,22 @@
  13.225              {
  13.226                  /* Find a window, to which this handle destinated */
  13.227                  status = 0;
  13.228 -                for (it = 0; it < SDL_CurrentDisplay.num_windows; it++) {
  13.229 -                    wdata =
  13.230 -                        (SDL_WindowData *) SDL_CurrentDisplay.windows[it].
  13.231 -                        driverdata;
  13.232 +                for (i = 0; i < SDL_GetNumVideoDisplays(); ++i) {
  13.233 +                    SDL_VideoDisplay *display = SDL_GetVideoDisplay(i);
  13.234 +                    for (j = 0; j < display->num_windows; ++j) {
  13.235 +                        wdata = (SDL_WindowData *) display->windows[j].driverdata;
  13.236  
  13.237 -                    /* Find the proper window */
  13.238 -                    if (wdata->window != NULL) {
  13.239 -                        if (PtWidgetRid(wdata->window) ==
  13.240 -                            event->collector.rid) {
  13.241 -                            window =
  13.242 -                                (SDL_Window *) & SDL_CurrentDisplay.
  13.243 -                                windows[it];
  13.244 -                            status = 1;
  13.245 -                            break;
  13.246 +                        /* Find the proper window */
  13.247 +                        if (wdata->window != NULL) {
  13.248 +                            if (PtWidgetRid(wdata->window) ==
  13.249 +                                event->collector.rid) {
  13.250 +                                window = (SDL_Window *) &display->windows[it];
  13.251 +                                status = 1;
  13.252 +                                break;
  13.253 +                            }
  13.254 +                        } else {
  13.255 +                            continue;
  13.256                          }
  13.257 -                    } else {
  13.258 -                        continue;
  13.259                      }
  13.260                  }
  13.261                  if (status == 0) {
    14.1 --- a/src/video/photon/SDL_photon_input.c	Mon Nov 30 21:04:25 2009 +0000
    14.2 +++ b/src/video/photon/SDL_photon_input.c	Tue Dec 01 05:57:15 2009 +0000
    14.3 @@ -53,6 +53,8 @@
    14.4      uint32_t it;
    14.5  
    14.6      for (it = 0; it < _this->num_displays; it++) {
    14.7 +        SDL_VideoDisplay *display = &_this->displays[it];
    14.8 +
    14.9          /* Clear SDL mouse structure */
   14.10          SDL_memset(&photon_mouse, 0x00, sizeof(struct SDL_Mouse));
   14.11  
   14.12 @@ -74,7 +76,7 @@
   14.13          photon_mouse.FreeMouse = photon_freemouse;
   14.14  
   14.15          /* Get display data */
   14.16 -        didata = (SDL_DisplayData *) _this->displays[it].driverdata;
   14.17 +        didata = (SDL_DisplayData *) display->driverdata;
   14.18  
   14.19          /* Store SDL_DisplayData pointer in the mouse driver internals */
   14.20          mdata->didata = didata;
    15.1 --- a/src/video/photon/SDL_photon_render.c	Mon Nov 30 21:04:25 2009 +0000
    15.2 +++ b/src/video/photon/SDL_photon_render.c	Tue Dec 01 05:57:15 2009 +0000
    15.3 @@ -276,7 +276,7 @@
    15.4      uint32_t it;
    15.5  
    15.6      for (it = 0; it < _this->num_displays; it++) {
    15.7 -        SDL_AddRenderDriver(it, &photon_renderdriver);
    15.8 +        SDL_AddRenderDriver(&_this->displays[it], &photon_renderdriver);
    15.9      }
   15.10  }
   15.11  
    16.1 --- a/src/video/ps3/SDL_ps3modes.c	Mon Nov 30 21:04:25 2009 +0000
    16.2 +++ b/src/video/ps3/SDL_ps3modes.c	Tue Dec 01 05:57:15 2009 +0000
    16.3 @@ -84,7 +84,8 @@
    16.4  };
    16.5  
    16.6  void
    16.7 -PS3_GetDisplayModes(_THIS) {
    16.8 +PS3_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
    16.9 +{
   16.10      deprintf(1, "+PS3_GetDisplayModes()\n");
   16.11      SDL_DisplayMode mode;
   16.12      unsigned int nummodes;
   16.13 @@ -98,13 +99,13 @@
   16.14  
   16.15          /* Add DisplayMode to list */
   16.16          deprintf(2, "Adding resolution %u x %u\n", ps3fb_modedb[n].w, ps3fb_modedb[n].h);
   16.17 -        SDL_AddDisplayMode(_this->current_display, &ps3fb_modedb[n]);
   16.18 +        SDL_AddDisplayMode(display, &ps3fb_modedb[n]);
   16.19      }
   16.20      deprintf(1, "-PS3_GetDisplayModes()\n");
   16.21  }
   16.22  
   16.23  int
   16.24 -PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
   16.25 +PS3_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
   16.26  {
   16.27      deprintf(1, "+PS3_SetDisplayMode()\n");
   16.28      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   16.29 @@ -123,13 +124,14 @@
   16.30  }
   16.31  
   16.32  void
   16.33 -PS3_QuitModes(_THIS) {
   16.34 +PS3_QuitModes(_THIS)
   16.35 +{
   16.36      deprintf(1, "+PS3_QuitModes()\n");
   16.37  
   16.38      /* There was no mem allocated for driverdata */
   16.39      int i, j;
   16.40 -    for (i = _this->num_displays; i--;) {
   16.41 -        SDL_VideoDisplay *display = &_this->displays[i];
   16.42 +    for (i = 0; i < SDL_GetNumVideoDisplays(); ++i) {
   16.43 +        SDL_VideoDisplay *display = SDL_GetVideoDisplay(i);
   16.44          for (j = display->num_display_modes; j--;) {
   16.45              display->display_modes[j].driverdata = NULL;
   16.46          }
    17.1 --- a/src/video/ps3/SDL_ps3modes_c.h	Mon Nov 30 21:04:25 2009 +0000
    17.2 +++ b/src/video/ps3/SDL_ps3modes_c.h	Tue Dec 01 05:57:15 2009 +0000
    17.3 @@ -25,8 +25,8 @@
    17.4  #define _SDL_ps3modes_h
    17.5  
    17.6  extern void PS3_InitModes(_THIS);
    17.7 -extern void PS3_GetDisplayModes(_THIS);
    17.8 -extern int PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
    17.9 +extern void PS3_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
   17.10 +extern int PS3_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
   17.11  extern void PS3_QuitModes(_THIS);
   17.12  
   17.13  #endif /* SDL_ps3modes_h */
    18.1 --- a/src/video/qnxgf/SDL_gf_input.c	Mon Nov 30 21:04:25 2009 +0000
    18.2 +++ b/src/video/qnxgf/SDL_gf_input.c	Tue Dec 01 05:57:15 2009 +0000
    18.3 @@ -60,6 +60,8 @@
    18.4      uint32_t it;
    18.5  
    18.6      for (it = 0; it < _this->num_displays; it++) {
    18.7 +        SDL_VideoDisplay *display = &_this->displays[it];
    18.8 +
    18.9          /* Clear SDL mouse structure */
   18.10          SDL_memset(&gf_mouse, 0x00, sizeof(struct SDL_Mouse));
   18.11  
   18.12 @@ -81,7 +83,7 @@
   18.13          gf_mouse.FreeMouse = gf_freemouse;
   18.14  
   18.15          /* Get display data */
   18.16 -        didata = (SDL_DisplayData *) _this->displays[it].driverdata;
   18.17 +        didata = (SDL_DisplayData *) display->driverdata;
   18.18  
   18.19          /* Store SDL_DisplayData pointer in the mouse driver internals */
   18.20          mdata->didata = didata;
    19.1 --- a/src/video/qnxgf/SDL_gf_render.c	Mon Nov 30 21:04:25 2009 +0000
    19.2 +++ b/src/video/qnxgf/SDL_gf_render.c	Tue Dec 01 05:57:15 2009 +0000
    19.3 @@ -261,7 +261,7 @@
    19.4      uint32_t it;
    19.5  
    19.6      for (it = 0; it < _this->num_displays; it++) {
    19.7 -        SDL_AddRenderDriver(it, &gf_renderdriver);
    19.8 +        SDL_AddRenderDriver(&_this->displays[it], &gf_renderdriver);
    19.9      }
   19.10  }
   19.11  
    20.1 --- a/src/video/qnxgf/SDL_qnxgf.c	Mon Nov 30 21:04:25 2009 +0000
    20.2 +++ b/src/video/qnxgf/SDL_qnxgf.c	Tue Dec 01 05:57:15 2009 +0000
    20.3 @@ -522,13 +522,9 @@
    20.4          }
    20.5  
    20.6          /* Get all display modes for this display */
    20.7 -        _this->current_display = it;
    20.8 -        qnxgf_getdisplaymodes(_this);
    20.9 +        qnxgf_getdisplaymodes(_this, display);
   20.10      }
   20.11  
   20.12 -    /* Restore default display */
   20.13 -    _this->current_display = 0;
   20.14 -
   20.15      /* Add GF renderer to SDL */
   20.16      gf_addrenderdriver(_this);
   20.17  
   20.18 @@ -614,10 +610,9 @@
   20.19  }
   20.20  
   20.21  void
   20.22 -qnxgf_getdisplaymodes(_THIS)
   20.23 +qnxgf_getdisplaymodes(_THIS, SDL_VideoDisplay * display)
   20.24  {
   20.25 -    SDL_DisplayData *didata =
   20.26 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
   20.27 +    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
   20.28      SDL_DisplayMode mode;
   20.29      gf_modeinfo_t modeinfo;
   20.30      uint32_t it = 0;
   20.31 @@ -653,7 +648,7 @@
   20.32                      mode.format =
   20.33                          qnxgf_gf_to_sdl_pixelformat(modeinfo.primary_format);
   20.34                      mode.driverdata = NULL;
   20.35 -                    SDL_AddDisplayMode(_this->current_display, &mode);
   20.36 +                    SDL_AddDisplayMode(display, &mode);
   20.37  
   20.38                      /* If mode is RGBA8888, add the same mode as RGBx888 */
   20.39                      if (modeinfo.primary_format == GF_FORMAT_BGRA8888) {
   20.40 @@ -662,7 +657,7 @@
   20.41                          mode.refresh_rate = generic_mode[jt].refresh_rate;
   20.42                          mode.format = SDL_PIXELFORMAT_RGB888;
   20.43                          mode.driverdata = NULL;
   20.44 -                        SDL_AddDisplayMode(_this->current_display, &mode);
   20.45 +                        SDL_AddDisplayMode(display, &mode);
   20.46                      }
   20.47                      /* If mode is RGBA1555, add the same mode as RGBx555 */
   20.48                      if (modeinfo.primary_format == GF_FORMAT_PACK_ARGB1555) {
   20.49 @@ -671,7 +666,7 @@
   20.50                          mode.refresh_rate = generic_mode[jt].refresh_rate;
   20.51                          mode.format = SDL_PIXELFORMAT_RGB555;
   20.52                          mode.driverdata = NULL;
   20.53 -                        SDL_AddDisplayMode(_this->current_display, &mode);
   20.54 +                        SDL_AddDisplayMode(display, &mode);
   20.55                      }
   20.56  
   20.57                      jt++;
   20.58 @@ -689,7 +684,7 @@
   20.59                              qnxgf_gf_to_sdl_pixelformat(modeinfo.
   20.60                                                          primary_format);
   20.61                          mode.driverdata = NULL;
   20.62 -                        SDL_AddDisplayMode(_this->current_display, &mode);
   20.63 +                        SDL_AddDisplayMode(display, &mode);
   20.64  
   20.65                          /* If mode is RGBA8888, add the same mode as RGBx888 */
   20.66                          if (modeinfo.primary_format == GF_FORMAT_BGRA8888) {
   20.67 @@ -698,7 +693,7 @@
   20.68                              mode.refresh_rate = modeinfo.refresh[jt];
   20.69                              mode.format = SDL_PIXELFORMAT_RGB888;
   20.70                              mode.driverdata = NULL;
   20.71 -                            SDL_AddDisplayMode(_this->current_display, &mode);
   20.72 +                            SDL_AddDisplayMode(display, &mode);
   20.73                          }
   20.74                          /* If mode is RGBA1555, add the same mode as RGBx555 */
   20.75                          if (modeinfo.primary_format ==
   20.76 @@ -708,7 +703,7 @@
   20.77                              mode.refresh_rate = modeinfo.refresh[jt];
   20.78                              mode.format = SDL_PIXELFORMAT_RGB555;
   20.79                              mode.driverdata = NULL;
   20.80 -                            SDL_AddDisplayMode(_this->current_display, &mode);
   20.81 +                            SDL_AddDisplayMode(display, &mode);
   20.82                          }
   20.83  
   20.84                          jt++;
   20.85 @@ -731,10 +726,9 @@
   20.86  }
   20.87  
   20.88  int
   20.89 -qnxgf_setdisplaymode(_THIS, SDL_DisplayMode * mode)
   20.90 +qnxgf_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
   20.91  {
   20.92 -    SDL_DisplayData *didata =
   20.93 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
   20.94 +    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
   20.95      uint32_t refresh_rate = 0;
   20.96      int status;
   20.97  
   20.98 @@ -760,15 +754,15 @@
   20.99          tempmode.refresh_rate = 0x0000FFFF;
  20.100  
  20.101          /* Check if window width and height matches one of our modes */
  20.102 -        for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) {
  20.103 -            if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) &&
  20.104 -                (SDL_CurrentDisplay.display_modes[it].h == mode->h) &&
  20.105 -                (SDL_CurrentDisplay.display_modes[it].format == mode->format))
  20.106 +        for (it = 0; it < display->num_display_modes; it++) {
  20.107 +            if ((display->display_modes[it].w == mode->w) &&
  20.108 +                (display->display_modes[it].h == mode->h) &&
  20.109 +                (display->display_modes[it].format == mode->format))
  20.110              {
  20.111                  /* Find the lowest refresh rate available */
  20.112                  if (tempmode.refresh_rate >
  20.113 -                    SDL_CurrentDisplay.display_modes[it].refresh_rate) {
  20.114 -                    tempmode = SDL_CurrentDisplay.display_modes[it];
  20.115 +                    display->display_modes[it].refresh_rate) {
  20.116 +                    tempmode = display->display_modes[it];
  20.117                  }
  20.118              }
  20.119          }
  20.120 @@ -790,21 +784,21 @@
  20.121          tempmode.refresh_rate = 0x0000FFFF;
  20.122  
  20.123          /* Check if window width and height matches one of our modes */
  20.124 -        for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) {
  20.125 -            if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) &&
  20.126 -                (SDL_CurrentDisplay.display_modes[it].h == mode->h) &&
  20.127 -                (SDL_CurrentDisplay.display_modes[it].format == mode->format))
  20.128 +        for (it = 0; it < display->num_display_modes; it++) {
  20.129 +            if ((display->display_modes[it].w == mode->w) &&
  20.130 +                (display->display_modes[it].h == mode->h) &&
  20.131 +                (display->display_modes[it].format == mode->format))
  20.132              {
  20.133                  /* Find the lowest refresh rate available */
  20.134                  if (tempmode.refresh_rate >
  20.135 -                    SDL_CurrentDisplay.display_modes[it].refresh_rate) {
  20.136 -                    tempmode = SDL_CurrentDisplay.display_modes[it];
  20.137 +                    display->display_modes[it].refresh_rate) {
  20.138 +                    tempmode = display->display_modes[it];
  20.139                  }
  20.140  
  20.141                  /* Check if requested refresh rate found */
  20.142                  if (refresh_rate ==
  20.143 -                    SDL_CurrentDisplay.display_modes[it].refresh_rate) {
  20.144 -                    tempmode = SDL_CurrentDisplay.display_modes[it];
  20.145 +                    display->display_modes[it].refresh_rate) {
  20.146 +                    tempmode = display->display_modes[it];
  20.147                      break;
  20.148                  }
  20.149              }
  20.150 @@ -928,36 +922,33 @@
  20.151  }
  20.152  
  20.153  int
  20.154 -qnxgf_setdisplaypalette(_THIS, SDL_Palette * palette)
  20.155 +qnxgf_setdisplaypalette(_THIS, SDL_VideoDisplay * display, SDL_Palette * palette)
  20.156  {
  20.157 -    SDL_DisplayData *didata =
  20.158 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
  20.159 +    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
  20.160  
  20.161      /* QNX GF doesn't have support for global palette changing, but we */
  20.162      /* could store it for usage in future */
  20.163  
  20.164 -    /* Setting display palette operation has been failed */
  20.165 +    SDL_Unsupported();
  20.166      return -1;
  20.167  }
  20.168  
  20.169  int
  20.170 -qnxgf_getdisplaypalette(_THIS, SDL_Palette * palette)
  20.171 +qnxgf_getdisplaypalette(_THIS, SDL_VideoDisplay * display, SDL_Palette * palette)
  20.172  {
  20.173 -    SDL_DisplayData *didata =
  20.174 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
  20.175 +    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
  20.176  
  20.177      /* We can't provide current palette settings and looks like SDL          */
  20.178      /* do not call this function also, in such case this function returns -1 */
  20.179  
  20.180 -    /* Getting display palette operation has been failed */
  20.181 +    SDL_Unsupported();
  20.182      return -1;
  20.183  }
  20.184  
  20.185  int
  20.186 -qnxgf_setdisplaygammaramp(_THIS, Uint16 * ramp)
  20.187 +qnxgf_setdisplaygammaramp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
  20.188  {
  20.189 -    SDL_DisplayData *didata =
  20.190 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
  20.191 +    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
  20.192      int status;
  20.193  
  20.194      /* Setup gamma ramp, for each color channel */
  20.195 @@ -974,12 +965,12 @@
  20.196  }
  20.197  
  20.198  int
  20.199 -qnxgf_getdisplaygammaramp(_THIS, Uint16 * ramp)
  20.200 +qnxgf_getdisplaygammaramp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
  20.201  {
  20.202      /* TODO: We need to return previous gamma set           */
  20.203      /*       Also we need some initial fake gamma to return */
  20.204  
  20.205 -    /* Getting display gamma ramp operation has been failed */
  20.206 +    SDL_Unsupported();
  20.207      return -1;
  20.208  }
  20.209  
  20.210 @@ -987,8 +978,8 @@
  20.211  qnxgf_createwindow(_THIS, SDL_Window * window)
  20.212  {
  20.213      SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
  20.214 -    SDL_DisplayData *didata =
  20.215 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
  20.216 +    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
  20.217 +    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
  20.218      SDL_WindowData *wdata;
  20.219      int32_t status;
  20.220  
  20.221 @@ -1002,15 +993,15 @@
  20.222          mode.refresh_rate = 0x0000FFFF;
  20.223  
  20.224          /* Check if window width and height matches one of our modes */
  20.225 -        for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) {
  20.226 -            if ((SDL_CurrentDisplay.display_modes[it].w == window->w) &&
  20.227 -                (SDL_CurrentDisplay.display_modes[it].h == window->h) &&
  20.228 -                (SDL_CurrentDisplay.display_modes[it].format ==
  20.229 -                 SDL_CurrentDisplay.desktop_mode.format)) {
  20.230 +        for (it = 0; it < display->num_display_modes; it++) {
  20.231 +            if ((display->display_modes[it].w == window->w) &&
  20.232 +                (display->display_modes[it].h == window->h) &&
  20.233 +                (display->display_modes[it].format ==
  20.234 +                 display->desktop_mode.format)) {
  20.235                  /* Find the lowest refresh rate available */
  20.236                  if (mode.refresh_rate >
  20.237 -                    SDL_CurrentDisplay.display_modes[it].refresh_rate) {
  20.238 -                    mode = SDL_CurrentDisplay.display_modes[it];
  20.239 +                    display->display_modes[it].refresh_rate) {
  20.240 +                    mode = display->display_modes[it];
  20.241                  }
  20.242              }
  20.243          }
  20.244 @@ -1164,7 +1155,7 @@
  20.245  {
  20.246      SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
  20.247      SDL_DisplayData *didata =
  20.248 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
  20.249 +        (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
  20.250      SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
  20.251  
  20.252      if (wdata != NULL) {
  20.253 @@ -1318,7 +1309,7 @@
  20.254      SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
  20.255      SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
  20.256      SDL_DisplayData *didata =
  20.257 -        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
  20.258 +        (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
  20.259      EGLBoolean status;
  20.260      int32_t gfstatus;
  20.261      EGLint configs;
    21.1 --- a/src/video/win32/SDL_win32gamma.c	Mon Nov 30 21:04:25 2009 +0000
    21.2 +++ b/src/video/win32/SDL_win32gamma.c	Tue Dec 01 05:57:15 2009 +0000
    21.3 @@ -25,12 +25,12 @@
    21.4  
    21.5  
    21.6  int
    21.7 -WIN_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
    21.8 +WIN_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
    21.9  {
   21.10  #ifdef _WIN32_WCE
   21.11      return -1;
   21.12  #else
   21.13 -    SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
   21.14 +    SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
   21.15      HDC hdc;
   21.16      BOOL succeeded = FALSE;
   21.17  
   21.18 @@ -47,12 +47,12 @@
   21.19  }
   21.20  
   21.21  int
   21.22 -WIN_GetDisplayGammaRamp(_THIS, Uint16 * ramp)
   21.23 +WIN_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
   21.24  {
   21.25  #ifdef _WIN32_WCE
   21.26      return -1;
   21.27  #else
   21.28 -    SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
   21.29 +    SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
   21.30      HDC hdc;
   21.31      BOOL succeeded = FALSE;
   21.32  
    22.1 --- a/src/video/win32/SDL_win32gamma.h	Mon Nov 30 21:04:25 2009 +0000
    22.2 +++ b/src/video/win32/SDL_win32gamma.h	Tue Dec 01 05:57:15 2009 +0000
    22.3 @@ -24,8 +24,8 @@
    22.4  #ifndef _SDL_win32gamma_h
    22.5  #define _SDL_win32gamma_h
    22.6  
    22.7 -extern int WIN_SetDisplayGammaRamp(_THIS, Uint16 * ramp);
    22.8 -extern int WIN_GetDisplayGammaRamp(_THIS, Uint16 * ramp);
    22.9 +extern int WIN_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
   22.10 +extern int WIN_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
   22.11  
   22.12  #endif /* _SDL_win32gamma_h */
   22.13  
    23.1 --- a/src/video/win32/SDL_win32modes.c	Mon Nov 30 21:04:25 2009 +0000
    23.2 +++ b/src/video/win32/SDL_win32modes.c	Tue Dec 01 05:57:15 2009 +0000
    23.3 @@ -41,7 +41,6 @@
    23.4      if (!data) {
    23.5          return SDL_FALSE;
    23.6      }
    23.7 -    SDL_memcpy(data->DeviceName, deviceName, sizeof(data->DeviceName));
    23.8      data->DeviceMode = devmode;
    23.9      data->DeviceMode.dmFields =
   23.10          (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY |
   23.11 @@ -196,9 +195,9 @@
   23.12  }
   23.13  
   23.14  void
   23.15 -WIN_GetDisplayModes(_THIS)
   23.16 +WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
   23.17  {
   23.18 -    SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
   23.19 +    SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
   23.20      DWORD i;
   23.21      SDL_DisplayMode mode;
   23.22  
   23.23 @@ -207,15 +206,16 @@
   23.24              break;
   23.25          }
   23.26          if (mode.format != SDL_PIXELFORMAT_UNKNOWN)
   23.27 -            if (!SDL_AddDisplayMode(_this->current_display, &mode)) {
   23.28 +            if (!SDL_AddDisplayMode(display, &mode)) {
   23.29                  SDL_free(mode.driverdata);
   23.30              }
   23.31      }
   23.32  }
   23.33  
   23.34  int
   23.35 -WIN_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
   23.36 +WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
   23.37  {
   23.38 +    SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
   23.39      SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
   23.40      LONG status;
   23.41  
   23.42 @@ -228,8 +228,8 @@
   23.43  #endif
   23.44  
   23.45      status =
   23.46 -        ChangeDisplaySettingsEx(data->DeviceName, &data->DeviceMode, NULL,
   23.47 -                                CDS_FULLSCREEN, NULL);
   23.48 +        ChangeDisplaySettingsEx(displaydata->DeviceName, &data->DeviceMode,
   23.49 +                                NULL, CDS_FULLSCREEN, NULL);
   23.50      if (status == DISP_CHANGE_SUCCESSFUL) {
   23.51          return 0;
   23.52      } else {
    24.1 --- a/src/video/win32/SDL_win32modes.h	Mon Nov 30 21:04:25 2009 +0000
    24.2 +++ b/src/video/win32/SDL_win32modes.h	Tue Dec 01 05:57:15 2009 +0000
    24.3 @@ -31,13 +31,12 @@
    24.4  
    24.5  typedef struct
    24.6  {
    24.7 -    TCHAR DeviceName[32];
    24.8      DEVMODE DeviceMode;
    24.9  } SDL_DisplayModeData;
   24.10  
   24.11  extern void WIN_InitModes(_THIS);
   24.12 -extern void WIN_GetDisplayModes(_THIS);
   24.13 -extern int WIN_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
   24.14 +extern void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
   24.15 +extern int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
   24.16  extern void WIN_QuitModes(_THIS);
   24.17  
   24.18  #endif /* _SDL_win32modes_h */
    25.1 --- a/src/video/x11/SDL_x11gamma.c	Mon Nov 30 21:04:25 2009 +0000
    25.2 +++ b/src/video/x11/SDL_x11gamma.c	Tue Dec 01 05:57:15 2009 +0000
    25.3 @@ -124,7 +124,7 @@
    25.4     cool. If not, then we just fail  */
    25.5  
    25.6  int
    25.7 -X11_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
    25.8 +X11_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * sdl_display, Uint16 * ramp)
    25.9  {
   25.10      Visual *visual;
   25.11      Display *display;
   25.12 @@ -214,7 +214,7 @@
   25.13  }
   25.14  
   25.15  int
   25.16 -X11_GetDisplayGammaRamp(_THIS, Uint16 * ramp)
   25.17 +X11_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
   25.18  {
   25.19      int i;
   25.20  
    26.1 --- a/src/video/x11/SDL_x11gamma.h	Mon Nov 30 21:04:25 2009 +0000
    26.2 +++ b/src/video/x11/SDL_x11gamma.h	Tue Dec 01 05:57:15 2009 +0000
    26.3 @@ -30,7 +30,7 @@
    26.4                                Colormap colormap,
    26.5                                Visual * visual, XColor * ramp);
    26.6  
    26.7 -extern int X11_SetDisplayGammaRamp(_THIS, Uint16 * ramp);
    26.8 -extern int X11_GetDisplayGammaRamp(_THIS, Uint16 * ramp);
    26.9 +extern int X11_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
   26.10 +extern int X11_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
   26.11  
   26.12  #endif
    27.1 --- a/src/video/x11/SDL_x11modes.c	Mon Nov 30 21:04:25 2009 +0000
    27.2 +++ b/src/video/x11/SDL_x11modes.c	Tue Dec 01 05:57:15 2009 +0000
    27.3 @@ -311,10 +311,10 @@
    27.4  #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
    27.5  
    27.6  void
    27.7 -X11_GetDisplayModes(_THIS)
    27.8 +X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
    27.9  {
   27.10      Display *display = ((SDL_VideoData *) _this->driverdata)->display;
   27.11 -    SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
   27.12 +    SDL_DisplayData *data = (SDL_DisplayData *) sdl_display->driverdata;
   27.13  #if SDL_VIDEO_DRIVER_X11_XINERAMA
   27.14      int xinerama_major, xinerama_minor;
   27.15      int screens;
   27.16 @@ -341,7 +341,7 @@
   27.17       * we have to use the same format for all windows and all display modes.
   27.18       * (or support recreating the window with a new visual behind the scenes)
   27.19       */
   27.20 -    mode.format = SDL_CurrentDisplay.current_mode.format;
   27.21 +    mode.format = sdl_display->current_mode.format;
   27.22      mode.driverdata = NULL;
   27.23  
   27.24      data->use_xinerama = 0;
   27.25 @@ -382,14 +382,14 @@
   27.26                  mode.w = screen_w;
   27.27                  mode.h = screen_h;
   27.28                  mode.refresh_rate = 0;
   27.29 -                SDL_AddDisplayMode(_this->current_display, &mode);
   27.30 +                SDL_AddDisplayMode(sdl_display, &mode);
   27.31              }
   27.32  
   27.33              /* Add the head xinerama mode */
   27.34              mode.w = data->xinerama_info.width;
   27.35              mode.h = data->xinerama_info.height;
   27.36              mode.refresh_rate = 0;
   27.37 -            SDL_AddDisplayMode(_this->current_display, &mode);
   27.38 +            SDL_AddDisplayMode(sdl_display, &mode);
   27.39          }
   27.40      }
   27.41  #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
   27.42 @@ -426,7 +426,7 @@
   27.43                              "XRANDR: mode = %4d[%d], w = %4d, h = %4d, rate = %4d\n",
   27.44                              i, j, mode.w, mode.h, mode.refresh_rate);
   27.45  #endif
   27.46 -                    SDL_AddDisplayMode(_this->current_display, &mode);
   27.47 +                    SDL_AddDisplayMode(sdl_display, &mode);
   27.48                  }
   27.49              }
   27.50  
   27.51 @@ -462,7 +462,7 @@
   27.52              mode.w = modes[i]->hdisplay;
   27.53              mode.h = modes[i]->vdisplay;
   27.54              mode.refresh_rate = calculate_rate(modes[i]);
   27.55 -            SDL_AddDisplayMode(_this->current_display, &mode);
   27.56 +            SDL_AddDisplayMode(sdl_display, &mode);
   27.57          }
   27.58          XFree(modes);
   27.59  
   27.60 @@ -475,7 +475,7 @@
   27.61          mode.w = screen_w;
   27.62          mode.h = screen_h;
   27.63          mode.refresh_rate = 0;
   27.64 -        SDL_AddDisplayMode(_this->current_display, &mode);
   27.65 +        SDL_AddDisplayMode(sdl_display, &mode);
   27.66      }
   27.67  #ifdef X11MODES_DEBUG
   27.68      if (data->use_xinerama) {
   27.69 @@ -672,10 +672,10 @@
   27.70  }
   27.71  
   27.72  int
   27.73 -X11_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
   27.74 +X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode)
   27.75  {
   27.76      Display *display = ((SDL_VideoData *) _this->driverdata)->display;
   27.77 -    SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
   27.78 +    SDL_DisplayData *data = (SDL_DisplayData *) sdl_display->driverdata;
   27.79  
   27.80      set_best_resolution(display, data, mode->w, mode->h, mode->refresh_rate);
   27.81      return 0;
    28.1 --- a/src/video/x11/SDL_x11modes.h	Mon Nov 30 21:04:25 2009 +0000
    28.2 +++ b/src/video/x11/SDL_x11modes.h	Tue Dec 01 05:57:15 2009 +0000
    28.3 @@ -55,8 +55,8 @@
    28.4  } SDL_DisplayData;
    28.5  
    28.6  extern void X11_InitModes(_THIS);
    28.7 -extern void X11_GetDisplayModes(_THIS);
    28.8 -extern int X11_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
    28.9 +extern void X11_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
   28.10 +extern int X11_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
   28.11  extern void X11_QuitModes(_THIS);
   28.12  
   28.13  #endif /* _SDL_x11modes_h */
    29.1 --- a/test/common.c	Mon Nov 30 21:04:25 2009 +0000
    29.2 +++ b/test/common.c	Tue Dec 01 05:57:15 2009 +0000
    29.3 @@ -76,7 +76,7 @@
    29.4      state->argv = argv;
    29.5      state->flags = flags;
    29.6      state->window_title = argv[0];
    29.7 -    state->window_flags = SDL_WINDOW_SHOWN;
    29.8 +    state->window_flags = 0;
    29.9      state->window_x = SDL_WINDOWPOS_UNDEFINED;
   29.10      state->window_y = SDL_WINDOWPOS_UNDEFINED;
   29.11      state->window_w = DEFAULT_WINDOW_WIDTH;
   29.12 @@ -737,6 +737,7 @@
   29.13              }
   29.14          }
   29.15  
   29.16 +        SDL_zero(fullscreen_mode);
   29.17          switch (state->depth) {
   29.18          case 8:
   29.19              fullscreen_mode.format = SDL_PIXELFORMAT_INDEX8;
   29.20 @@ -754,14 +755,7 @@
   29.21              fullscreen_mode.format = SDL_PIXELFORMAT_RGB888;
   29.22              break;
   29.23          }
   29.24 -        fullscreen_mode.w = state->window_w;
   29.25 -        fullscreen_mode.h = state->window_h;
   29.26          fullscreen_mode.refresh_rate = state->refresh_rate;
   29.27 -        if (SDL_SetFullscreenDisplayMode(&fullscreen_mode)<0) {
   29.28 -            fprintf(stderr, "Can't switch to fullscreen display mode: %s\n",
   29.29 -                    SDL_GetError());
   29.30 -            return SDL_FALSE;
   29.31 -        }
   29.32  
   29.33          state->windows =
   29.34              (SDL_WindowID *) SDL_malloc(state->num_windows *
   29.35 @@ -789,6 +783,13 @@
   29.36                  return SDL_FALSE;
   29.37              }
   29.38  
   29.39 +            if (SDL_SetWindowDisplayMode(state->windows[i], &fullscreen_mode) < 0) {
   29.40 +                fprintf(stderr, "Can't set up fullscreen display mode: %s\n",
   29.41 +                        SDL_GetError());
   29.42 +                return SDL_FALSE;
   29.43 +            }
   29.44 +            SDL_ShowWindow(state->windows[i]);
   29.45 +
   29.46              if (!state->skip_renderer
   29.47                  && (state->renderdriver
   29.48                      || !(state->window_flags & SDL_WINDOW_OPENGL))) {