Backends: Win32: Viewports: fixed an issue when closing a window from the OS close button (with io.ConfigViewportsNoDecoration=false) while user code is discarding the 'bool *p_open=false output' from Begin()

This commit is contained in:
ocornut
2025-03-26 22:59:14 +01:00
parent 790f2b9a7a
commit 0c079e453b
2 changed files with 12 additions and 2 deletions

View File

@@ -23,6 +23,7 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2025-03-26: [Docking] Viewports: fixed an issue when closing a window from the OS close button (with io.ConfigViewportsNoDecoration = false) while user code was discarding the 'bool* p_open = false' output from Begin(). Because we allowed the Win32 window to close early, Windows destroyed it and our imgui window became not visible even though user code was still submitting it.
// 2025-03-10: When dealing with OEM keys, use scancodes instead of translated keycodes to choose ImGuiKey values. (#7136, #7201, #7206, #7306, #7670, #7672, #8468)
// 2025-02-21: [Docking] WM_SETTINGCHANGE's SPI_SETWORKAREA message also triggers a refresh of monitor list. (#8415)
// 2025-02-18: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursor support.
@@ -1357,14 +1358,14 @@ static LRESULT CALLBACK ImGui_ImplWin32_WndProcHandler_PlatformWindow(HWND hWnd,
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(ctx);
LRESULT result = 0;
if (ImGui_ImplWin32_WndProcHandlerEx(hWnd, msg, wParam, lParam, io))
result = true;
result = 1;
else if (ImGuiViewport* viewport = ImGui_ImplWin32_FindViewportByPlatformHandle(platform_io, hWnd))
{
switch (msg)
{
case WM_CLOSE:
viewport->PlatformRequestClose = true;
break;
return 0; // 0 = Operating system will ignore the message and not destroy the window. We close ourselves.
case WM_MOVE:
viewport->PlatformRequestMove = true;
break;