mirror of https://github.com/libsdl-org/SDL
Removed display mode flags
They weren't really adding any value and added complexity to the API
This commit is contained in:
parent
9ff1055489
commit
14338ab459
|
@ -43,16 +43,6 @@ extern "C" {
|
|||
typedef Uint32 SDL_DisplayID;
|
||||
typedef Uint32 SDL_WindowID;
|
||||
|
||||
/**
|
||||
* \brief The flags on a display mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_DISPLAYMODE_DESKTOP = 0x00000001, /**< The display uses this as the desktop mode */
|
||||
SDL_DISPLAYMODE_CURRENT = 0x00000002, /**< The display is currently using this mode */
|
||||
|
||||
} SDL_DisplayModeFlags;
|
||||
|
||||
/**
|
||||
* \brief The structure that defines a display mode
|
||||
*
|
||||
|
@ -65,7 +55,6 @@ typedef enum
|
|||
typedef struct
|
||||
{
|
||||
SDL_DisplayID displayID; /**< the display this mode is associated with */
|
||||
Uint32 flags; /**< whether this mode is the current mode or a desktop mode */
|
||||
Uint32 format; /**< pixel format */
|
||||
int pixel_w; /**< width in pixels (used for creating back buffers) */
|
||||
int pixel_h; /**< height in pixels (used for creating back buffers) */
|
||||
|
|
|
@ -154,6 +154,7 @@ struct SDL_VideoDisplay
|
|||
int num_fullscreen_modes;
|
||||
SDL_DisplayMode *fullscreen_modes;
|
||||
SDL_DisplayMode desktop_mode;
|
||||
const SDL_DisplayMode *current_mode;
|
||||
SDL_DisplayOrientation orientation;
|
||||
|
||||
SDL_Window *fullscreen_window;
|
||||
|
|
|
@ -649,7 +649,7 @@ SDL_DisplayID SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send
|
|||
}
|
||||
|
||||
new_display->desktop_mode.displayID = id;
|
||||
new_display->desktop_mode.flags = (SDL_DISPLAYMODE_DESKTOP | SDL_DISPLAYMODE_CURRENT);
|
||||
new_display->current_mode = &new_display->desktop_mode;
|
||||
SDL_FinalizeDisplayMode(&new_display->desktop_mode);
|
||||
|
||||
if (send_event) {
|
||||
|
@ -782,7 +782,6 @@ const char *SDL_GetDisplayName(SDL_DisplayID displayID)
|
|||
int SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect)
|
||||
{
|
||||
SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID);
|
||||
const SDL_DisplayMode *mode;
|
||||
|
||||
CHECK_DISPLAY_MAGIC(display, -1);
|
||||
|
||||
|
@ -804,14 +803,8 @@ int SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect)
|
|||
SDL_GetDisplayBounds(_this->displays[SDL_GetDisplayIndex(displayID) - 1].id, rect);
|
||||
rect->x += rect->w;
|
||||
}
|
||||
mode = SDL_GetCurrentDisplayMode(displayID);
|
||||
if (mode) {
|
||||
rect->w = mode->screen_w;
|
||||
rect->h = mode->screen_h;
|
||||
} else {
|
||||
rect->w = 0;
|
||||
rect->h = 0;
|
||||
}
|
||||
rect->w = display->current_mode->screen_w;
|
||||
rect->h = display->current_mode->screen_h;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -929,22 +922,11 @@ SDL_bool SDL_AddFullscreenDisplayMode(SDL_VideoDisplay *display, const SDL_Displ
|
|||
new_mode.displayID = display->id;
|
||||
SDL_FinalizeDisplayMode(&new_mode);
|
||||
|
||||
if ((new_mode.flags & SDL_DISPLAYMODE_CURRENT) != 0) {
|
||||
display->desktop_mode.flags &= ~SDL_DISPLAYMODE_CURRENT;
|
||||
for (i = 0; i < display->num_fullscreen_modes; ++i) {
|
||||
display->fullscreen_modes[i].flags &= ~SDL_DISPLAYMODE_CURRENT;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure we don't already have the mode in the list */
|
||||
modes = display->fullscreen_modes;
|
||||
nmodes = display->num_fullscreen_modes;
|
||||
for (i = 0; i < nmodes; ++i) {
|
||||
if (cmpmodes(&new_mode, &modes[i]) == 0) {
|
||||
/* If the new mode is current, make sure we save that */
|
||||
if ((new_mode.flags & SDL_DISPLAYMODE_CURRENT) != 0) {
|
||||
SDL_memcpy(&modes[i], &new_mode, sizeof(modes[i]));
|
||||
}
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -979,6 +961,7 @@ void SDL_ResetFullscreenDisplayModes(SDL_VideoDisplay *display)
|
|||
display->fullscreen_modes = NULL;
|
||||
display->num_fullscreen_modes = 0;
|
||||
display->max_fullscreen_modes = 0;
|
||||
display->current_mode = &display->desktop_mode;
|
||||
}
|
||||
|
||||
const SDL_DisplayMode **SDL_GetFullscreenDisplayModes(SDL_DisplayID displayID, int *count)
|
||||
|
@ -1077,7 +1060,6 @@ void SDL_SetDesktopDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode
|
|||
{
|
||||
SDL_memcpy(&display->desktop_mode, mode, sizeof(*mode));
|
||||
display->desktop_mode.displayID = display->id;
|
||||
display->desktop_mode.flags = (SDL_DISPLAYMODE_DESKTOP | SDL_DISPLAYMODE_CURRENT);
|
||||
SDL_FinalizeDisplayMode(&display->desktop_mode);
|
||||
}
|
||||
|
||||
|
@ -1092,48 +1074,21 @@ const SDL_DisplayMode *SDL_GetDesktopDisplayMode(SDL_DisplayID displayID)
|
|||
|
||||
void SDL_SetCurrentDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (mode == &display->desktop_mode) {
|
||||
display->desktop_mode.flags |= SDL_DISPLAYMODE_CURRENT;
|
||||
} else {
|
||||
display->desktop_mode.flags &= ~SDL_DISPLAYMODE_CURRENT;
|
||||
}
|
||||
|
||||
for (i = 0; i < display->num_fullscreen_modes; ++i) {
|
||||
if (mode == &display->fullscreen_modes[i]) {
|
||||
display->fullscreen_modes[i].flags |= SDL_DISPLAYMODE_CURRENT;
|
||||
} else {
|
||||
display->fullscreen_modes[i].flags &= ~SDL_DISPLAYMODE_CURRENT;
|
||||
}
|
||||
}
|
||||
SDL_assert((mode->flags & SDL_DISPLAYMODE_CURRENT) != 0);
|
||||
display->current_mode = mode;
|
||||
}
|
||||
|
||||
const SDL_DisplayMode *SDL_GetCurrentDisplayMode(SDL_DisplayID displayID)
|
||||
{
|
||||
SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID);
|
||||
const SDL_DisplayMode **modes;
|
||||
const SDL_DisplayMode *current_mode = NULL;
|
||||
|
||||
CHECK_DISPLAY_MAGIC(display, NULL);
|
||||
|
||||
modes = SDL_GetFullscreenDisplayModes(displayID, NULL);
|
||||
if (modes) {
|
||||
int i;
|
||||
/* Make sure our mode list is updated */
|
||||
if (display->num_fullscreen_modes == 0 && _this->GetDisplayModes) {
|
||||
_this->GetDisplayModes(_this, display);
|
||||
}
|
||||
|
||||
for (i = 0; modes[i]; ++i) {
|
||||
if ((modes[i]->flags & SDL_DISPLAYMODE_CURRENT) != 0) {
|
||||
current_mode = modes[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
SDL_free(modes);
|
||||
}
|
||||
if (current_mode == NULL) {
|
||||
current_mode = &display->desktop_mode;
|
||||
}
|
||||
return current_mode;
|
||||
return display->current_mode;
|
||||
}
|
||||
|
||||
static int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, SDL_DisplayMode *mode)
|
||||
|
@ -1142,7 +1097,7 @@ static int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, SDL_DisplayMo
|
|||
mode = &display->desktop_mode;
|
||||
}
|
||||
|
||||
if ((mode->flags & SDL_DISPLAYMODE_CURRENT) != 0) {
|
||||
if (mode == display->current_mode) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -622,7 +622,7 @@ void Cocoa_QuitModes(_THIS)
|
|||
SDL_VideoDisplay *display = &_this->displays[i];
|
||||
SDL_DisplayModeData *mode;
|
||||
|
||||
if (SDL_GetCurrentDisplayMode(display->id) != SDL_GetDesktopDisplayMode(display->id)) {
|
||||
if (display->current_mode->driverdata != display->desktop_mode.driverdata) {
|
||||
Cocoa_SetDisplayMode(_this, display, &display->desktop_mode);
|
||||
}
|
||||
|
||||
|
|
|
@ -301,7 +301,7 @@ SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window *window)
|
|||
attr[i++] = profile;
|
||||
|
||||
attr[i++] = NSOpenGLPFAColorSize;
|
||||
attr[i++] = 32;
|
||||
attr[i++] = SDL_BYTESPERPIXEL(display->current_mode->format) * 8;
|
||||
|
||||
attr[i++] = NSOpenGLPFADepthSize;
|
||||
attr[i++] = _this->gl_config.depth_size;
|
||||
|
|
|
@ -139,7 +139,6 @@ static void N3DS_VideoQuit(_THIS)
|
|||
static int N3DS_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
|
||||
{
|
||||
SDL_DisplayData *driver_data = display->driverdata;
|
||||
const SDL_DisplayMode *mode = SDL_GetCurrentDisplayMode(display->id);
|
||||
|
||||
if (driver_data == NULL) {
|
||||
return -1;
|
||||
|
@ -147,8 +146,8 @@ static int N3DS_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rec
|
|||
|
||||
rect->x = 0;
|
||||
rect->y = (driver_data->screen == GFX_TOP) ? 0 : GSP_SCREEN_WIDTH;
|
||||
rect->w = mode->screen_w;
|
||||
rect->h = mode->screen_h;
|
||||
rect->w = display->current_mode->screen_w;
|
||||
rect->h = display->current_mode->screen_h;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -972,11 +972,10 @@ int Wayland_VideoInit(_THIS)
|
|||
static int Wayland_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
|
||||
{
|
||||
SDL_DisplayData *driverdata = display->driverdata;
|
||||
const SDL_DisplayMode *mode = SDL_GetCurrentDisplayMode(display->id);
|
||||
rect->x = driverdata->x;
|
||||
rect->y = driverdata->y;
|
||||
rect->w = mode->screen_w;
|
||||
rect->h = mode->screen_h;
|
||||
rect->w = display->current_mode->screen_w;
|
||||
rect->h = display->current_mode->screen_h;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -470,9 +470,8 @@ static int X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data)
|
|||
if ((dev) && (dev->displays) && (dev->num_displays > 0)) {
|
||||
const SDL_VideoDisplay *dpy = &dev->displays[0];
|
||||
const SDL_DisplayData *dpydata = dpy->driverdata;
|
||||
const SDL_DisplayMode *mode = SDL_GetCurrentDisplayMode(dpy->id);
|
||||
x = dpydata->x + ((mode->pixel_w - data->dialog_width) / 2);
|
||||
y = dpydata->y + ((mode->pixel_h - data->dialog_height) / 3);
|
||||
x = dpydata->x + ((dpy->current_mode->pixel_w - data->dialog_width) / 2);
|
||||
y = dpydata->y + ((dpy->current_mode->pixel_h - data->dialog_height) / 3);
|
||||
} else { /* oh well. This will misposition on a multi-head setup. Init first next time. */
|
||||
x = (DisplayWidth(display, data->screen) - data->dialog_width) / 2;
|
||||
y = (DisplayHeight(display, data->screen) - data->dialog_height) / 3;
|
||||
|
|
|
@ -816,12 +816,11 @@ void X11_QuitModes(_THIS)
|
|||
int X11_GetDisplayBounds(_THIS, SDL_VideoDisplay *sdl_display, SDL_Rect *rect)
|
||||
{
|
||||
SDL_DisplayData *data = sdl_display->driverdata;
|
||||
const SDL_DisplayMode *mode = SDL_GetCurrentDisplayMode(sdl_display->id);
|
||||
|
||||
rect->x = data->x;
|
||||
rect->y = data->y;
|
||||
rect->w = mode->screen_w;
|
||||
rect->h = mode->screen_h;
|
||||
rect->w = sdl_display->current_mode->screen_w;
|
||||
rect->h = sdl_display->current_mode->screen_h;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue