Make SDL3 file dialogs have parent window.

Somehow needed to avoid causing it to block on macOS.
This commit is contained in:
PJB3005
2025-07-19 18:45:14 +02:00
parent d5df765467
commit 1037fc735e
2 changed files with 5 additions and 0 deletions

View File

@@ -49,6 +49,7 @@ public static partial class SDL
public const string SDL_PROP_FILE_DIALOG_NFILTERS_NUMBER = "SDL.filedialog.nfilters";
public const string SDL_PROP_FILE_DIALOG_FILTERS_POINTER = "SDL.filedialog.filters";
public const string SDL_PROP_FILE_DIALOG_WINDOW_POINTER = "SDL.filedialog.window";
public static int SDL_VERSIONNUM_MAJOR(int version) => version / 1000000;
public static int SDL_VERSIONNUM_MINOR(int version) => version / 1000 % 1000;

View File

@@ -46,6 +46,10 @@ internal partial class Clyde
}
}
// NOTE: Giving a parent window is required to avoid the file dialog being blocking on macOS.
var mainWindow = (Sdl3WindowReg)_clyde._mainWindow!;
SDL.SDL_SetPointerProperty(props, SDL.SDL_PROP_FILE_DIALOG_WINDOW_POINTER, mainWindow.Sdl3Window);
var task = ShowFileDialogWithProperties(type, props);
SDL.SDL_DestroyProperties(props);