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

HoveredWindow state is no longer cleared after closing a secondary viewport #7971

Closed
tombuskens opened this issue Sep 10, 2024 · 2 comments
Closed

Comments

@tombuskens
Copy link

Version/Branch of Dear ImGui:

version 1.91.0 (19100), docking branch

Back-ends:

imgui_impl_win32.cpp + imgui_impl_dx12.cpp

Compiler, OS:

Windows 10 + MSVC 14.39.33218

Full config/build information:

Dear ImGui 1.91.0 (19100)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=202002
define: _WIN32
define: _WIN64
define: _MSC_VER=1939
define: _MSVC_LANG=202002
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_win32
io.BackendRendererName: imgui_impl_dx12
io.ConfigFlags: 0x00000481
 NavEnableKeyboard
 DockingEnable
 ViewportsEnable
io.ConfigViewportsNoAutoMerge
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigWindowsMoveFromTitleBarOnly
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C0E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------
io.Fonts: 39 fonts, Flags: 0x00000000, TexSize: 1024,1024
io.DisplaySize: 784.00,561.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Details:

In the docking branch, after closing a modal dialog, the hovered window state is no longer cleared when moving the mouse from within the app to outside the app.
The expected behavior would be that the hovered window state is cleared.

See video for steps to reproduce, .e.g.

  • Open a modal dialog
  • Close it
  • Hover over a window (HoveredWindow is set correctly)
  • Move from the window to a location outside of the application (HoveredWindow is incorrectly still set)

I noticed normally, when moving the mouse outside the application generates both a MouseViewport (0x00000000) and a MousePos(-FLT_MAX, -FLT_MAX). After opening and closing the modal, only a MouseViewport (0x00000000) is generated when moving outside the application.

As a workaround I'm currently calling ImGui::GetIO().AddMousePosEvent(-FLT_MIN, -FLT_MIN); after closing a modal dialog.

Screenshots/Video:

hovered_window.mp4

Minimal, Complete and Verifiable Example code:

Unmodified demo window.

@ocornut ocornut changed the title HoveredWindow state is no longer cleared after closing a modal HoveredWindow state is no longer cleared after closing a secondary viewport Sep 16, 2024
ocornut added a commit that referenced this issue Sep 16, 2024
…king would hog mouse tracking and temporary lead to incorrect update of HoveredWindow. (#7971)
@ocornut
Copy link
Owner

ocornut commented Sep 16, 2024

Thank you for reporting!
I investigated it and understood it wasn't specifically linked to modal.
Rather, the issue was that if a window disappear while being tracked, it can leave a tracking request and mess with mouse updates for other windows.
I have pushed a fix 8ba7efb
Although this technically only affects multi-viewports I have also merged the fix in the main branch.

@ocornut ocornut closed this as completed Sep 16, 2024
ocornut added a commit that referenced this issue Sep 16, 2024
…king would hog mouse tracking and temporary lead to incorrect update of HoveredWindow. (#7971)

# Conflicts:
#	backends/imgui_impl_win32.cpp
#	docs/CHANGELOG.txt
@tombuskens
Copy link
Author

Thanks for the quick fix!

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

No branches or pull requests

2 participants