From fcc292a40ffbe7ff57ec1fb93c666eb260a8c42a Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Thu, 3 Aug 2023 15:43:18 +0200 Subject: [PATCH] source/Platform/Win32/Win32Display.cpp: in create() fix a bug where window size was initially not setup correctly causing two resize events. --- source/Platform/Win32/Win32Display.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/source/Platform/Win32/Win32Display.cpp b/source/Platform/Win32/Win32Display.cpp index 78f4be0..23f53c7 100644 --- a/source/Platform/Win32/Win32Display.cpp +++ b/source/Platform/Win32/Win32Display.cpp @@ -42,20 +42,26 @@ Win32Display::~Win32Display() bool Win32Display::create(DisplayDescription description) { DWORD flags; - Vector2i pos; + Vector2i pos, actual_size; if (firstTime) { registerClass(); firstTime = false; } + // Store the size for use later. + m_size = Vector2u(description.mode.width, description.mode.height); + // Set window to center and set decoration flags. pos = centerWindow(description.mode.width, description.mode.height); flags = getWin32Flags(description.decoration); + // Calculate the actuall window size (with borders and stuff) + actual_size = calculateSize(flags, description.mode.width, description.mode.height); + // Create window. m_handle = CreateWindowExA(0, WND_CLASSNAME, "", flags, - pos.x, pos.y, description.mode.width, description.mode.height, + pos.x, pos.y, actual_size.x, actual_size.y, NULL, NULL, GetModuleHandle(NULL), (LPVOID) this); if (!m_handle) { @@ -63,11 +69,6 @@ bool Win32Display::create(DisplayDescription description) return false; } - setSize(description.mode.width, description.mode.height); - - // Store the size for use later. - m_size = getSize(); - return true; }