From c6fdc0708906b7d85aa2b11bea69e71bd29dfeab Mon Sep 17 00:00:00 2001 From: Hugh Sanderson Date: Wed, 2 Oct 2024 11:53:38 +0800 Subject: [PATCH] Set SDL3 window creation properties --- project/src/common/ExternalInterface.cpp | 9 +++++---- project/src/sdl2/SDL2Stage.cpp | 8 +++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/project/src/common/ExternalInterface.cpp b/project/src/common/ExternalInterface.cpp index ba59b22db..81543ee81 100644 --- a/project/src/common/ExternalInterface.cpp +++ b/project/src/common/ExternalInterface.cpp @@ -5894,6 +5894,7 @@ EMSCRIPTEN_KEEPALIVE int nme_file_upload_info( const char *event, double progres } #endif +inline const char *safeStr( const char *inPtr ) { return inPtr ? inPtr : ""; } bool nme_file_dialog_open(HxString inTitle, HxString inText, HxString inDefaultPath, HxString inTypes, value inCallback, int inFlags ) { if (gCurrentFileDialog) @@ -5902,10 +5903,10 @@ bool nme_file_dialog_open(HxString inTitle, HxString inText, HxString inDefaultP // TODO - mac #if (defined(HX_WINDOWS) && !defined(HX_WINRT)) || defined(HX_MACOS) gCurrentFileDialog = new FileDialogSpec(); - gCurrentFileDialog->title = inTitle.c_str(); - gCurrentFileDialog->text = inText.c_str(); - gCurrentFileDialog->defaultPath = inDefaultPath.c_str(); - gCurrentFileDialog->fileTypes = inTypes.c_str(); + gCurrentFileDialog->title = safeStr(inTitle.c_str()); + gCurrentFileDialog->text = safeStr(inText.c_str()); + gCurrentFileDialog->defaultPath = safeStr(inDefaultPath.c_str()); + gCurrentFileDialog->fileTypes = safeStr(inTypes.c_str()); gCurrentFileDialog->callback = new AutoGCRoot(inCallback); gCurrentFileDialog->flags = inFlags; diff --git a/project/src/sdl2/SDL2Stage.cpp b/project/src/sdl2/SDL2Stage.cpp index 0937154cf..3e37ba8c3 100644 --- a/project/src/sdl2/SDL2Stage.cpp +++ b/project/src/sdl2/SDL2Stage.cpp @@ -2482,7 +2482,13 @@ void CreateMainFrame(FrameCreationCallback inOnFrame, int inWidth, int inHeight, SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, targetY); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, setWidth); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, setHeight); - SDL_SetNumberProperty(props, "flags", requestWindowFlags); + + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN, resizable); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN, borderless); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN, fullscreen); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN, tryHighDpi); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_ALWAYS_ON_TOP_BOOLEAN, inFlags & wfAlwaysOnTop); + window = SDL_CreateWindowWithProperties(props); SDL_DestroyProperties(props); #else