I want to open a file from a GUI, using an ordinary file dialog. This is using Rend3 (3D graphics), egui (2D interface on top of 3D), winit (interface to OS window system), and rfd (Rust interface to native file dialogs). Targets are Linux, Win64, MacOS.
It basically works, but there are some problems.
File dialogs can be used in synchronous (modal, calling program stalled) or asynchronous (calling program continues to run.) Async mode, or sync from another thread, can apparently cause memory corruption on Microsoft Windows. (This is a "native file dialog", which means it's using some C++ Microsoft library). There are issues filed by others with both egui and rfd. So, until that's dealt with, synchronous (modal) mode is the way to go.
The trouble is, it's possible for the modal dialog to end up behind the main window. This tends to happen because the file dialog is slow to appear, since it has to read directories. Click anywhere while it's loading, and the file dialog ends up behind the main window.
For a full-screen program like a game, this is serious. The full-screen main window is dead, because the hidden modal dialog has control. Alt-tab won't work, because both windows belong to the same program. Control-alt-del will work, but that shouldn't be necessary.
So, how can I enforce window order within my own program, so that the main window is always behind the file dialog, even if the user clicks on the main window with the dialog up?
Is there something better than rfd, with cross-platform support?