Use CreateWindow/GetBatteryInfo/GetUserLocaleName from Windows instead of SDL for now
#2800
This commit is contained in:
@@ -32,7 +32,9 @@
|
||||
namespace SDLImpl
|
||||
{
|
||||
int32 SystemDpi = 96;
|
||||
#if PLATFORM_LINUX
|
||||
String UserLocale("en");
|
||||
#endif
|
||||
bool WindowDecorationsSupported = true;
|
||||
bool SupportsDecorationDragging = true;
|
||||
String WaylandDisplayEnv;
|
||||
@@ -107,6 +109,7 @@ bool SDLPlatform::Init()
|
||||
if (!SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD))
|
||||
Platform::Fatal(String::Format(TEXT("Failed to initialize SDL: {0}."), String(SDL_GetError())));
|
||||
|
||||
#if PLATFORM_LINUX
|
||||
int localesCount = 0;
|
||||
auto locales = SDL_GetPreferredLocales(&localesCount);
|
||||
for (int i = 0; i < localesCount; i++)
|
||||
@@ -123,6 +126,7 @@ bool SDLPlatform::Init()
|
||||
}
|
||||
}
|
||||
SDL_free(locales);
|
||||
#endif
|
||||
|
||||
if (InitInternal())
|
||||
return true;
|
||||
@@ -214,6 +218,7 @@ bool SDLPlatform::SupportsNativeDecorationDragging()
|
||||
return SDLImpl::SupportsDecorationDragging;
|
||||
}
|
||||
|
||||
#if !PLATFORM_WINDOWS
|
||||
BatteryInfo SDLPlatform::GetBatteryInfo()
|
||||
{
|
||||
BatteryInfo info;
|
||||
@@ -241,16 +246,24 @@ BatteryInfo SDLPlatform::GetBatteryInfo()
|
||||
}
|
||||
return info;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32 SDLPlatform::GetDpi()
|
||||
{
|
||||
return SDLImpl::SystemDpi;
|
||||
}
|
||||
|
||||
#if PLATFORM_LINUX
|
||||
String SDLPlatform::GetUserLocaleName()
|
||||
{
|
||||
return SDLImpl::UserLocale;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool SDLPlatform::CanOpenUrl(const StringView& url)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDLPlatform::OpenUrl(const StringView& url)
|
||||
{
|
||||
@@ -318,6 +331,8 @@ Window* SDLPlatform::CreateWindow(const CreateWindowSettings& settings)
|
||||
return New<SDLWindow>(settings);
|
||||
}
|
||||
|
||||
#if !PLATFORM_WINDOWS
|
||||
|
||||
bool ReadStream(SDL_IOStream*& stream, char* buffer, int64 bufferLength, int64& bufferPosition, LogType logType, CreateProcessSettings& settings)
|
||||
{
|
||||
bool flushBuffer = false;
|
||||
@@ -480,3 +495,5 @@ int32 SDLPlatform::CreateProcess(CreateProcessSettings& settings)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -77,9 +77,14 @@ public:
|
||||
static bool SupportsNativeDecorations();
|
||||
static bool SupportsNativeDecorationDragging();
|
||||
static void SetHighDpiAwarenessEnabled(bool enable);
|
||||
#if !PLATFORM_WINDOWS
|
||||
static BatteryInfo GetBatteryInfo();
|
||||
#endif
|
||||
static int32 GetDpi();
|
||||
#if PLATFORM_LINUX
|
||||
static String GetUserLocaleName();
|
||||
#endif
|
||||
static bool CanOpenUrl(const StringView& url);
|
||||
static void OpenUrl(const StringView& url);
|
||||
static Float2 GetMousePosition();
|
||||
static void SetMousePosition(const Float2& pos);
|
||||
@@ -87,7 +92,9 @@ public:
|
||||
static Rectangle GetMonitorBounds(const Float2& screenPos);
|
||||
static Rectangle GetVirtualDesktopBounds();
|
||||
static Window* CreateWindow(const CreateWindowSettings& settings);
|
||||
#if !PLATFORM_WINDOWS
|
||||
static int32 CreateProcess(CreateProcessSettings& settings);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -775,13 +775,11 @@ bool WindowsPlatform::Init()
|
||||
DWORD tmp;
|
||||
Char buffer[256];
|
||||
|
||||
#if !PLATFORM_SDL
|
||||
// Get user locale string
|
||||
if (GetUserDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH))
|
||||
{
|
||||
UserLocale = String(buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Get computer name string
|
||||
if (GetComputerNameW(buffer, &tmp))
|
||||
@@ -951,12 +949,12 @@ int32 WindowsPlatform::GetDpi()
|
||||
{
|
||||
return SystemDpi;
|
||||
}
|
||||
#endif
|
||||
|
||||
String WindowsPlatform::GetUserLocaleName()
|
||||
{
|
||||
return UserLocale;
|
||||
}
|
||||
#endif
|
||||
|
||||
String WindowsPlatform::GetComputerName()
|
||||
{
|
||||
@@ -1120,7 +1118,6 @@ bool IsProcRunning(HANDLE handle)
|
||||
return WaitForSingleObject(handle, 0) == WAIT_TIMEOUT;
|
||||
}
|
||||
|
||||
#if !PLATFORM_SDL
|
||||
void ReadPipe(HANDLE pipe, Array<char>& rawData, Array<Char>& logData, LogType logType, CreateProcessSettings& settings)
|
||||
{
|
||||
// Check if any data is ready to read
|
||||
@@ -1329,6 +1326,7 @@ int32 WindowsPlatform::CreateProcess(CreateProcessSettings& settings)
|
||||
return result;
|
||||
}
|
||||
|
||||
#if !PLATFORM_SDL
|
||||
Window* WindowsPlatform::CreateWindow(const CreateWindowSettings& settings)
|
||||
{
|
||||
return New<WindowsWindow>(settings);
|
||||
|
||||
@@ -67,8 +67,8 @@ public:
|
||||
static BatteryInfo GetBatteryInfo();
|
||||
#if !PLATFORM_SDL
|
||||
static int32 GetDpi();
|
||||
static String GetUserLocaleName();
|
||||
#endif
|
||||
static String GetUserLocaleName();
|
||||
static String GetComputerName();
|
||||
static bool GetHasFocus();
|
||||
static bool CanOpenUrl(const StringView& url);
|
||||
@@ -81,8 +81,8 @@ public:
|
||||
static void GetEnvironmentVariables(Dictionary<String, String, HeapAllocation>& result);
|
||||
static bool GetEnvironmentVariable(const String& name, String& value);
|
||||
static bool SetEnvironmentVariable(const String& name, const String& value);
|
||||
#if !PLATFORM_SDL
|
||||
static int32 CreateProcess(CreateProcessSettings& settings);
|
||||
#if !PLATFORM_SDL
|
||||
static Window* CreateWindow(const CreateWindowSettings& settings);
|
||||
#endif
|
||||
static void* LoadLibrary(const Char* filename);
|
||||
|
||||
Reference in New Issue
Block a user