Skip to content

Commit 8ba7efb

Browse files
committed
Backends: Win32: fixed an issue where a viewport destroyed while clicking would hog mouse tracking and temporary lead to incorrect update of HoveredWindow. (#7971)
1 parent 44a7450 commit 8ba7efb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

backends/imgui_impl_win32.cpp

Lines changed: 12 additions & 1 deletion
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
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
26+
// 2024-09-16: [Docking] Inputs: fixed an issue where a viewport destroyed while clicking would hog mouse tracking and temporary lead to incorrect update of HoveredWindow. (#7971)
2627
// 2024-07-08: Inputs: Fixed ImGuiMod_Super being mapped to VK_APPS instead of VK_LWIN||VK_RWIN. (#7768)
2728
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
2829
// 2023-09-25: Inputs: Synthesize key-down event on key-up for VK_SNAPSHOT / ImGuiKey_PrintScreen as Windows doesn't emit it (same behavior as GLFW/SDL).
@@ -114,7 +115,7 @@ struct ImGui_ImplWin32_Data
114115
{
115116
HWND hWnd;
116117
HWND MouseHwnd;
117-
int MouseTrackedArea; // 0: not tracked, 1: client are, 2: non-client area
118+
int MouseTrackedArea; // 0: not tracked, 1: client area, 2: non-client area
118119
int MouseButtonsDown;
119120
INT64 Time;
120121
INT64 TicksPerSecond;
@@ -705,6 +706,16 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
705706
}
706707
return 0;
707708
}
709+
case WM_DESTROY:
710+
if (bd->MouseHwnd == hwnd && bd->MouseTrackedArea != 0)
711+
{
712+
TRACKMOUSEEVENT tme_cancel = { sizeof(tme_cancel), TME_CANCEL, hwnd, 0 };
713+
::TrackMouseEvent(&tme_cancel);
714+
bd->MouseHwnd = nullptr;
715+
bd->MouseTrackedArea = 0;
716+
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
717+
}
718+
return 0;
708719
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
709720
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
710721
case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK:

docs/CHANGELOG.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ Docking+Viewports Branch:
8282
over main viewport bounds isn't translated properly. (#7985)
8383
- Backends: Win32: fixed direct calls to platform_io.Platform_SetWindowPos()/Platform_SetWindowSize()
8484
on windows created by application (typically main viewport).
85+
- Backends: Win32: fixed an issue where a viewport destroyed while clicking would hog
86+
mouse tracking and temporary lead to incorrect update of HoveredWindow. (#7971)
8587
- Backends: SDL3: added support for viewport->ParentViewportId field to support parenting
8688
windows at OS level. (#7973) [@RT2code]
8789

0 commit comments

Comments
 (0)