|
|
@@ -422,18 +422,27 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
|
|
|
SDL_GetDesktopDisplayMode(0, &mode);
|
|
|
DXGI_FORMAT fullscreenFormat = SDL_BITSPERPIXEL(mode.format) == 16 ? DXGI_FORMAT_B5G6R5_UNORM : DXGI_FORMAT_R8G8B8A8_UNORM;
|
|
|
|
|
|
+ bool center = false;
|
|
|
+
|
|
|
// If zero dimensions in windowed mode, set windowed mode to maximize and set a predefined default restored window size. If zero in fullscreen, use desktop mode
|
|
|
if (!width || !height)
|
|
|
{
|
|
|
- if (fullscreen || borderless || maximize)
|
|
|
+ if (fullscreen || borderless)
|
|
|
{
|
|
|
width = mode.w;
|
|
|
height = mode.h;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- width = 1024;
|
|
|
- height = 768;
|
|
|
+ // If we don't have a height/width calculate a reasonable starting window size, and center it
|
|
|
+ // this will also be the restore size when switching from maximized
|
|
|
+ float ratio = float(mode.h) / float(mode.w);
|
|
|
+ width = mode.w - 200;
|
|
|
+ height = (int) (float (mode.w - 200) * ratio);
|
|
|
+ SetWindowPosition(mode.w/2 - width/2, mode.h/2 - height/2);
|
|
|
+
|
|
|
+ if (!maximize)
|
|
|
+ center = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -484,13 +493,13 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (maximize)
|
|
|
+ width = height = 0;
|
|
|
+
|
|
|
AdjustWindow(width, height, fullscreen, borderless);
|
|
|
|
|
|
- if (maximize)
|
|
|
- {
|
|
|
- Maximize();
|
|
|
- SDL_GetWindowSize(impl_->window_, &width, &height);
|
|
|
- }
|
|
|
+ if (center)
|
|
|
+ CenterWindow();
|
|
|
|
|
|
if (!impl_->device_ || multiSample_ != multiSample)
|
|
|
CreateDevice(width, height, multiSample);
|