From cabf8736c72ab67e3ee0ce60aab9d19154e4779b Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Thu, 25 Jul 2024 22:32:00 +0300 Subject: [PATCH] Refactor application window class name --- Source/Engine/Platform/Base/PlatformBase.cpp | 1 + Source/Engine/Platform/Base/PlatformBase.h | 7 +++++++ Source/Engine/Platform/GDK/GDKPlatform.cpp | 5 ++--- Source/Engine/Platform/GDK/GDKPlatform.h | 5 ----- Source/Engine/Platform/GDK/GDKWindow.cpp | 2 +- Source/Engine/Platform/Windows/WindowsPlatform.cpp | 5 ++--- Source/Engine/Platform/Windows/WindowsPlatform.h | 5 ----- Source/Engine/Platform/Windows/WindowsWindow.cpp | 2 +- 8 files changed, 14 insertions(+), 18 deletions(-) diff --git a/Source/Engine/Platform/Base/PlatformBase.cpp b/Source/Engine/Platform/Base/PlatformBase.cpp index 8a6baf4bc..840079684 100644 --- a/Source/Engine/Platform/Base/PlatformBase.cpp +++ b/Source/Engine/Platform/Base/PlatformBase.cpp @@ -45,6 +45,7 @@ static_assert(sizeof(double) == 8, "Invalid double type size."); static_assert((PLATFORM_THREADS_LIMIT & (PLATFORM_THREADS_LIMIT - 1)) == 0, "Threads limit must be power of two."); static_assert(PLATFORM_THREADS_LIMIT % 4 == 0, "Threads limit must be multiple of 4."); +const Char* PlatformBase::ApplicationClassName = TEXT("FlaxWindow"); float PlatformBase::CustomDpiScale = 1.0f; Array> PlatformBase::Users; Delegate PlatformBase::UserAdded; diff --git a/Source/Engine/Platform/Base/PlatformBase.h b/Source/Engine/Platform/Base/PlatformBase.h index 35cfd8d17..e6039f711 100644 --- a/Source/Engine/Platform/Base/PlatformBase.h +++ b/Source/Engine/Platform/Base/PlatformBase.h @@ -166,6 +166,13 @@ DECLARE_SCRIPTING_TYPE_MINIMAL(PlatformBase); /// static void Exit(); +public: + + /// + /// Application windows class name. + /// + static const Char* ApplicationClassName; + public: /// /// Copy memory region diff --git a/Source/Engine/Platform/GDK/GDKPlatform.cpp b/Source/Engine/Platform/GDK/GDKPlatform.cpp index 8d3bd935d..12e0431c5 100644 --- a/Source/Engine/Platform/GDK/GDKPlatform.cpp +++ b/Source/Engine/Platform/GDK/GDKPlatform.cpp @@ -30,7 +30,6 @@ inline bool operator==(const APP_LOCAL_DEVICE_ID& l, const APP_LOCAL_DEVICE_ID& return Platform::MemoryCompare(&l, &r, sizeof(APP_LOCAL_DEVICE_ID)) == 0; } -const Char* GDKPlatform::ApplicationWindowClass = TEXT("FlaxWindow"); void* GDKPlatform::Instance = nullptr; Delegate<> GDKPlatform::Suspended; Delegate<> GDKPlatform::Resumed; @@ -316,7 +315,7 @@ void GDKPlatform::PreInit(void* hInstance) windowsClass.style = CS_HREDRAW | CS_VREDRAW; windowsClass.lpfnWndProc = WndProc; windowsClass.hInstance = (HINSTANCE)Instance; - windowsClass.lpszClassName = ApplicationWindowClass; + windowsClass.lpszClassName = ApplicationClassName; if (!RegisterClassW(&windowsClass)) { Error(TEXT("Window class registration failed!")); @@ -474,7 +473,7 @@ void GDKPlatform::Exit() if (PlmSignalResume) CloseHandle(PlmSignalResume); - UnregisterClassW(ApplicationWindowClass, nullptr); + UnregisterClassW(ApplicationClassName, nullptr); XGameRuntimeUninitialize(); } diff --git a/Source/Engine/Platform/GDK/GDKPlatform.h b/Source/Engine/Platform/GDK/GDKPlatform.h index 98297cf33..f054953bf 100644 --- a/Source/Engine/Platform/GDK/GDKPlatform.h +++ b/Source/Engine/Platform/GDK/GDKPlatform.h @@ -13,11 +13,6 @@ class FLAXENGINE_API GDKPlatform : public Win32Platform { public: - /// - /// Win32 application windows class name. - /// - static const Char* ApplicationWindowClass; - /// /// Handle to Win32 application instance. /// diff --git a/Source/Engine/Platform/GDK/GDKWindow.cpp b/Source/Engine/Platform/GDK/GDKWindow.cpp index 8061d3528..371492813 100644 --- a/Source/Engine/Platform/GDK/GDKWindow.cpp +++ b/Source/Engine/Platform/GDK/GDKWindow.cpp @@ -71,7 +71,7 @@ GDKWindow::GDKWindow(const CreateWindowSettings& settings) // Creating the window _handle = CreateWindowExW( exStyle, - Platform::ApplicationWindowClass, + Platform::ApplicationClassName, settings.Title.GetText(), style, x, diff --git a/Source/Engine/Platform/Windows/WindowsPlatform.cpp b/Source/Engine/Platform/Windows/WindowsPlatform.cpp index ba450d7ee..d95494d77 100644 --- a/Source/Engine/Platform/Windows/WindowsPlatform.cpp +++ b/Source/Engine/Platform/Windows/WindowsPlatform.cpp @@ -33,7 +33,6 @@ #define CLR_EXCEPTION 0xE0434352 #define VCPP_EXCEPTION 0xE06D7363 -const Char* WindowsPlatform::ApplicationWindowClass = TEXT("FlaxWindow"); void* WindowsPlatform::Instance = nullptr; #if CRASH_LOG_ENABLE || TRACY_ENABLE @@ -527,7 +526,7 @@ void WindowsPlatform::PreInit(void* hInstance) windowsClass.hInstance = (HINSTANCE)Instance; windowsClass.hIcon = LoadIconW(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDR_MAINFRAME)); windowsClass.hCursor = LoadCursor(nullptr, IDC_ARROW); - windowsClass.lpszClassName = ApplicationWindowClass; + windowsClass.lpszClassName = ApplicationClassName; if (!RegisterClassW(&windowsClass)) { Error(TEXT("Window class registration failed!")); @@ -741,7 +740,7 @@ void WindowsPlatform::Exit() #endif // Unregister app class - UnregisterClassW(ApplicationWindowClass, nullptr); + UnregisterClassW(ApplicationClassName, nullptr); Win32Platform::Exit(); } diff --git a/Source/Engine/Platform/Windows/WindowsPlatform.h b/Source/Engine/Platform/Windows/WindowsPlatform.h index 046b79d58..8d377ed56 100644 --- a/Source/Engine/Platform/Windows/WindowsPlatform.h +++ b/Source/Engine/Platform/Windows/WindowsPlatform.h @@ -13,11 +13,6 @@ class FLAXENGINE_API WindowsPlatform : public Win32Platform { public: - /// - /// Win32 application windows class name. - /// - static const Char* ApplicationWindowClass; - /// /// Handle to Win32 application instance. /// diff --git a/Source/Engine/Platform/Windows/WindowsWindow.cpp b/Source/Engine/Platform/Windows/WindowsWindow.cpp index 99e033570..b75082e58 100644 --- a/Source/Engine/Platform/Windows/WindowsWindow.cpp +++ b/Source/Engine/Platform/Windows/WindowsWindow.cpp @@ -120,7 +120,7 @@ WindowsWindow::WindowsWindow(const CreateWindowSettings& settings) // Creating the window _handle = CreateWindowExW( exStyle, - Platform::ApplicationWindowClass, + Platform::ApplicationClassName, settings.Title.GetText(), style, x,