When the window fullscreen mode changes, update the display resolution
parent
707fd9f071
commit
4750fe7390
|
@ -122,7 +122,7 @@ static SDL_VideoDevice *_this = NULL;
|
||||||
return retval; \
|
return retval; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FULLSCREEN_MASK ( SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN )
|
#define FULLSCREEN_MASK (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN)
|
||||||
|
|
||||||
#ifdef __MACOSX__
|
#ifdef __MACOSX__
|
||||||
/* Support for Mac OS X fullscreen spaces */
|
/* Support for Mac OS X fullscreen spaces */
|
||||||
|
@ -626,9 +626,9 @@ SDL_GetIndexOfDisplay(SDL_VideoDisplay *display)
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
SDL_GetDisplayDriverData( int displayIndex )
|
SDL_GetDisplayDriverData(int displayIndex)
|
||||||
{
|
{
|
||||||
CHECK_DISPLAY_INDEX( displayIndex, NULL );
|
CHECK_DISPLAY_INDEX(displayIndex, NULL);
|
||||||
|
|
||||||
return _this->displays[displayIndex].driverdata;
|
return _this->displays[displayIndex].driverdata;
|
||||||
}
|
}
|
||||||
|
@ -1020,6 +1020,13 @@ SDL_SetWindowDisplayMode(SDL_Window * window, const SDL_DisplayMode * mode)
|
||||||
} else {
|
} else {
|
||||||
SDL_zero(window->fullscreen_mode);
|
SDL_zero(window->fullscreen_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FULLSCREEN_VISIBLE(window) && (window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
|
||||||
|
SDL_DisplayMode fullscreen_mode;
|
||||||
|
if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
|
||||||
|
SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1029,12 +1036,12 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode)
|
||||||
SDL_DisplayMode fullscreen_mode;
|
SDL_DisplayMode fullscreen_mode;
|
||||||
SDL_VideoDisplay *display;
|
SDL_VideoDisplay *display;
|
||||||
|
|
||||||
|
CHECK_WINDOW_MAGIC(window, -1);
|
||||||
|
|
||||||
if (!mode) {
|
if (!mode) {
|
||||||
return SDL_InvalidParamError("mode");
|
return SDL_InvalidParamError("mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_WINDOW_MAGIC(window, -1);
|
|
||||||
|
|
||||||
fullscreen_mode = window->fullscreen_mode;
|
fullscreen_mode = window->fullscreen_mode;
|
||||||
if (!fullscreen_mode.w) {
|
if (!fullscreen_mode.w) {
|
||||||
fullscreen_mode.w = window->w;
|
fullscreen_mode.w = window->w;
|
||||||
|
@ -1046,11 +1053,9 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode)
|
||||||
display = SDL_GetDisplayForWindow(window);
|
display = SDL_GetDisplayForWindow(window);
|
||||||
|
|
||||||
/* if in desktop size mode, just return the size of the desktop */
|
/* if in desktop size mode, just return the size of the desktop */
|
||||||
if ( ( window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP ) == SDL_WINDOW_FULLSCREEN_DESKTOP )
|
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
|
||||||
{
|
|
||||||
fullscreen_mode = display->desktop_mode;
|
fullscreen_mode = display->desktop_mode;
|
||||||
}
|
} else if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window),
|
||||||
else if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window),
|
|
||||||
&fullscreen_mode,
|
&fullscreen_mode,
|
||||||
&fullscreen_mode)) {
|
&fullscreen_mode)) {
|
||||||
return SDL_SetError("Couldn't find display mode match");
|
return SDL_SetError("Couldn't find display mode match");
|
||||||
|
@ -1450,7 +1455,7 @@ SDL_GetWindowFlags(SDL_Window * window)
|
||||||
void
|
void
|
||||||
SDL_SetWindowTitle(SDL_Window * window, const char *title)
|
SDL_SetWindowTitle(SDL_Window * window, const char *title)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
|
|
||||||
if (title == window->title) {
|
if (title == window->title) {
|
||||||
return;
|
return;
|
||||||
|
@ -1478,7 +1483,7 @@ SDL_GetWindowTitle(SDL_Window * window)
|
||||||
void
|
void
|
||||||
SDL_SetWindowIcon(SDL_Window * window, SDL_Surface * icon)
|
SDL_SetWindowIcon(SDL_Window * window, SDL_Surface * icon)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
|
|
||||||
if (!icon) {
|
if (!icon) {
|
||||||
return;
|
return;
|
||||||
|
@ -1568,7 +1573,7 @@ SDL_GetWindowData(SDL_Window * window, const char *name)
|
||||||
void
|
void
|
||||||
SDL_SetWindowPosition(SDL_Window * window, int x, int y)
|
SDL_SetWindowPosition(SDL_Window * window, int x, int y)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
|
|
||||||
if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) {
|
if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) {
|
||||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||||
|
@ -1612,7 +1617,7 @@ SDL_SetWindowPosition(SDL_Window * window, int x, int y)
|
||||||
void
|
void
|
||||||
SDL_GetWindowPosition(SDL_Window * window, int *x, int *y)
|
SDL_GetWindowPosition(SDL_Window * window, int *x, int *y)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
|
|
||||||
/* Fullscreen windows are always at their display's origin */
|
/* Fullscreen windows are always at their display's origin */
|
||||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||||
|
@ -1635,7 +1640,7 @@ SDL_GetWindowPosition(SDL_Window * window, int *x, int *y)
|
||||||
void
|
void
|
||||||
SDL_SetWindowBordered(SDL_Window * window, SDL_bool bordered)
|
SDL_SetWindowBordered(SDL_Window * window, SDL_bool bordered)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
||||||
const int want = (bordered != SDL_FALSE); /* normalize the flag. */
|
const int want = (bordered != SDL_FALSE); /* normalize the flag. */
|
||||||
const int have = ((window->flags & SDL_WINDOW_BORDERLESS) == 0);
|
const int have = ((window->flags & SDL_WINDOW_BORDERLESS) == 0);
|
||||||
|
@ -1653,7 +1658,7 @@ SDL_SetWindowBordered(SDL_Window * window, SDL_bool bordered)
|
||||||
void
|
void
|
||||||
SDL_SetWindowSize(SDL_Window * window, int w, int h)
|
SDL_SetWindowSize(SDL_Window * window, int w, int h)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
if (w <= 0) {
|
if (w <= 0) {
|
||||||
SDL_InvalidParamError("w");
|
SDL_InvalidParamError("w");
|
||||||
return;
|
return;
|
||||||
|
@ -1681,10 +1686,16 @@ SDL_SetWindowSize(SDL_Window * window, int w, int h)
|
||||||
h = window->max_h;
|
h = window->max_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Should this change fullscreen modes? */
|
|
||||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||||
window->windowed.w = w;
|
window->windowed.w = w;
|
||||||
window->windowed.h = h;
|
window->windowed.h = h;
|
||||||
|
|
||||||
|
if (FULLSCREEN_VISIBLE(window) && (window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
|
||||||
|
SDL_DisplayMode fullscreen_mode;
|
||||||
|
if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
|
||||||
|
SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
window->w = w;
|
window->w = w;
|
||||||
window->h = h;
|
window->h = h;
|
||||||
|
@ -1701,7 +1712,7 @@ SDL_SetWindowSize(SDL_Window * window, int w, int h)
|
||||||
void
|
void
|
||||||
SDL_GetWindowSize(SDL_Window * window, int *w, int *h)
|
SDL_GetWindowSize(SDL_Window * window, int *w, int *h)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
if (w) {
|
if (w) {
|
||||||
*w = window->w;
|
*w = window->w;
|
||||||
}
|
}
|
||||||
|
@ -1713,7 +1724,7 @@ SDL_GetWindowSize(SDL_Window * window, int *w, int *h)
|
||||||
void
|
void
|
||||||
SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
|
SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
if (min_w <= 0) {
|
if (min_w <= 0) {
|
||||||
SDL_InvalidParamError("min_w");
|
SDL_InvalidParamError("min_w");
|
||||||
return;
|
return;
|
||||||
|
@ -1737,7 +1748,7 @@ SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
|
||||||
void
|
void
|
||||||
SDL_GetWindowMinimumSize(SDL_Window * window, int *min_w, int *min_h)
|
SDL_GetWindowMinimumSize(SDL_Window * window, int *min_w, int *min_h)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
if (min_w) {
|
if (min_w) {
|
||||||
*min_w = window->min_w;
|
*min_w = window->min_w;
|
||||||
}
|
}
|
||||||
|
@ -1749,7 +1760,7 @@ SDL_GetWindowMinimumSize(SDL_Window * window, int *min_w, int *min_h)
|
||||||
void
|
void
|
||||||
SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h)
|
SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
if (max_w <= 0) {
|
if (max_w <= 0) {
|
||||||
SDL_InvalidParamError("max_w");
|
SDL_InvalidParamError("max_w");
|
||||||
return;
|
return;
|
||||||
|
@ -1773,7 +1784,7 @@ SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h)
|
||||||
void
|
void
|
||||||
SDL_GetWindowMaximumSize(SDL_Window * window, int *max_w, int *max_h)
|
SDL_GetWindowMaximumSize(SDL_Window * window, int *max_w, int *max_h)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
if (max_w) {
|
if (max_w) {
|
||||||
*max_w = window->max_w;
|
*max_w = window->max_w;
|
||||||
}
|
}
|
||||||
|
@ -1785,7 +1796,7 @@ SDL_GetWindowMaximumSize(SDL_Window * window, int *max_w, int *max_h)
|
||||||
void
|
void
|
||||||
SDL_ShowWindow(SDL_Window * window)
|
SDL_ShowWindow(SDL_Window * window)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
|
|
||||||
if (window->flags & SDL_WINDOW_SHOWN) {
|
if (window->flags & SDL_WINDOW_SHOWN) {
|
||||||
return;
|
return;
|
||||||
|
@ -1800,7 +1811,7 @@ SDL_ShowWindow(SDL_Window * window)
|
||||||
void
|
void
|
||||||
SDL_HideWindow(SDL_Window * window)
|
SDL_HideWindow(SDL_Window * window)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
|
|
||||||
if (!(window->flags & SDL_WINDOW_SHOWN)) {
|
if (!(window->flags & SDL_WINDOW_SHOWN)) {
|
||||||
return;
|
return;
|
||||||
|
@ -1817,7 +1828,7 @@ SDL_HideWindow(SDL_Window * window)
|
||||||
void
|
void
|
||||||
SDL_RaiseWindow(SDL_Window * window)
|
SDL_RaiseWindow(SDL_Window * window)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
|
|
||||||
if (!(window->flags & SDL_WINDOW_SHOWN)) {
|
if (!(window->flags & SDL_WINDOW_SHOWN)) {
|
||||||
return;
|
return;
|
||||||
|
@ -1830,7 +1841,7 @@ SDL_RaiseWindow(SDL_Window * window)
|
||||||
void
|
void
|
||||||
SDL_MaximizeWindow(SDL_Window * window)
|
SDL_MaximizeWindow(SDL_Window * window)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
|
|
||||||
if (window->flags & SDL_WINDOW_MAXIMIZED) {
|
if (window->flags & SDL_WINDOW_MAXIMIZED) {
|
||||||
return;
|
return;
|
||||||
|
@ -1846,7 +1857,7 @@ SDL_MaximizeWindow(SDL_Window * window)
|
||||||
void
|
void
|
||||||
SDL_MinimizeWindow(SDL_Window * window)
|
SDL_MinimizeWindow(SDL_Window * window)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
|
|
||||||
if (window->flags & SDL_WINDOW_MINIMIZED) {
|
if (window->flags & SDL_WINDOW_MINIMIZED) {
|
||||||
return;
|
return;
|
||||||
|
@ -1862,7 +1873,7 @@ SDL_MinimizeWindow(SDL_Window * window)
|
||||||
void
|
void
|
||||||
SDL_RestoreWindow(SDL_Window * window)
|
SDL_RestoreWindow(SDL_Window * window)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
|
|
||||||
if (!(window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) {
|
if (!(window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) {
|
||||||
return;
|
return;
|
||||||
|
@ -1880,7 +1891,7 @@ SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags)
|
||||||
|
|
||||||
flags &= FULLSCREEN_MASK;
|
flags &= FULLSCREEN_MASK;
|
||||||
|
|
||||||
if ( flags == (window->flags & FULLSCREEN_MASK) ) {
|
if (flags == (window->flags & FULLSCREEN_MASK)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2083,7 +2094,7 @@ SDL_UpdateWindowGrab(SDL_Window * window)
|
||||||
void
|
void
|
||||||
SDL_SetWindowGrab(SDL_Window * window, SDL_bool grabbed)
|
SDL_SetWindowGrab(SDL_Window * window, SDL_bool grabbed)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
|
|
||||||
if (!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED)) {
|
if (!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED)) {
|
||||||
return;
|
return;
|
||||||
|
@ -2239,7 +2250,7 @@ SDL_DestroyWindow(SDL_Window * window)
|
||||||
{
|
{
|
||||||
SDL_VideoDisplay *display;
|
SDL_VideoDisplay *display;
|
||||||
|
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
|
|
||||||
window->is_destroying = SDL_TRUE;
|
window->is_destroying = SDL_TRUE;
|
||||||
|
|
||||||
|
@ -2468,7 +2479,7 @@ SDL_GL_UnloadLibrary(void)
|
||||||
static SDL_INLINE SDL_bool
|
static SDL_INLINE SDL_bool
|
||||||
isAtLeastGL3(const char *verstr)
|
isAtLeastGL3(const char *verstr)
|
||||||
{
|
{
|
||||||
return ( verstr && (SDL_atoi(verstr) >= 3) );
|
return (verstr && (SDL_atoi(verstr) >= 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool
|
SDL_bool
|
||||||
|
@ -2675,20 +2686,20 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value)
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case SDL_GL_CONTEXT_FLAGS:
|
case SDL_GL_CONTEXT_FLAGS:
|
||||||
if( value & ~(SDL_GL_CONTEXT_DEBUG_FLAG |
|
if (value & ~(SDL_GL_CONTEXT_DEBUG_FLAG |
|
||||||
SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG |
|
SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG |
|
||||||
SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG |
|
SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG |
|
||||||
SDL_GL_CONTEXT_RESET_ISOLATION_FLAG) ) {
|
SDL_GL_CONTEXT_RESET_ISOLATION_FLAG)) {
|
||||||
retval = SDL_SetError("Unknown OpenGL context flag %d", value);
|
retval = SDL_SetError("Unknown OpenGL context flag %d", value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_this->gl_config.flags = value;
|
_this->gl_config.flags = value;
|
||||||
break;
|
break;
|
||||||
case SDL_GL_CONTEXT_PROFILE_MASK:
|
case SDL_GL_CONTEXT_PROFILE_MASK:
|
||||||
if( value != 0 &&
|
if (value != 0 &&
|
||||||
value != SDL_GL_CONTEXT_PROFILE_CORE &&
|
value != SDL_GL_CONTEXT_PROFILE_CORE &&
|
||||||
value != SDL_GL_CONTEXT_PROFILE_COMPATIBILITY &&
|
value != SDL_GL_CONTEXT_PROFILE_COMPATIBILITY &&
|
||||||
value != SDL_GL_CONTEXT_PROFILE_ES ) {
|
value != SDL_GL_CONTEXT_PROFILE_ES) {
|
||||||
retval = SDL_SetError("Unknown OpenGL context profile %d", value);
|
retval = SDL_SetError("Unknown OpenGL context profile %d", value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2971,7 +2982,7 @@ SDL_GL_GetCurrentContext(void)
|
||||||
|
|
||||||
void SDL_GL_GetDrawableSize(SDL_Window * window, int *w, int *h)
|
void SDL_GL_GetDrawableSize(SDL_Window * window, int *w, int *h)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
|
|
||||||
if (_this->GL_GetDrawableSize) {
|
if (_this->GL_GetDrawableSize) {
|
||||||
_this->GL_GetDrawableSize(_this, window, w, h);
|
_this->GL_GetDrawableSize(_this, window, w, h);
|
||||||
|
@ -3011,7 +3022,7 @@ SDL_GL_GetSwapInterval(void)
|
||||||
void
|
void
|
||||||
SDL_GL_SwapWindow(SDL_Window * window)
|
SDL_GL_SwapWindow(SDL_Window * window)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
|
|
||||||
if (!(window->flags & SDL_WINDOW_OPENGL)) {
|
if (!(window->flags & SDL_WINDOW_OPENGL)) {
|
||||||
SDL_SetError("The specified window isn't an OpenGL window");
|
SDL_SetError("The specified window isn't an OpenGL window");
|
||||||
|
|
Loading…
Reference in New Issue