Skip to content

Commit 0c079e4

Browse files
committed
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()
1 parent 790f2b9 commit 0c079e4

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

backends/imgui_impl_win32.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
// CHANGELOG
2424
// (minor and older changes stripped away, please see git history for details)
2525
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
26+
// 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.
2627
// 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)
2728
// 2025-02-21: [Docking] WM_SETTINGCHANGE's SPI_SETWORKAREA message also triggers a refresh of monitor list. (#8415)
2829
// 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,
13571358
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(ctx);
13581359
LRESULT result = 0;
13591360
if (ImGui_ImplWin32_WndProcHandlerEx(hWnd, msg, wParam, lParam, io))
1360-
result = true;
1361+
result = 1;
13611362
else if (ImGuiViewport* viewport = ImGui_ImplWin32_FindViewportByPlatformHandle(platform_io, hWnd))
13621363
{
13631364
switch (msg)
13641365
{
13651366
case WM_CLOSE:
13661367
viewport->PlatformRequestClose = true;
1367-
break;
1368+
return 0; // 0 = Operating system will ignore the message and not destroy the window. We close ourselves.
13681369
case WM_MOVE:
13691370
viewport->PlatformRequestMove = true;
13701371
break;

docs/CHANGELOG.txt

+9
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ Other changes:
4848
- Style, InputText: added ImGuiCol_InputTextCursor to configure color of
4949
the InputText cursor/caret. (#7031)
5050

51+
Docking+Viewports Branch:
52+
53+
- Backends: Win32: Viewports: fixed an issue when closing a window from
54+
the OS close button (with io.ConfigViewportsNoDecoration=false) while
55+
user code is discarding the 'bool *p_open=false output' from Begin().
56+
Because we allowed the Win32 window to close early, Windows destroyed
57+
it and our imgui window became not visible even though user code was
58+
still submitting it.
59+
5160

5261
-----------------------------------------------------------------------
5362
VERSION 1.91.9b (Released 2025-03-17)

0 commit comments

Comments
 (0)