From 2ae116c72b41b6d8f5dab3a03472e0bc4ce0657b Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Fri, 9 Jun 2023 16:27:43 -0700 Subject: [PATCH] fix window dimensions when starting in fullscreen --- src/Window.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Window.cs b/src/Window.cs index 8354663c..4b45d39f 100644 --- a/src/Window.cs +++ b/src/Window.cs @@ -45,17 +45,21 @@ namespace MoonWorks ScreenMode = windowCreateInfo.ScreenMode; + SDL.SDL_GetDesktopDisplayMode(0, out var displayMode); + Handle = SDL.SDL_CreateWindow( windowCreateInfo.WindowTitle, - SDL.SDL_WINDOWPOS_UNDEFINED, - SDL.SDL_WINDOWPOS_UNDEFINED, - (int) windowCreateInfo.WindowWidth, - (int) windowCreateInfo.WindowHeight, + SDL.SDL_WINDOWPOS_CENTERED, + SDL.SDL_WINDOWPOS_CENTERED, + windowCreateInfo.ScreenMode == ScreenMode.Windowed ? (int) windowCreateInfo.WindowWidth : displayMode.w, + windowCreateInfo.ScreenMode == ScreenMode.Windowed ? (int) windowCreateInfo.WindowHeight : displayMode.h, flags ); - Width = windowCreateInfo.WindowWidth; - Height = windowCreateInfo.WindowHeight; + /* Requested size might be different in fullscreen, so let's just get the area */ + SDL.SDL_GetWindowSize(Handle, out var width, out var height); + Width = (uint) width; + Height = (uint) height; idLookup.Add(SDL.SDL_GetWindowID(Handle), this); }