-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Obtaining native window handle and OS-level modal windows #479
Comments
Hi!
Currently, yes. There are various in-progress but stale attempts such as #168, however due to focus being elsewhere I didn't have time to make any progress there. What people end up doing for multi-window apps instead is sidestepping the Hmm, I guess your real question is how to open a native file open/save dialog, right? That's definitely something that would be nice to have. Getting native window handles in SDL/GLFW could be implemented in the |
SDL does not implement modal windows at all. At most you can obtain native window handle, which is then used with system-specific APIs. Now, about OS-specific APIs:
It depends, each OS/GUI-toolkit will have different requirements. IMO there should be at least 2 classes: 1 that represents OS-specific application and 1 that represents OS-specific Window. Because on many OSes certain resources are tied to each window and other certain ones to the application as a process. Modal functionality would be in window class. Splitting resource lifetime per application and window class is the cleanest solution I can think of. In the case of modals - I have used tinyfiledialogs project which "magically" has no dependencies and implements typical blocking modal on each platform, without even requiring to link anything (except on Windows). I guess it calls shell utilities or does Last things: to help you I can:
|
Yeah I don't intentionally support XP either anyway, so this should be fine.
Yep, there's Utility::Unicode::widen(), which wraps the Windows APIs (and thus is Windows-specific because no other platform really needs this anyway) and which is used by all Magnum APIs that deal with Unicode on Windows.
I'm aware :) I'd go with KDE and GTK support. With KDE it'd be I assme rather easy, unfortunately as far as I know with GTK there's no way to unload the library so once it gets loaded it'll be in memory forever. I think because of this SDL had to use some sort of IPC to avoid loading GTK in SDL_ShowMessageBox (can't find the source tho).
Yeah that would be great. But please note that I'm still not able to invest any time into this myself in the near future. |
Then tinyfiledialogs should be the prefferred choice. I have searched for many similar solutions (found also the one you linked) and this one has least dependencies, is completely troubleless, no linking required (except on Windows to some system DLLs), no global state init required, fully C and C++ compliant, single file implementation ... basically ideal.
Ahh, I remember similar nightmare trying to RAII-ize fontconfig library. It has one of the worst C library designs I have seen when it comes to initialization:
A single project can deal with it. But when your project has 2 dependencies and both of them try to correctly use fontconfig, it is a distaster. The only way to "fix" it is to force a leak and make sure fontconfig is never attempted to be cleaned up twice. I just can't get why it is so complex, why there is no init check and why extra init/cleanup usage is inconsistent. Many libraries have just an integer reference counter or simply create 2 independent instances.
Fine, I already see you must be busy by looking at the reponse times on this issue. I'm currently more involved in using ImGui than Magnum. Xeverous/filter_spirit@3e06e81 This commit is actually bigger than I thought (it also adds stuff to my project that immediately uses it) so I think a more comfortable way would be to state that everything is in this path: https://github.com/Xeverous/filter_spirit/tree/3e06e81a40c9655fddbb8d1a9cefbd6fb81ed5e4/external/tiny_file_dialogs - the whole thing is just a single CMake file + subproject link (link is not clickable because tinyfiledialogs project is not located on github). |
I'm creating an application that (so far) is planned to be run on desktop (Linux and Windows) and the browser (via Emscripten). I need to ask the user to open a file - I'm not sure yet how such thing will be done in Emscripten build, but for Windows (or any other desktop OS) I need the native window handle.
There is
SDL_Window* Magnum::Platform::Sdl2Application::window()
and https://stackoverflow.com/questions/24117983/get-window-handle-of-sdl-2-application guides to this snippet:... so obtaining native window handle (at least on SDL-based applcation) is not a problem.
The questions are:
IFileSaveDialog::Show(hwnd)
), if the modal window is given the pointer to the parent window, the parent window is blocked and event handling stops there untill modal is closed because the modal temporarily takes ownership of the OS event loop - I had problems with other libraries where doing such things (spawning modal windows) inside event handling function could cause the application to stop, loop infinitely or break in some other way (any sort of unfixable event loop corruption). Usually I had to just delay spawning the modal to a different application function, outside event callbacks.Platform::*Application
can only create 1 window?The text was updated successfully, but these errors were encountered: