Skip to content
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

Fix modal disable/enable behavior on Win32 #106

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

theOtherMichael
Copy link

This PR fixes the modal behavior of native file dialogs on Win32. Previously, opening a native file dialog would leave the calling window enabled. This is not how NFD behaves on macOS, though I do not know how it behaves on Linux.

More importantly, this issue exposes folks with immediate-mode GUI libraries like Dear ImGui to crashes on Windows. If you use WM_SIZING messages or similar to redraw an immediate mode GUI, but an NFD is open because of a call from the GUI, then a user can break things by resizing the calling window with an NFD still open. Dear ImGui, at least, does not support recursive UI rendering.

This fix simply passes the calling window handle to fileOpenDialog->Show(), which it gets from GetActiveWindow(). If GetActiveWindow() can't get a handle, it returns NULL anyways, so this change should not negatively impact existing projects. If anyone prefers to avoid disabling the base window when opening an NFD, then I'd argue that should be an API change, because again, this is the default behavior for NFD on macOS.

I tested this with Clang and MSVC on Win32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant