summaryrefslogtreecommitdiff
path: root/src/video/sdl2_v.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2021-01-16 23:36:15 +0100
committerGitHub <noreply@github.com>2021-01-16 23:36:15 +0100
commit540fdfbf5a8a6bd7fcdf28d62681c1666b66c870 (patch)
tree4d6c16a2216c4dbd21becf27b31d9de5444a5b20 /src/video/sdl2_v.cpp
parentc91a7b5e2e4294bbc489b7a973f4302e05d1bea4 (diff)
downloadopenttd-540fdfbf5a8a6bd7fcdf28d62681c1666b66c870.tar.xz
Fix 0e62a398c7f: Only center the window, when it is smaller than the screen. (#8581)
Diffstat (limited to 'src/video/sdl2_v.cpp')
-rw-r--r--src/video/sdl2_v.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp
index 48bd84691..685610d2c 100644
--- a/src/video/sdl2_v.cpp
+++ b/src/video/sdl2_v.cpp
@@ -275,8 +275,8 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h, bool resize)
int x = SDL_WINDOWPOS_UNDEFINED, y = SDL_WINDOWPOS_UNDEFINED;
SDL_Rect r;
if (SDL_GetDisplayBounds(this->startup_display, &r) == 0) {
- x = r.x + (r.w - w) / 2;
- y = r.y + (r.h - h) / 4; // decent desktops have taskbars at the bottom
+ x = r.x + std::max(0, r.w - static_cast<int>(w)) / 2;
+ y = r.y + std::max(0, r.h - static_cast<int>(h)) / 4; // decent desktops have taskbars at the bottom
}
_sdl_window = SDL_CreateWindow(
caption,