Setting the window size changes the fullscreen display mode, unless a window display mode has been set. Testing: * Ran testsprite2 --fullscreen, used Ctrl+ and Ctrl- to change window sizes, verified that the display mode changed as well.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c
index 0c35c39..70ec0f9 100644
--- a/src/render/direct3d/SDL_render_d3d.c
+++ b/src/render/direct3d/SDL_render_d3d.c
@@ -462,15 +462,21 @@ D3D_ActivateRenderer(SDL_Renderer * renderer)
if (data->updateSize) {
SDL_Window *window = renderer->window;
int w, h;
+ Uint32 window_flags = SDL_GetWindowFlags(window);
SDL_GetWindowSize(window, &w, &h);
data->pparams.BackBufferWidth = w;
data->pparams.BackBufferHeight = h;
- if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) {
- data->pparams.BackBufferFormat =
- PixelFormatToD3DFMT(SDL_GetWindowPixelFormat(window));
+ if (window_flags & SDL_WINDOW_FULLSCREEN && (window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
+ SDL_DisplayMode fullscreen_mode;
+ SDL_GetWindowDisplayMode(window, &fullscreen_mode);
+ data->pparams.Windowed = FALSE;
+ data->pparams.BackBufferFormat = PixelFormatToD3DFMT(fullscreen_mode.format);
+ data->pparams.FullScreen_RefreshRateInHz = fullscreen_mode.refresh_rate;
} else {
+ data->pparams.Windowed = TRUE;
data->pparams.BackBufferFormat = D3DFMT_UNKNOWN;
+ data->pparams.FullScreen_RefreshRateInHz = 0;
}
if (D3D_Reset(renderer) < 0) {
return -1;
@@ -565,25 +571,16 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
pparams.hDeviceWindow = windowinfo.info.win.window;
pparams.BackBufferWidth = w;
pparams.BackBufferHeight = h;
- if (window_flags & SDL_WINDOW_FULLSCREEN) {
- pparams.BackBufferFormat =
- PixelFormatToD3DFMT(fullscreen_mode.format);
- } else {
- pparams.BackBufferFormat = D3DFMT_UNKNOWN;
- }
pparams.BackBufferCount = 1;
pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
- if (window_flags & SDL_WINDOW_FULLSCREEN) {
- if ((window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
- pparams.Windowed = TRUE;
- pparams.FullScreen_RefreshRateInHz = 0;
- } else {
- pparams.Windowed = FALSE;
- pparams.FullScreen_RefreshRateInHz = fullscreen_mode.refresh_rate;
- }
+ if (window_flags & SDL_WINDOW_FULLSCREEN && (window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
+ pparams.Windowed = FALSE;
+ pparams.BackBufferFormat = PixelFormatToD3DFMT(fullscreen_mode.format);
+ pparams.FullScreen_RefreshRateInHz = fullscreen_mode.refresh_rate;
} else {
pparams.Windowed = TRUE;
+ pparams.BackBufferFormat = D3DFMT_UNKNOWN;
pparams.FullScreen_RefreshRateInHz = 0;
}
if (flags & SDL_RENDERER_PRESENTVSYNC) {
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index c3a2655..f642f7c 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1044,10 +1044,10 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode)
fullscreen_mode = window->fullscreen_mode;
if (!fullscreen_mode.w) {
- fullscreen_mode.w = window->w;
+ fullscreen_mode.w = window->windowed.w;
}
if (!fullscreen_mode.h) {
- fullscreen_mode.h = window->h;
+ fullscreen_mode.h = window->windowed.h;
}
display = SDL_GetDisplayForWindow(window);
@@ -1093,9 +1093,9 @@ static void
SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
{
SDL_VideoDisplay *display;
- SDL_Window *other;
+ SDL_Window *other;
- CHECK_WINDOW_MAGIC(window,);
+ CHECK_WINDOW_MAGIC(window,);
#ifdef __MACOSX__
if (Cocoa_SetWindowFullscreenSpace(window, fullscreen)) {
@@ -1688,15 +1688,13 @@ SDL_SetWindowSize(SDL_Window * window, int w, int h)
h = window->max_h;
}
- if (window->flags & SDL_WINDOW_FULLSCREEN) {
- window->windowed.w = w;
- window->windowed.h = h;
+ window->windowed.w = w;
+ window->windowed.h = h;
+ if (window->flags & SDL_WINDOW_FULLSCREEN) {
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);
- }
+ window->last_fullscreen_flags = 0;
+ SDL_UpdateFullscreenMode(window, SDL_TRUE);
}
} else {
window->w = w;