Commit 1cd715e9 authored by Sam Lantinga's avatar Sam Lantinga

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.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404241
parent 3e860cdc
......@@ -50,7 +50,8 @@ extern "C" {
* \sa SDL_GetDesktopDisplayMode()
* \sa SDL_GetCurrentDisplayMode()
* \sa SDL_GetClosestDisplayMode()
* \sa SDL_SetDisplayMode()
* \sa SDL_SetWindowDisplayMode()
* \sa SDL_GetWindowDisplayMode()
*/
typedef struct
{
......@@ -427,23 +428,25 @@ extern DECLSPEC SDL_DisplayMode *SDLCALL SDL_GetClosestDisplayMode(const
/**
* \brief Set the display mode used when a fullscreen window is visible
* on the currently selected display.
* on the currently selected display. By default the window's
* dimensions and the desktop format and refresh rate are used.
*
* \param mode The mode to use, or NULL for the desktop mode.
* \param mode The mode to use, or NULL for the default mode.
*
* \return 0 on success, or -1 if setting the display mode failed.
*
* \sa SDL_SetWindowFullscreen()
*/
extern DECLSPEC int SDLCALL SDL_SetFullscreenDisplayMode(const SDL_DisplayMode
extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_WindowID windowID,
const SDL_DisplayMode
* mode);
/**
* \brief Fill in information about the display mode used when a fullscreen
* window is visible on the currently selected display.
*/
extern DECLSPEC int SDLCALL SDL_GetFullscreenDisplayMode(SDL_DisplayMode *
mode);
extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_WindowID windowID,
SDL_DisplayMode * mode);
/**
* \brief Set the palette entries for indexed display modes.
......@@ -680,7 +683,7 @@ extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_WindowID windowID);
*
* \return 0 on success, or -1 if setting the display mode failed.
*
* \sa SDL_SetFullscreenDisplayMode()
* \sa SDL_WindowDisplayMode()
*/
extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_WindowID windowID,
int fullscreen);
......
......@@ -482,7 +482,6 @@ SDL_Surface *
SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
{
SDL_DisplayMode desktop_mode;
SDL_DisplayMode mode;
int window_x = SDL_WINDOWPOS_UNDEFINED;
int window_y = SDL_WINDOWPOS_UNDEFINED;
Uint32 window_flags;
......@@ -552,7 +551,6 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
window_flags |= SDL_WINDOW_BORDERLESS;
}
GetEnvironmentWindowPosition(width, height, &window_x, &window_y);
SDL_SetFullscreenDisplayMode(NULL);
SDL_VideoWindow =
SDL_CreateWindow(wm_title, window_x, window_y, width, height,
window_flags);
......@@ -611,14 +609,14 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
return NULL;
}
}
mode.format = desired_format;
mode.w = width;
mode.h = height;
mode.refresh_rate = 0;
/* Set the desired display mode */
/* Set up the desired display mode */
if (flags & SDL_FULLSCREEN) {
if (SDL_SetFullscreenDisplayMode(&mode) < 0) {
SDL_DisplayMode mode;
SDL_zero(mode);
mode.format = desired_format;
if (SDL_SetWindowDisplayMode(SDL_VideoWindow, &mode) < 0) {
return NULL;
}
}
......
......@@ -113,30 +113,39 @@ SDL_GetGamma(float *red, float *green, float *blue)
return succeeded;
}
static void
SDL_UninitializedVideo()
{
SDL_SetError("Video subsystem has not been initialized");
}
int
SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green,
const Uint16 * blue)
SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
int succeeded;
if (!_this) {
SDL_UninitializedVideo();
return -1;
}
/* Lazily allocate the gamma tables */
if (!SDL_CurrentDisplay.gamma) {
SDL_GetGammaRamp(NULL, NULL, NULL);
if (!display->gamma) {
if (SDL_GetGammaRampForDisplay(display, NULL, NULL, NULL) < 0) {
return -1;
}
}
/* Fill the gamma table with the new values */
if (red) {
SDL_memcpy(&SDL_CurrentDisplay.gamma[0 * 256], red,
256 * sizeof(*SDL_CurrentDisplay.gamma));
SDL_memcpy(&display->gamma[0 * 256], red, 256 * sizeof(*display->gamma));
}
if (green) {
SDL_memcpy(&SDL_CurrentDisplay.gamma[1 * 256], green,
256 * sizeof(*SDL_CurrentDisplay.gamma));
SDL_memcpy(&display->gamma[1 * 256], green, 256 * sizeof(*display->gamma));
}
if (blue) {
SDL_memcpy(&SDL_CurrentDisplay.gamma[2 * 256], blue,
256 * sizeof(*SDL_CurrentDisplay.gamma));
SDL_memcpy(&display->gamma[2 * 256], blue, 256 * sizeof(*display->gamma));
}
/* Try to set the gamma ramp in the driver */
......@@ -144,7 +153,7 @@ SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green,
if (_this && _this->SetDisplayGammaRamp) {
if (SDL_GetFocusWindow()) {
succeeded =
_this->SetDisplayGammaRamp(_this, SDL_CurrentDisplay.gamma);
_this->SetDisplayGammaRamp(_this, display, display->gamma);
} else {
succeeded = 0;
}
......@@ -155,50 +164,73 @@ SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green,
}
int
SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue)
SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green, const Uint16 * blue)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (!_this) {
SDL_UninitializedVideo();
return -1;
}
return SDL_SetGammaRampForDisplay(&SDL_CurrentDisplay, red, green, blue);
}
int
SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (!_this) {
SDL_UninitializedVideo();
return -1;
}
/* Lazily allocate the gamma table */
if (!SDL_CurrentDisplay.gamma) {
size_t rampsize = (3 * 256 * sizeof(*SDL_CurrentDisplay.gamma));
if (!display->gamma) {
size_t rampsize = (3 * 256 * sizeof(*display->gamma));
SDL_CurrentDisplay.gamma = SDL_malloc(rampsize * 2);
if (!SDL_CurrentDisplay.gamma) {
display->gamma = SDL_malloc(rampsize * 2);
if (!display->gamma) {
SDL_OutOfMemory();
return -1;
}
if (_this && _this->GetDisplayGammaRamp) {
/* Get the real hardware gamma */
_this->GetDisplayGammaRamp(_this, SDL_CurrentDisplay.gamma);
_this->GetDisplayGammaRamp(_this, display, display->gamma);
} else {
/* Assume an identity gamma */
int i;
for (i = 0; i < 256; ++i) {
SDL_CurrentDisplay.gamma[0 * 256 + i] = (i << 8) | i;
SDL_CurrentDisplay.gamma[1 * 256 + i] = (i << 8) | i;
SDL_CurrentDisplay.gamma[2 * 256 + i] = (i << 8) | i;
display->gamma[0 * 256 + i] = (i << 8) | i;
display->gamma[1 * 256 + i] = (i << 8) | i;
display->gamma[2 * 256 + i] = (i << 8) | i;
}
}
SDL_CurrentDisplay.saved_gamma = SDL_CurrentDisplay.gamma + (3 * 256);
SDL_memcpy(SDL_CurrentDisplay.saved_gamma, SDL_CurrentDisplay.gamma,
rampsize);
display->saved_gamma = display->gamma + (3 * 256);
SDL_memcpy(display->saved_gamma, display->gamma, rampsize);
}
/* Just copy from our internal table */
if (red) {
SDL_memcpy(red, &SDL_CurrentDisplay.gamma[0 * 256],
256 * sizeof(*red));
SDL_memcpy(red, &display->gamma[0 * 256], 256 * sizeof(*red));
}
if (green) {
SDL_memcpy(green, &SDL_CurrentDisplay.gamma[1 * 256],
256 * sizeof(*green));
SDL_memcpy(green, &display->gamma[1 * 256], 256 * sizeof(*green));
}
if (blue) {
SDL_memcpy(blue, &SDL_CurrentDisplay.gamma[2 * 256],
256 * sizeof(*blue));
SDL_memcpy(blue, &display->gamma[2 * 256], 256 * sizeof(*blue));
}
return 0;
}
int
SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (!_this) {
SDL_UninitializedVideo();
return -1;
}
return SDL_GetGammaRampForDisplay(&SDL_CurrentDisplay, red, green, blue);
}
/* vi: set ts=4 sw=4 expandtab: */
......@@ -139,6 +139,8 @@ struct SDL_Window
int display;
SDL_Renderer *renderer;
SDL_DisplayMode fullscreen_mode;
void *userdata;
void *driverdata;
};
......@@ -158,7 +160,6 @@ struct SDL_VideoDisplay
SDL_DisplayMode *display_modes;
SDL_DisplayMode desktop_mode;
SDL_DisplayMode current_mode;
SDL_DisplayMode fullscreen_mode;
SDL_Palette *palette;
Uint16 *gamma;
......@@ -213,7 +214,7 @@ struct SDL_VideoDevice
* Get a list of the available display modes. e.g.
* SDL_AddDisplayMode(_this->current_display, mode)
*/
void (*GetDisplayModes) (_THIS);
void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display);
/*
* Setting the display mode is independent of creating windows, so
......@@ -221,19 +222,19 @@ struct SDL_VideoDevice
* their data updated accordingly, including the display surfaces
* associated with them.
*/
int (*SetDisplayMode) (_THIS, SDL_DisplayMode * mode);
int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
/* Set the color entries of the display palette */
int (*SetDisplayPalette) (_THIS, SDL_Palette * palette);
int (*SetDisplayPalette) (_THIS, SDL_VideoDisplay * display, SDL_Palette * palette);
/* Get the color entries of the display palette */
int (*GetDisplayPalette) (_THIS, SDL_Palette * palette);
int (*GetDisplayPalette) (_THIS, SDL_VideoDisplay * display, SDL_Palette * palette);
/* Set the gamma ramp */
int (*SetDisplayGammaRamp) (_THIS, Uint16 * ramp);
int (*SetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
/* Get the gamma ramp */
int (*GetDisplayGammaRamp) (_THIS, Uint16 * ramp);
int (*GetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
/* * * */
/*
......@@ -405,10 +406,19 @@ extern VideoBootStrap PND_bootstrap;
extern SDL_VideoDevice *SDL_GetVideoDevice();
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
extern SDL_bool
SDL_AddDisplayMode(int displayIndex, const SDL_DisplayMode * mode);
extern void
SDL_AddRenderDriver(int displayIndex, const SDL_RenderDriver * driver);
extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
extern int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display);
extern int SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayMode * mode);
extern int SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern int SDL_GetCurrentDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
extern int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode);
extern int SDL_SetDisplayPaletteForDisplay(SDL_VideoDisplay * display, const SDL_Color * colors, int firstcolor, int ncolors);
extern int SDL_GetDisplayPaletteForDisplay(SDL_VideoDisplay * display, SDL_Color * colors, int firstcolor, int ncolors);
extern void SDL_AddRenderDriver(SDL_VideoDisplay *display, const SDL_RenderDriver * driver);
extern int SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue);
extern int SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue);
extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
extern SDL_Window *SDL_GetWindowFromID(SDL_WindowID windowID);
......
......@@ -256,16 +256,17 @@ SDL_VideoInit(const char *driver_name, Uint32 flags)
}
/* The software renderer is always available */
for (i = 0; i < _this->num_displays; ++i) {
SDL_VideoDisplay *display = &_this->displays[i];
if (_this->GL_CreateContext) {
#if SDL_VIDEO_RENDER_OGL
SDL_AddRenderDriver(i, &GL_RenderDriver);
SDL_AddRenderDriver(display, &GL_RenderDriver);
#endif
#if SDL_VIDEO_RENDER_OGL_ES
SDL_AddRenderDriver(i, &GL_ES_RenderDriver);
SDL_AddRenderDriver(display, &GL_ES_RenderDriver);
#endif
}
if (_this->displays[i].num_render_drivers > 0) {
SDL_AddRenderDriver(i, &SW_RenderDriver);
if (display->num_render_drivers > 0) {
SDL_AddRenderDriver(display, &SW_RenderDriver);
}
}
......@@ -360,9 +361,8 @@ SDL_GetCurrentVideoDisplay(void)
}
SDL_bool
SDL_AddDisplayMode(int displayIndex, const SDL_DisplayMode * mode)
SDL_AddDisplayMode(SDL_VideoDisplay * display, const SDL_DisplayMode * mode)
{
SDL_VideoDisplay *display = &_this->displays[displayIndex];
SDL_DisplayMode *modes;
int i, nmodes;
......@@ -396,31 +396,51 @@ SDL_AddDisplayMode(int displayIndex, const SDL_DisplayMode * mode)
return SDL_TRUE;
}
int
SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display)
{
if (!display->num_display_modes && _this->GetDisplayModes) {
_this->GetDisplayModes(_this, display);
SDL_qsort(display->display_modes, display->num_display_modes,
sizeof(SDL_DisplayMode), cmpmodes);
}
return display->num_display_modes;
}
int
SDL_GetNumDisplayModes()
{
if (_this) {
SDL_VideoDisplay *display = &SDL_CurrentDisplay;
if (!display->num_display_modes && _this->GetDisplayModes) {
_this->GetDisplayModes(_this);
SDL_qsort(display->display_modes, display->num_display_modes,
sizeof(SDL_DisplayMode), cmpmodes);
}
return display->num_display_modes;
return SDL_GetNumDisplayModesForDisplay(&SDL_CurrentDisplay);
}
return 0;
}
int
SDL_GetDisplayMode(int index, SDL_DisplayMode * mode)
SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayMode * mode)
{
if (index < 0 || index >= SDL_GetNumDisplayModes()) {
if (index < 0 || index >= SDL_GetNumDisplayModesForDisplay(display)) {
SDL_SetError("index must be in the range of 0 - %d",
SDL_GetNumDisplayModes() - 1);
SDL_GetNumDisplayModesForDisplay(display) - 1);
return -1;
}
if (mode) {
*mode = SDL_CurrentDisplay.display_modes[index];
*mode = display->display_modes[index];
}
return 0;
}
int
SDL_GetDisplayMode(int index, SDL_DisplayMode * mode)
{
return SDL_GetDisplayModeForDisplay(&SDL_CurrentDisplay, index, mode);
}
int
SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
if (mode) {
*mode = display->desktop_mode;
}
return 0;
}
......@@ -432,8 +452,14 @@ SDL_GetDesktopDisplayMode(SDL_DisplayMode * mode)
SDL_UninitializedVideo();
return -1;
}
return SDL_GetDesktopDisplayModeForDisplay(&SDL_CurrentDisplay, mode);
}
int
SDL_GetCurrentDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
if (mode) {
*mode = SDL_CurrentDisplay.desktop_mode;
*mode = display->current_mode;
}
return 0;
}
......@@ -445,41 +471,41 @@ SDL_GetCurrentDisplayMode(SDL_DisplayMode * mode)
SDL_UninitializedVideo();
return -1;
}
if (mode) {
*mode = SDL_CurrentDisplay.current_mode;
}
return 0;
return SDL_GetCurrentDisplayModeForDisplay(&SDL_CurrentDisplay, mode);
}
SDL_DisplayMode *
SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode,
SDL_DisplayMode * closest)
SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display,
const SDL_DisplayMode * mode,
SDL_DisplayMode * closest)
{
Uint32 target_format;
int target_refresh_rate;
int i;
SDL_DisplayMode *current, *match;
if (!_this || !mode || !closest) {
if (!mode || !closest) {
SDL_SetError("Missing desired mode or closest mode parameter");
return NULL;
}
/* Default to the desktop format */
if (mode->format) {
target_format = mode->format;
} else {
target_format = SDL_CurrentDisplay.desktop_mode.format;
target_format = display->desktop_mode.format;
}
/* Default to the desktop refresh rate */
if (mode->refresh_rate) {
target_refresh_rate = mode->refresh_rate;
} else {
target_refresh_rate = SDL_CurrentDisplay.desktop_mode.refresh_rate;
target_refresh_rate = display->desktop_mode.refresh_rate;
}
match = NULL;
for (i = 0; i < SDL_GetNumDisplayModes(); ++i) {
current = &SDL_CurrentDisplay.display_modes[i];
for (i = 0; i < SDL_GetNumDisplayModesForDisplay(display); ++i) {
current = &display->display_modes[i];
if (current->w && (current->w < mode->w)) {
/* Out of sorted modes large enough here */
......@@ -555,19 +581,24 @@ SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode,
return NULL;
}
SDL_DisplayMode *
SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode,
SDL_DisplayMode * closest)
{
if (!_this) {
SDL_UninitializedVideo();
return NULL;
}
return SDL_GetClosestDisplayModeForDisplay(&SDL_CurrentDisplay, mode, closest);
}
int
SDL_SetDisplayMode(const SDL_DisplayMode * mode)
SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode)
{
SDL_VideoDisplay *display;
SDL_DisplayMode display_mode;
SDL_DisplayMode current_mode;
int i, ncolors;
if (!_this) {
SDL_UninitializedVideo();
return -1;
}
display = &SDL_CurrentDisplay;
if (!mode) {
mode = &display->desktop_mode;
}
......@@ -586,19 +617,22 @@ SDL_SetDisplayMode(const SDL_DisplayMode * mode)
if (!display_mode.refresh_rate) {
display_mode.refresh_rate = display->current_mode.refresh_rate;
}
/* Get a good video mode, the closest one possible */
if (!SDL_GetClosestDisplayMode(&display_mode, &display_mode)) {
if (!SDL_GetClosestDisplayModeForDisplay(display, &display_mode, &display_mode)) {
SDL_SetError("No video mode large enough for %dx%d",
display_mode.w, display_mode.h);
return -1;
}
/* See if there's anything left to do */
SDL_GetCurrentDisplayMode(&current_mode);
SDL_GetCurrentDisplayModeForDisplay(display, &current_mode);
if (SDL_memcmp(&display_mode, &current_mode, sizeof(display_mode)) == 0) {
return 0;
}
/* Actually change the display mode */
if (_this->SetDisplayMode(_this, &display_mode) < 0) {
if (_this->SetDisplayMode(_this, display, &display_mode) < 0) {
return -1;
}
display->current_mode = display_mode;
......@@ -624,84 +658,74 @@ SDL_SetDisplayMode(const SDL_DisplayMode * mode)
SDL_BITSPERPIXEL(display_mode.format));
}
}
/* Move any fullscreen windows into position */
for (i = 0; i < display->num_windows; ++i) {
SDL_Window *window = &display->windows[i];
if (FULLSCREEN_VISIBLE(window)) {
SDL_SetWindowPosition(window->id, window->x, window->y);
}
}
return 0;
}
int
SDL_SetFullscreenDisplayMode(const SDL_DisplayMode * mode)
SDL_SetDisplayMode(const SDL_DisplayMode * mode)
{
SDL_VideoDisplay *display;
SDL_DisplayMode fullscreen_mode;
int i;
if (!_this) {
SDL_UninitializedVideo();
return -1;
}
display = &SDL_CurrentDisplay;
if (!mode) {
mode = &display->desktop_mode;
}
if (!SDL_GetClosestDisplayMode(mode, &fullscreen_mode)) {
SDL_SetError("Couldn't find display mode match");
return -1;
}
return SDL_SetDisplayModeForDisplay(&SDL_CurrentDisplay, mode);
}
if (SDL_memcmp
(&fullscreen_mode, &display->fullscreen_mode,
sizeof(fullscreen_mode)) == 0) {
/* Nothing to do... */
return 0;
int
SDL_SetWindowDisplayMode(SDL_WindowID windowID, const SDL_DisplayMode * mode)
{
SDL_Window *window = SDL_GetWindowFromID(windowID);
if (!window) {
return -1;
}
display->fullscreen_mode = fullscreen_mode;
/* Actually set the mode if we have a fullscreen window visible */
for (i = 0; i < display->num_windows; ++i) {
SDL_Window *window = &display->windows[i];
if (FULLSCREEN_VISIBLE(window)) {
if (SDL_SetDisplayMode(&display->fullscreen_mode) < 0) {
return -1;
}
}
if (window->flags & SDL_WINDOW_FULLSCREEN) {
SDL_OnWindowResized(window);
}
if (mode) {
window->fullscreen_mode = *mode;
} else {
SDL_zero(window->fullscreen_mode);
}
return 0;
}
int
SDL_GetFullscreenDisplayMode(SDL_DisplayMode * mode)
SDL_GetWindowDisplayMode(SDL_WindowID windowID, SDL_DisplayMode * mode)
{
if (!_this) {
SDL_UninitializedVideo();
SDL_Window *window = SDL_GetWindowFromID(windowID);
SDL_DisplayMode fullscreen_mode;
if (!window) {
return -1;
}
fullscreen_mode = window->fullscreen_mode;
if (!fullscreen_mode.w) {
fullscreen_mode.w = window->w;
}
if (!fullscreen_mode.h) {
fullscreen_mode.h = window->h;
}
if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayFromWindow(window),
&fullscreen_mode,
&fullscreen_mode)) {
SDL_SetError("Couldn't find display mode match");
return -1;
}
if (mode) {
*mode = SDL_CurrentDisplay.fullscreen_mode;
*mode = fullscreen_mode;
}
return 0;
}
int
SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors)
SDL_SetDisplayPaletteForDisplay(SDL_VideoDisplay * display, const SDL_Color * colors, int firstcolor, int ncolors)
{
SDL_Palette *palette;
int status = 0;
if (!_this) {
SDL_UninitializedVideo();
return -1;
}
palette = SDL_CurrentDisplay.palette;
palette = display->palette;
if (!palette) {
SDL_SetError("Display mode does not have a palette");
return -1;
......@@ -709,7 +733,7 @@ SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors)
status = SDL_SetPaletteColors(palette, colors, firstcolor, ncolors);
if (_this->SetDisplayPalette) {
if (_this->SetDisplayPalette(_this, palette) < 0) {
if (_this->SetDisplayPalette(_this, display, palette) < 0) {
status = -1;
}
}
......@@ -717,16 +741,22 @@ SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors)
}
int
SDL_GetDisplayPalette(SDL_Color * colors, int firstcolor, int ncolors)
SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors)
{
SDL_Palette *palette;
if (!_this) {
SDL_UninitializedVideo();
return -1;
}
palette = SDL_CurrentDisplay.palette;
if (!palette->ncolors) {
return SDL_SetDisplayPaletteForDisplay(&SDL_CurrentDisplay, colors, firstcolor, ncolors);
}
int
SDL_GetDisplayPaletteForDisplay(SDL_VideoDisplay * display, SDL_Color * colors, int firstcolor, int ncolors)
{
SDL_Palette *palette;
palette = display->palette;
if (!palette || !palette->ncolors) {
SDL_SetError("Display mode does not have a palette");
return -1;
}
......@@ -739,6 +769,18 @@ SDL_GetDisplayPalette(SDL_Color * colors, int firstcolor, int ncolors)
return 0;
}
int
SDL_GetDisplayPalette(SDL_Color * colors, int firstcolor, int ncolors)
{
SDL_Palette *palette;
if (!_this) {
SDL_UninitializedVideo();
return -1;
}
return SDL_GetDisplayPaletteForDisplay(&SDL_CurrentDisplay, colors, firstcolor, ncolors);
}
SDL_WindowID
SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
{
......@@ -835,6 +877,7 @@ SDL_CreateWindowFrom(const void *data)
_this->CreateWindowFrom(_this, &window, data) < 0) {
return 0;
}
/* FIXME: Find out what display this window is actually on... */
display = &SDL_CurrentDisplay;
num_windows = display->num_windows;
windows =
......@@ -1248,6 +1291,7 @@ SDL_SetWindowFullscreen(SDL_WindowID windowID, int fullscreen)
if (FULLSCREEN_VISIBLE(window)) {
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
SDL_DisplayMode fullscreen_mode;
/* Hide any other fullscreen windows */
int i;
......@@ -1258,7 +1302,9 @@ SDL_SetWindowFullscreen(SDL_WindowID windowID, int fullscreen)
}
}
SDL_SetDisplayMode(&display->fullscreen_mode);
if (SDL_GetWindowDisplayMode(windowID, &fullscreen_mode) == 0) {
SDL_SetDisplayModeForDisplay(display, &fullscreen_mode);
}
}
} else {
window->flags &= ~SDL_WINDOW_FULLSCREEN;
......@@ -1336,11 +1382,11 @@ SDL_OnWindowFocusGained(SDL_Window * window)
{
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
if (window->flags & SDL_WINDOW_FULLSCREEN) {
SDL_SetDisplayMode(&display->fullscreen_mode);
if (FULLSCREEN_VISIBLE(window)) {
SDL_SetDisplayMode(&window->fullscreen_mode);
}
if (display->gamma && _this->SetDisplayGammaRamp) {
_this->SetDisplayGammaRamp(_this, display->gamma);
_this->SetDisplayGammaRamp(_this, display, display->gamma);
}
if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN))
&& _this->SetWindowGrab) {
......@@ -1353,12 +1399,12 @@ SDL_OnWindowFocusLost(SDL_Window * window)
{
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
if (window->flags & SDL_WINDOW_FULLSCREEN) {
if (FULLSCREEN_VISIBLE(window)) {
SDL_MinimizeWindow(window->id);
SDL_SetDisplayMode(NULL);
}
if (display->gamma && _this->SetDisplayGammaRamp) {
_this->SetDisplayGammaRamp(_this, display->saved_gamma);
_this->SetDisplayGammaRamp(_this, display, display->saved_gamma);
}
if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN))
&& _this->SetWindowGrab) {
......@@ -1430,16 +1476,10 @@ SDL_DestroyWindow(SDL_WindowID windowID)
}
void
SDL_AddRenderDriver(int displayIndex, const SDL_RenderDriver * driver)
SDL_AddRenderDriver(SDL_VideoDisplay * display, const SDL_RenderDriver * driver)
{
SDL_VideoDisplay *display;
SDL_RenderDriver *render_drivers;
if (displayIndex >= _this->num_displays) {
return;
}
display = &_this->displays[displayIndex];
render_drivers =
SDL_realloc(display->render_drivers,
(display->num_render_drivers +
......
......@@ -35,8 +35,8 @@ typedef struct
} SDL_DisplayModeData;
extern void Cocoa_InitModes(_THIS);
extern void Cocoa_GetDisplayModes(_THIS);
extern int Cocoa_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
extern void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
extern int Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern void Cocoa_QuitModes(_THIS);
#endif /* _SDL_cocoamodes_h */
......
......@@ -190,18 +190,18 @@ Cocoa_InitModes(_THIS)
static void
AddDisplayMode(const void *moderef, void *context)
{
SDL_VideoDevice *_this = (SDL_VideoDevice *) context;
SDL_VideoDisplay *display = (SDL_VideoDisplay *) context;
SDL_DisplayMode mode;
if (GetDisplayMode(moderef, &mode)) {
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(display, &mode);
}
}
void
Cocoa_GetDisplayModes(_THIS)
Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
{
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
CFArrayRef modes;
CFRange range;
......@@ -211,13 +211,13 @@ Cocoa_GetDisplayModes(_THIS)
}
range.location = 0;
range.length = CFArrayGetCount(modes);
CFArrayApplyFunction(modes, range, AddDisplayMode, _this);
CFArrayApplyFunction(modes, range, AddDisplayMode, display);
}
int
Cocoa_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken;
CGError result;
......@@ -279,21 +279,17 @@ ERR_NO_CAPTURE:
void
Cocoa_QuitModes(_THIS)
{
int i, saved_display;
int i;
saved_display = _this->current_display;
for (i = 0; i < _this->num_displays; ++i) {
SDL_VideoDisplay *display = &_this->displays[i];
if (display->current_mode.driverdata != display->desktop_mode.driverdata) {
_this->current_display = i;
Cocoa_SetDisplayMode(_this, &display->desktop_mode);
Cocoa_SetDisplayMode(_this, display, &display->desktop_mode);
}
}
CGReleaseAllDisplays();
ShowMenuBar();
_this->current_display = saved_display;
}
/* vi: set ts=4 sw=4 expandtab: */
......@@ -197,7 +197,7 @@ cbLayers(DFBDisplayLayerID layer_id, DFBDisplayLayerDescription desc,
}
static void
CheckSetDisplayMode(_THIS, DFB_DisplayData * data, SDL_DisplayMode * mode)
CheckSetDisplayMode(_THIS, SDL_VideoDisplay * display, DFB_DisplayData * data, SDL_DisplayMode * mode)
{
SDL_DFB_DEVICEDATA(_this);
DFBDisplayLayerConfig config;
......@@ -219,7 +219,7 @@ CheckSetDisplayMode(_THIS, DFB_DisplayData * data, SDL_DisplayMode * mode)
SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer,
DLSCL_SHARED));
if (failed == 0)
SDL_AddDisplayMode(_this->current_display, mode);
SDL_AddDisplayMode(display, mode);
else
SDL_DFB_DEBUG("Mode %d x %d not available: %x\n", mode->w,
mode->h, failed);
......@@ -356,11 +356,10 @@ DirectFB_InitModes(_THIS)
}
void
DirectFB_GetDisplayModes(_THIS)
DirectFB_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
{
SDL_DFB_DEVICEDATA(_this);
DFB_DisplayData *dispdata =
(DFB_DisplayData *) SDL_CurrentDisplay.driverdata;
DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
SDL_DisplayMode mode;
struct modes_callback_t data;
int i;
......@@ -376,25 +375,23 @@ DirectFB_GetDisplayModes(_THIS)
mode = data.modelist[i];
mode.format = SDL_PIXELFORMAT_ARGB8888;
CheckSetDisplayMode(_this, dispdata, &mode);
CheckSetDisplayMode(_this, display, dispdata, &mode);
mode.format = SDL_PIXELFORMAT_RGB888;
CheckSetDisplayMode(_this, dispdata, &mode);
CheckSetDisplayMode(_this, display, dispdata, &mode);
mode.format = SDL_PIXELFORMAT_RGB24;
CheckSetDisplayMode(_this, dispdata, &mode);
CheckSetDisplayMode(_this, display, dispdata, &mode);
mode.format = SDL_PIXELFORMAT_RGB565;
CheckSetDisplayMode(_this, dispdata, &mode);
CheckSetDisplayMode(_this, display, dispdata, &mode);
mode.format = SDL_PIXELFORMAT_INDEX8;
CheckSetDisplayMode(_this, dispdata, &mode);
CheckSetDisplayMode(_this, display, dispdata, &mode);
}
SDL_DFB_FREE(data.modelist);
return;
error:
SDL_DFB_FREE(data.modelist);
return;
}
int
DirectFB_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
DirectFB_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
/*
* FIXME: video mode switch is currently broken for 1.2.0
......@@ -402,7 +399,7 @@ DirectFB_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
*/
SDL_DFB_DEVICEDATA(_this);
DFB_DisplayData *data = (DFB_DisplayData *) SDL_CurrentDisplay.driverdata;
DFB_DisplayData *data = (DFB_DisplayData *) display->driverdata;
DFBDisplayLayerConfig config, rconfig;
DFBDisplayLayerConfigFlags fail = 0;
DFBResult ret;
......@@ -459,7 +456,7 @@ DirectFB_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
data->pixelformat = rconfig.pixelformat;
data->cw = config.width;
data->ch = config.height;
SDL_CurrentDisplay.current_mode = *mode;
display->current_mode = *mode;
return 0;
error:
......@@ -474,18 +471,16 @@ DirectFB_QuitModes(_THIS)
DFBResult ret;
int i;
SDL_SelectVideoDisplay(0);
SDL_GetDesktopDisplayMode(&tmode);
tmode.format = SDL_PIXELFORMAT_UNKNOWN;
DirectFB_SetDisplayMode(_this, &tmode);
for (i = 0; i < _this->num_displays; ++i) {
SDL_VideoDisplay *display = &_this->displays[i];
DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
SDL_GetDesktopDisplayMode(&tmode);
DirectFB_SetDisplayMode(_this, &tmode);
SDL_GetDesktopDisplayModeForDisplay(display, &tmode);
tmode.format = SDL_PIXELFORMAT_UNKNOWN;
DirectFB_SetDisplayMode(_this, display, &tmode);
for (i = 0; i < SDL_GetNumVideoDisplays(); i++) {
DFB_DisplayData *dispdata =
(DFB_DisplayData *) _this->displays[i].driverdata;
SDL_GetDesktopDisplayModeForDisplay(display, &tmode);
DirectFB_SetDisplayMode(_this, display, &tmode);
if (dispdata->layer) {
SDL_DFB_CHECK(dispdata->
......
......@@ -48,8 +48,8 @@ struct _DFB_DisplayData
extern void DirectFB_InitModes(_THIS);
extern void DirectFB_GetDisplayModes(_THIS);
extern int DirectFB_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
extern void DirectFB_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
extern int DirectFB_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern void DirectFB_QuitModes(_THIS);
#endif /* _SDL_directfb_modes_h */
......
......@@ -234,7 +234,7 @@ DirectFB_AddRenderDriver(_THIS)
{
int i;
for (i = 0; i < _this->num_displays; i++)
SDL_AddRenderDriver(i, &DirectFB_RenderDriver);
SDL_AddRenderDriver(&_this->displays[i], &DirectFB_RenderDriver);
}
static int
......@@ -264,6 +264,8 @@ DisplayPaletteChanged(void *userdata, SDL_Palette * palette)
SDL_DFB_CHECKERR(surfpal->SetEntries(surfpal, entries, ncolors, 0));
return 0;
error:
#else
SDL_Unsupported();
#endif
return -1;
}
......
......@@ -56,11 +56,6 @@ static void DirectFB_VideoQuit(_THIS);
static int DirectFB_Available(void);
static SDL_VideoDevice *DirectFB_CreateDevice(int devindex);
#if 0
static int DirectFB_SetDisplayGammaRamp(_THIS, Uint16 * ramp);
static int DirectFB_GetDisplayGammaRamp(_THIS, Uint16 * ramp);
#endif
VideoBootStrap DirectFB_bootstrap = {
"directfb", "DirectFB",
DirectFB_Available, DirectFB_CreateDevice
......@@ -103,13 +98,6 @@ DirectFB_CreateDevice(int devindex)
device->VideoQuit = DirectFB_VideoQuit;
device->GetDisplayModes = DirectFB_GetDisplayModes;
device->SetDisplayMode = DirectFB_SetDisplayMode;
#if 0
device->SetDisplayGammaRamp = DirectFB_SetDisplayGammaRamp;
device->GetDisplayGammaRamp = DirectFB_GetDisplayGammaRamp;
#else
device->SetDisplayGammaRamp = NULL;
device->GetDisplayGammaRamp = NULL;
#endif
device->PumpEvents = DirectFB_PumpEventsWindow;
device->CreateWindow = DirectFB_CreateWindow;
device->CreateWindowFrom = DirectFB_CreateWindowFrom;
......@@ -300,17 +288,3 @@ DirectFB_VideoQuit(_THIS)
devdata->initialized = 0;
}
#if 0
static int
DirectFB_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
{
return -1;
}
static int
DirectFB_GetDisplayGammaRamp(_THIS, Uint16 * ramp)
{
return -1;
}
#endif
......@@ -108,10 +108,6 @@ PND_create()
device->VideoQuit = PND_videoquit;
device->GetDisplayModes = PND_getdisplaymodes;
device->SetDisplayMode = PND_setdisplaymode;
device->SetDisplayPalette = PND_setdisplaypalette;
device->GetDisplayPalette = PND_getdisplaypalette;
device->SetDisplayGammaRamp = PND_setdisplaygammaramp;
device->GetDisplayGammaRamp = PND_getdisplaygammaramp;
device->CreateWindow = PND_createwindow;
device->CreateWindowFrom = PND_createwindowfrom;
device->SetWindowTitle = PND_setwindowtitle;
......@@ -191,54 +187,17 @@ PND_videoquit(_THIS)
}
void
PND_getdisplaymodes(_THIS)
PND_getdisplaymodes(_THIS, SDL_VideoDisplay * display)
{
}
int
PND_setdisplaymode(_THIS, SDL_DisplayMode * mode)
PND_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
return 0;
}
int
PND_setdisplaypalette(_THIS, SDL_Palette * palette)
{
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
/* Setting display palette operation has been failed */
return -1;
}
int
PND_getdisplaypalette(_THIS, SDL_Palette * palette)
{
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
/* Getting display palette operation has been failed */
return -1;
}
int
PND_setdisplaygammaramp(_THIS, Uint16 * ramp)
{
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
/* Setting display gamma ramp operation has been failed */
return -1;
}
int
PND_getdisplaygammaramp(_THIS, Uint16 * ramp)
{
/* Getting display gamma ramp operation has been failed */
return -1;
}
int
PND_createwindow(_THIS, SDL_Window * window)
{
......@@ -458,7 +417,7 @@ PND_gl_createcontext(_THIS, SDL_Window * window)
SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
EGLBoolean status;
int32_t gfstatus;
EGLint configs;
......@@ -857,7 +816,7 @@ PND_gl_swapwindow(_THIS, SDL_Window * window)
SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
if (phdata->egl_initialized != SDL_TRUE) {
......
......@@ -269,10 +269,6 @@ photon_create(int devindex)
device->VideoQuit = photon_videoquit;
device->GetDisplayModes = photon_getdisplaymodes;
device->SetDisplayMode = photon_setdisplaymode;
device->SetDisplayPalette = photon_setdisplaypalette;
device->GetDisplayPalette = photon_getdisplaypalette;
device->SetDisplayGammaRamp = photon_setdisplaygammaramp;
device->GetDisplayGammaRamp = photon_getdisplaygammaramp;
device->CreateWindow = photon_createwindow;
device->CreateWindowFrom = photon_createwindowfrom;
device->SetWindowTitle = photon_setwindowtitle;
......@@ -524,11 +520,10 @@ photon_videoquit(_THIS)
}
void
photon_getdisplaymodes(_THIS)
photon_getdisplaymodes(_THIS, SDL_VideoDisplay * display)
{
SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
SDL_DisplayMode mode;
PgVideoModes_t modes;
PgVideoModeInfo_t modeinfo;
......@@ -569,7 +564,7 @@ photon_getdisplaymodes(_THIS)
mode.refresh_rate = modeinfo.refresh_rates[jt];
mode.format = photon_image_to_sdl_pixelformat(modeinfo.type);
mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(display, &mode);
/* If mode is RGBA8888, add the same mode as RGBx888 */
if (modeinfo.type == Pg_IMAGE_DIRECT_8888) {
......@@ -578,7 +573,7 @@ photon_getdisplaymodes(_THIS)
mode.refresh_rate = modeinfo.refresh_rates[jt];
mode.format = SDL_PIXELFORMAT_RGB888;
mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(display, &mode);
}
/* If mode is RGBA1555, add the same mode as RGBx555 */
......@@ -588,7 +583,7 @@ photon_getdisplaymodes(_THIS)
mode.refresh_rate = modeinfo.refresh_rates[jt];
mode.format = SDL_PIXELFORMAT_RGB555;
mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(display, &mode);
}
jt++;
......@@ -600,11 +595,10 @@ photon_getdisplaymodes(_THIS)
}
int
photon_setdisplaymode(_THIS, SDL_DisplayMode * mode)
photon_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
PgVideoModes_t modes;
PgVideoModeInfo_t modeinfo;
PgDisplaySettings_t modesettings;
......@@ -651,15 +645,15 @@ photon_setdisplaymode(_THIS, SDL_DisplayMode * mode)
tempmode.refresh_rate = 0x0000FFFF;
/* Check if window width and height matches one of our modes */
for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) {
if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) &&
(SDL_CurrentDisplay.display_modes[it].h == mode->h) &&
(SDL_CurrentDisplay.display_modes[it].format == mode->format))
for (it = 0; it < display->num_display_modes; it++) {
if ((display->display_modes[it].w == mode->w) &&
(display->display_modes[it].h == mode->h) &&
(display->display_modes[it].format == mode->format))
{
/* Find the lowest refresh rate available */
if (tempmode.refresh_rate >
SDL_CurrentDisplay.display_modes[it].refresh_rate) {
tempmode = SDL_CurrentDisplay.display_modes[it];
display->display_modes[it].refresh_rate) {
tempmode = display->display_modes[it];
}
}
}
......@@ -680,21 +674,21 @@ photon_setdisplaymode(_THIS, SDL_DisplayMode * mode)
tempmode.refresh_rate = 0x0000FFFF;
/* Check if window width and height matches one of our modes */
for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) {
if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) &&
(SDL_CurrentDisplay.display_modes[it].h == mode->h) &&
(SDL_CurrentDisplay.display_modes[it].format == mode->format))
for (it = 0; it < display->num_display_modes; it++) {
if ((display->display_modes[it].w == mode->w) &&
(display->display_modes[it].h == mode->h) &&
(display->display_modes[it].format == mode->format))
{
/* Find the lowest refresh rate available */
if (tempmode.refresh_rate >
SDL_CurrentDisplay.display_modes[it].refresh_rate) {
tempmode = SDL_CurrentDisplay.display_modes[it];
display->display_modes[it].refresh_rate) {
tempmode = display->display_modes[it];
}
/* Check if requested refresh rate found */
if (refresh_rate ==
SDL_CurrentDisplay.display_modes[it].refresh_rate) {
tempmode = SDL_CurrentDisplay.display_modes[it];
display->display_modes[it].refresh_rate) {
tempmode = display->display_modes[it];
break;
}
}
......@@ -778,49 +772,12 @@ photon_setdisplaymode(_THIS, SDL_DisplayMode * mode)
return 0;
}
int
photon_setdisplaypalette(_THIS, SDL_Palette * palette)
{
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
/* Setting display palette operation has been failed */
return -1;
}
int
photon_getdisplaypalette(_THIS, SDL_Palette * palette)
{
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
/* Getting display palette operation has been failed */
return -1;
}
int
photon_setdisplaygammaramp(_THIS, Uint16 * ramp)
{
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
/* Setting display gamma ramp operation has been failed */
return -1;
}
int
photon_getdisplaygammaramp(_THIS, Uint16 * ramp)
{
/* Getting display gamma ramp operation has been failed */
return -1;
}
int
photon_createwindow(_THIS, SDL_Window * window)
{
SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
SDL_WindowData *wdata;
PhDim_t winsize;
PhPoint_t winpos;
......@@ -1098,7 +1055,7 @@ photon_setwindowposition(_THIS, SDL_Window * window)
{
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
PhPoint_t winpos;
int32_t status;
......@@ -1266,7 +1223,7 @@ photon_destroywindow(_THIS, SDL_Window * window)
{
SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
int32_t status;
......@@ -1457,7 +1414,7 @@ photon_gl_createcontext(_THIS, SDL_Window * window)
SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
EGLBoolean status;
int32_t gfstatus;
EGLint configs;
......@@ -1984,7 +1941,7 @@ photon_gl_swapwindow(_THIS, SDL_Window * window)
SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
PhRect_t dst_rect;
PhRect_t src_rect;
int32_t status;
......@@ -2093,7 +2050,7 @@ int photon_gl_recreatesurface(_THIS, SDL_Window * window, uint32_t width, uint32
SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
SDL_bool makecurrent=SDL_FALSE;
int32_t gfstatus;
......@@ -2194,7 +2151,6 @@ photon_pumpevents(_THIS)
PhEvent_t *event = (PhEvent_t *) eventbuffer;
int32_t status;
uint32_t finish = 0;
uint32_t it;
SDL_Window *window;
SDL_WindowData *wdata;
......@@ -2211,23 +2167,22 @@ photon_pumpevents(_THIS)
{
/* Find a window, to which this handle destinated */
status = 0;
for (it = 0; it < SDL_CurrentDisplay.num_windows; it++) {
wdata =
(SDL_WindowData *) SDL_CurrentDisplay.windows[it].
driverdata;
/* Find the proper window */
if (wdata->window != NULL) {
if (PtWidgetRid(wdata->window) ==
event->collector.rid) {
window =
(SDL_Window *) & SDL_CurrentDisplay.
windows[it];
status = 1;
break;
for (i = 0; i < SDL_GetNumVideoDisplays(); ++i) {
SDL_VideoDisplay *display = SDL_GetVideoDisplay(i);
for (j = 0; j < display->num_windows; ++j) {
wdata = (SDL_WindowData *) display->windows[j].driverdata;
/* Find the proper window */
if (wdata->window != NULL) {
if (PtWidgetRid(wdata->window) ==
event->collector.rid) {
window = (SDL_Window *) &display->windows[it];
status = 1;
break;
}
} else {
continue;
}
} else {
continue;
}
}
if (status == 0) {
......
......@@ -53,6 +53,8 @@ photon_addinputdevices(_THIS)
uint32_t it;
for (it = 0; it < _this->num_displays; it++) {
SDL_VideoDisplay *display = &_this->displays[it];
/* Clear SDL mouse structure */
SDL_memset(&photon_mouse, 0x00, sizeof(struct SDL_Mouse));
......@@ -74,7 +76,7 @@ photon_addinputdevices(_THIS)
photon_mouse.FreeMouse = photon_freemouse;
/* Get display data */
didata = (SDL_DisplayData *) _this->displays[it].driverdata;
didata = (SDL_DisplayData *) display->driverdata;
/* Store SDL_DisplayData pointer in the mouse driver internals */
mdata->didata = didata;
......
......@@ -276,7 +276,7 @@ photon_addrenderdriver(_THIS)
uint32_t it;
for (it = 0; it < _this->num_displays; it++) {
SDL_AddRenderDriver(it, &photon_renderdriver);
SDL_AddRenderDriver(&_this->displays[it], &photon_renderdriver);
}
}
......
......@@ -84,7 +84,8 @@ static PS3_DisplayModeData ps3fb_data[] = {
};
void
PS3_GetDisplayModes(_THIS) {
PS3_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
{
deprintf(1, "+PS3_GetDisplayModes()\n");
SDL_DisplayMode mode;
unsigned int nummodes;
......@@ -98,13 +99,13 @@ PS3_GetDisplayModes(_THIS) {
/* Add DisplayMode to list */
deprintf(2, "Adding resolution %u x %u\n", ps3fb_modedb[n].w, ps3fb_modedb[n].h);
SDL_AddDisplayMode(_this->current_display, &ps3fb_modedb[n]);
SDL_AddDisplayMode(display, &ps3fb_modedb[n]);
}
deprintf(1, "-PS3_GetDisplayModes()\n");
}
int
PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
PS3_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
deprintf(1, "+PS3_SetDisplayMode()\n");
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
......@@ -123,13 +124,14 @@ PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
}
void
PS3_QuitModes(_THIS) {
PS3_QuitModes(_THIS)
{
deprintf(1, "+PS3_QuitModes()\n");
/* There was no mem allocated for driverdata */
int i, j;
for (i = _this->num_displays; i--;) {
SDL_VideoDisplay *display = &_this->displays[i];
for (i = 0; i < SDL_GetNumVideoDisplays(); ++i) {
SDL_VideoDisplay *display = SDL_GetVideoDisplay(i);
for (j = display->num_display_modes; j--;) {
display->display_modes[j].driverdata = NULL;
}
......
......@@ -25,8 +25,8 @@
#define _SDL_ps3modes_h
extern void PS3_InitModes(_THIS);
extern void PS3_GetDisplayModes(_THIS);
extern int PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
extern void PS3_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
extern int PS3_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern void PS3_QuitModes(_THIS);
#endif /* SDL_ps3modes_h */
......
......@@ -60,6 +60,8 @@ gf_addinputdevices(_THIS)
uint32_t it;
for (it = 0; it < _this->num_displays; it++) {
SDL_VideoDisplay *display = &_this->displays[it];
/* Clear SDL mouse structure */
SDL_memset(&gf_mouse, 0x00, sizeof(struct SDL_Mouse));
......@@ -81,7 +83,7 @@ gf_addinputdevices(_THIS)
gf_mouse.FreeMouse = gf_freemouse;
/* Get display data */
didata = (SDL_DisplayData *) _this->displays[it].driverdata;
didata = (SDL_DisplayData *) display->driverdata;
/* Store SDL_DisplayData pointer in the mouse driver internals */
mdata->didata = didata;
......
......@@ -261,7 +261,7 @@ gf_addrenderdriver(_THIS)
uint32_t it;
for (it = 0; it < _this->num_displays; it++) {
SDL_AddRenderDriver(it, &gf_renderdriver);
SDL_AddRenderDriver(&_this->displays[it], &gf_renderdriver);
}
}
......
......@@ -522,13 +522,9 @@ qnxgf_videoinit(_THIS)
}
/* Get all display modes for this display */
_this->current_display = it;
qnxgf_getdisplaymodes(_this);
qnxgf_getdisplaymodes(_this, display);
}
/* Restore default display */
_this->current_display = 0;
/* Add GF renderer to SDL */
gf_addrenderdriver(_this);
......@@ -614,10 +610,9 @@ qnxgf_videoquit(_THIS)
}
void
qnxgf_getdisplaymodes(_THIS)
qnxgf_getdisplaymodes(_THIS, SDL_VideoDisplay * display)
{
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
SDL_DisplayMode mode;
gf_modeinfo_t modeinfo;
uint32_t it = 0;
......@@ -653,7 +648,7 @@ qnxgf_getdisplaymodes(_THIS)
mode.format =
qnxgf_gf_to_sdl_pixelformat(modeinfo.primary_format);
mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(display, &mode);
/* If mode is RGBA8888, add the same mode as RGBx888 */
if (modeinfo.primary_format == GF_FORMAT_BGRA8888) {
......@@ -662,7 +657,7 @@ qnxgf_getdisplaymodes(_THIS)
mode.refresh_rate = generic_mode[jt].refresh_rate;
mode.format = SDL_PIXELFORMAT_RGB888;
mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(display, &mode);
}
/* If mode is RGBA1555, add the same mode as RGBx555 */
if (modeinfo.primary_format == GF_FORMAT_PACK_ARGB1555) {
......@@ -671,7 +666,7 @@ qnxgf_getdisplaymodes(_THIS)
mode.refresh_rate = generic_mode[jt].refresh_rate;
mode.format = SDL_PIXELFORMAT_RGB555;
mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(display, &mode);
}
jt++;
......@@ -689,7 +684,7 @@ qnxgf_getdisplaymodes(_THIS)
qnxgf_gf_to_sdl_pixelformat(modeinfo.
primary_format);
mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(display, &mode);
/* If mode is RGBA8888, add the same mode as RGBx888 */
if (modeinfo.primary_format == GF_FORMAT_BGRA8888) {
......@@ -698,7 +693,7 @@ qnxgf_getdisplaymodes(_THIS)
mode.refresh_rate = modeinfo.refresh[jt];
mode.format = SDL_PIXELFORMAT_RGB888;
mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(display, &mode);
}
/* If mode is RGBA1555, add the same mode as RGBx555 */
if (modeinfo.primary_format ==
......@@ -708,7 +703,7 @@ qnxgf_getdisplaymodes(_THIS)
mode.refresh_rate = modeinfo.refresh[jt];
mode.format = SDL_PIXELFORMAT_RGB555;
mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(display, &mode);
}
jt++;
......@@ -731,10 +726,9 @@ qnxgf_getdisplaymodes(_THIS)
}
int
qnxgf_setdisplaymode(_THIS, SDL_DisplayMode * mode)
qnxgf_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
uint32_t refresh_rate = 0;
int status;
......@@ -760,15 +754,15 @@ qnxgf_setdisplaymode(_THIS, SDL_DisplayMode * mode)
tempmode.refresh_rate = 0x0000FFFF;
/* Check if window width and height matches one of our modes */
for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) {
if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) &&
(SDL_CurrentDisplay.display_modes[it].h == mode->h) &&
(SDL_CurrentDisplay.display_modes[it].format == mode->format))
for (it = 0; it < display->num_display_modes; it++) {
if ((display->display_modes[it].w == mode->w) &&
(display->display_modes[it].h == mode->h) &&
(display->display_modes[it].format == mode->format))
{
/* Find the lowest refresh rate available */
if (tempmode.refresh_rate >
SDL_CurrentDisplay.display_modes[it].refresh_rate) {
tempmode = SDL_CurrentDisplay.display_modes[it];
display->display_modes[it].refresh_rate) {
tempmode = display->display_modes[it];
}
}
}
......@@ -790,21 +784,21 @@ qnxgf_setdisplaymode(_THIS, SDL_DisplayMode * mode)
tempmode.refresh_rate = 0x0000FFFF;
/* Check if window width and height matches one of our modes */
for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) {
if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) &&
(SDL_CurrentDisplay.display_modes[it].h == mode->h) &&
(SDL_CurrentDisplay.display_modes[it].format == mode->format))
for (it = 0; it < display->num_display_modes; it++) {
if ((display->display_modes[it].w == mode->w) &&
(display->display_modes[it].h == mode->h) &&
(display->display_modes[it].format == mode->format))
{
/* Find the lowest refresh rate available */
if (tempmode.refresh_rate >
SDL_CurrentDisplay.display_modes[it].refresh_rate) {
tempmode = SDL_CurrentDisplay.display_modes[it];
display->display_modes[it].refresh_rate) {
tempmode = display->display_modes[it];
}
/* Check if requested refresh rate found */
if (refresh_rate ==
SDL_CurrentDisplay.display_modes[it].refresh_rate) {
tempmode = SDL_CurrentDisplay.display_modes[it];
display->display_modes[it].refresh_rate) {
tempmode = display->display_modes[it];
break;
}
}
......@@ -928,36 +922,33 @@ qnxgf_setdisplaymode(_THIS, SDL_DisplayMode * mode)
}
int
qnxgf_setdisplaypalette(_THIS, SDL_Palette * palette)
qnxgf_setdisplaypalette(_THIS, SDL_VideoDisplay * display, SDL_Palette * palette)
{
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
/* QNX GF doesn't have support for global palette changing, but we */
/* could store it for usage in future */
/* Setting display palette operation has been failed */
SDL_Unsupported();
return -1;
}
int
qnxgf_getdisplaypalette(_THIS, SDL_Palette * palette)
qnxgf_getdisplaypalette(_THIS, SDL_VideoDisplay * display, SDL_Palette * palette)
{
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
/* We can't provide current palette settings and looks like SDL */
/* do not call this function also, in such case this function returns -1 */
/* Getting display palette operation has been failed */
SDL_Unsupported();
return -1;
}
int
qnxgf_setdisplaygammaramp(_THIS, Uint16 * ramp)
qnxgf_setdisplaygammaramp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
{
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
int status;
/* Setup gamma ramp, for each color channel */
......@@ -974,12 +965,12 @@ qnxgf_setdisplaygammaramp(_THIS, Uint16 * ramp)
}
int
qnxgf_getdisplaygammaramp(_THIS, Uint16 * ramp)
qnxgf_getdisplaygammaramp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
{
/* TODO: We need to return previous gamma set */
/* Also we need some initial fake gamma to return */
/* Getting display gamma ramp operation has been failed */
SDL_Unsupported();
return -1;
}
......@@ -987,8 +978,8 @@ int
qnxgf_createwindow(_THIS, SDL_Window * window)
{
SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
SDL_WindowData *wdata;
int32_t status;
......@@ -1002,15 +993,15 @@ qnxgf_createwindow(_THIS, SDL_Window * window)
mode.refresh_rate = 0x0000FFFF;
/* Check if window width and height matches one of our modes */
for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) {
if ((SDL_CurrentDisplay.display_modes[it].w == window->w) &&
(SDL_CurrentDisplay.display_modes[it].h == window->h) &&
(SDL_CurrentDisplay.display_modes[it].format ==
SDL_CurrentDisplay.desktop_mode.format)) {
for (it = 0; it < display->num_display_modes; it++) {
if ((display->display_modes[it].w == window->w) &&
(display->display_modes[it].h == window->h) &&
(display->display_modes[it].format ==
display->desktop_mode.format)) {
/* Find the lowest refresh rate available */
if (mode.refresh_rate >
SDL_CurrentDisplay.display_modes[it].refresh_rate) {
mode = SDL_CurrentDisplay.display_modes[it];
display->display_modes[it].refresh_rate) {
mode = display->display_modes[it];
}
}
}
......@@ -1164,7 +1155,7 @@ qnxgf_destroywindow(_THIS, SDL_Window * window)
{
SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
if (wdata != NULL) {
......@@ -1318,7 +1309,7 @@ qnxgf_gl_createcontext(_THIS, SDL_Window * window)
SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata;
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
EGLBoolean status;
int32_t gfstatus;
EGLint configs;
......
......@@ -25,12 +25,12 @@
int
WIN_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
WIN_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
{
#ifdef _WIN32_WCE
return -1;
#else
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
HDC hdc;
BOOL succeeded = FALSE;
......@@ -47,12 +47,12 @@ WIN_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
}
int
WIN_GetDisplayGammaRamp(_THIS, Uint16 * ramp)
WIN_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
{
#ifdef _WIN32_WCE
return -1;
#else
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
HDC hdc;
BOOL succeeded = FALSE;
......
......@@ -24,8 +24,8 @@
#ifndef _SDL_win32gamma_h
#define _SDL_win32gamma_h
extern int WIN_SetDisplayGammaRamp(_THIS, Uint16 * ramp);
extern int WIN_GetDisplayGammaRamp(_THIS, Uint16 * ramp);
extern int WIN_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
extern int WIN_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
#endif /* _SDL_win32gamma_h */
......
......@@ -41,7 +41,6 @@ WIN_GetDisplayMode(LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode)
if (!data) {
return SDL_FALSE;
}
SDL_memcpy(data->DeviceName, deviceName, sizeof(data->DeviceName));
data->DeviceMode = devmode;
data->DeviceMode.dmFields =
(DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY |
......@@ -196,9 +195,9 @@ WIN_InitModes(_THIS)
}
void
WIN_GetDisplayModes(_THIS)
WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
{
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
DWORD i;
SDL_DisplayMode mode;
......@@ -207,15 +206,16 @@ WIN_GetDisplayModes(_THIS)
break;
}
if (mode.format != SDL_PIXELFORMAT_UNKNOWN)
if (!SDL_AddDisplayMode(_this->current_display, &mode)) {
if (!SDL_AddDisplayMode(display, &mode)) {
SDL_free(mode.driverdata);
}
}
}
int
WIN_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
LONG status;
......@@ -228,8 +228,8 @@ WIN_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
#endif
status =
ChangeDisplaySettingsEx(data->DeviceName, &data->DeviceMode, NULL,
CDS_FULLSCREEN, NULL);
ChangeDisplaySettingsEx(displaydata->DeviceName, &data->DeviceMode,
NULL, CDS_FULLSCREEN, NULL);
if (status == DISP_CHANGE_SUCCESSFUL) {
return 0;
} else {
......
......@@ -31,13 +31,12 @@ typedef struct
typedef struct
{
TCHAR DeviceName[32];
DEVMODE DeviceMode;
} SDL_DisplayModeData;
extern void WIN_InitModes(_THIS);
extern void WIN_GetDisplayModes(_THIS);
extern int WIN_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
extern void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
extern int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern void WIN_QuitModes(_THIS);
#endif /* _SDL_win32modes_h */
......
......@@ -124,7 +124,7 @@ X11_TrackColormap(Display * display, int scrNum, Colormap colormap,
cool. If not, then we just fail */
int
X11_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
X11_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * sdl_display, Uint16 * ramp)
{
Visual *visual;
Display *display;
......@@ -214,7 +214,7 @@ X11_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
}
int
X11_GetDisplayGammaRamp(_THIS, Uint16 * ramp)
X11_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
{
int i;
......
......@@ -30,7 +30,7 @@ extern void X11_TrackColormap(Display * display, int scrNum,
Colormap colormap,
Visual * visual, XColor * ramp);
extern int X11_SetDisplayGammaRamp(_THIS, Uint16 * ramp);
extern int X11_GetDisplayGammaRamp(_THIS, Uint16 * ramp);
extern int X11_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
extern int X11_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
#endif
......@@ -311,10 +311,10 @@ restore_mode(Display * display, SDL_DisplayData * data)
#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
void
X11_GetDisplayModes(_THIS)
X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
{
Display *display = ((SDL_VideoData *) _this->driverdata)->display;
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *data = (SDL_DisplayData *) sdl_display->driverdata;
#if SDL_VIDEO_DRIVER_X11_XINERAMA
int xinerama_major, xinerama_minor;
int screens;
......@@ -341,7 +341,7 @@ X11_GetDisplayModes(_THIS)
* we have to use the same format for all windows and all display modes.
* (or support recreating the window with a new visual behind the scenes)
*/
mode.format = SDL_CurrentDisplay.current_mode.format;
mode.format = sdl_display->current_mode.format;
mode.driverdata = NULL;
data->use_xinerama = 0;
......@@ -382,14 +382,14 @@ X11_GetDisplayModes(_THIS)
mode.w = screen_w;
mode.h = screen_h;
mode.refresh_rate = 0;
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(sdl_display, &mode);
}
/* Add the head xinerama mode */
mode.w = data->xinerama_info.width;
mode.h = data->xinerama_info.height;
mode.refresh_rate = 0;
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(sdl_display, &mode);
}
}
#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
......@@ -426,7 +426,7 @@ X11_GetDisplayModes(_THIS)
"XRANDR: mode = %4d[%d], w = %4d, h = %4d, rate = %4d\n",
i, j, mode.w, mode.h, mode.refresh_rate);
#endif
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(sdl_display, &mode);
}
}
......@@ -462,7 +462,7 @@ X11_GetDisplayModes(_THIS)
mode.w = modes[i]->hdisplay;
mode.h = modes[i]->vdisplay;
mode.refresh_rate = calculate_rate(modes[i]);
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(sdl_display, &mode);
}
XFree(modes);
......@@ -475,7 +475,7 @@ X11_GetDisplayModes(_THIS)
mode.w = screen_w;
mode.h = screen_h;
mode.refresh_rate = 0;
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(sdl_display, &mode);
}
#ifdef X11MODES_DEBUG
if (data->use_xinerama) {
......@@ -672,10 +672,10 @@ set_best_resolution(Display * display, SDL_DisplayData * data, int w, int h,
}
int
X11_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode)
{
Display *display = ((SDL_VideoData *) _this->driverdata)->display;
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *data = (SDL_DisplayData *) sdl_display->driverdata;
set_best_resolution(display, data, mode->w, mode->h, mode->refresh_rate);
return 0;
......
......@@ -55,8 +55,8 @@ typedef struct
} SDL_DisplayData;
extern void X11_InitModes(_THIS);
extern void X11_GetDisplayModes(_THIS);
extern int X11_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
extern void X11_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
extern int X11_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern void X11_QuitModes(_THIS);
#endif /* _SDL_x11modes_h */
......
......@@ -76,7 +76,7 @@ CommonCreateState(char **argv, Uint32 flags)
state->argv = argv;
state->flags = flags;
state->window_title = argv[0];
state->window_flags = SDL_WINDOW_SHOWN;
state->window_flags = 0;
state->window_x = SDL_WINDOWPOS_UNDEFINED;
state->window_y = SDL_WINDOWPOS_UNDEFINED;
state->window_w = DEFAULT_WINDOW_WIDTH;
......@@ -737,6 +737,7 @@ CommonInit(CommonState * state)
}
}
SDL_zero(fullscreen_mode);
switch (state->depth) {
case 8:
fullscreen_mode.format = SDL_PIXELFORMAT_INDEX8;
......@@ -754,14 +755,7 @@ CommonInit(CommonState * state)
fullscreen_mode.format = SDL_PIXELFORMAT_RGB888;
break;
}
fullscreen_mode.w = state->window_w;
fullscreen_mode.h = state->window_h;
fullscreen_mode.refresh_rate = state->refresh_rate;
if (SDL_SetFullscreenDisplayMode(&fullscreen_mode)<0) {
fprintf(stderr, "Can't switch to fullscreen display mode: %s\n",
SDL_GetError());
return SDL_FALSE;
}
state->windows =
(SDL_WindowID *) SDL_malloc(state->num_windows *
......@@ -789,6 +783,13 @@ CommonInit(CommonState * state)
return SDL_FALSE;
}
if (SDL_SetWindowDisplayMode(state->windows[i], &fullscreen_mode) < 0) {
fprintf(stderr, "Can't set up fullscreen display mode: %s\n",
SDL_GetError());
return SDL_FALSE;
}
SDL_ShowWindow(state->windows[i]);
if (!state->skip_renderer
&& (state->renderdriver
|| !(state->window_flags & SDL_WINDOW_OPENGL))) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment