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

Docking: ImGuiDockNodeFlags_KeepAliveOnly with DockSpaceOverViewport causes WindowOverViewport_<viewport> to received focus when hovered #8125

Closed
kcbanner opened this issue Nov 2, 2024 · 2 comments
Labels
bug docking focus test wanted Should add corresponding test to ImGuiTestSuite

Comments

@kcbanner
Copy link

kcbanner commented Nov 2, 2024

Version/Branch of Dear ImGui:

1.90.1 (docking)

Back-ends:

imgui_impl_glfw.cpp

Compiler, OS:

Windows 10 + zig cc

Full config/build information:

Dear ImGui 1.91.0 (19100)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201402
define: _WIN32
define: _WIN64
define: _MSC_VER=1933
define: _MSVC_LANG=201402
define: __clang_version__=19.1.0 (git@github.com:kcbanner/zig-bootstrap.git ea3fd1d367632c2cd23b51e074dd68f58de266bb)
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: NULL
io.ConfigFlags: 0x000000A3
 NavEnableKeyboard
 NavEnableGamepad
 NoMouseCursorChange
 DockingEnable
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000000E
 HasMouseCursors
 HasSetMousePos
 RendererHasVtxOffset
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 2560.00,1440.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: 2.00
style.FrameBorderSize: 1.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Details:

When specifying ImGuiDockNodeFlags_KeepAliveOnly to DockSpaceOverViewport, the WindowOverViewport_<viewport> window receives focus when hovered.

When ImGuiDockNodeFlags_KeepAliveOnly is not specified, the hovered window is NULL as expected (when over the central node).

My use case involves toggling the dock on and off (to hide editor UI). My game only receives input events if there is no imgui window focused, and so the WindowOverViewport_<viewport> window getting focus is an issue.

Applying this diff resolves the issue:

    if (dockspace_flags & ImGuiDockNodeFlags_PassthruCentralNode)
        host_window_flags |= ImGuiWindowFlags_NoBackground;
+   if (dockspace_flags & ImGuiDockNodeFlags_KeepAliveOnly)
+        host_window_flags |= ImGuiWindowFlags_NoMouseInputs;

Screenshots/Video:

imgui_issue.mp4

Minimal, Complete and Verifiable Example code:

Add the following code to one of the examples:

ImGui::DockSpaceOverViewport(0, ImGui::GetMainViewport(), ImGuiDockNodeFlags_PassthruCentralNode | ImGuiDockNodeFlags_KeepAliveOnly);

Open the Imgui Metrics/Debugger window and expand the Internal State tab. Observe when hovering the empty space in the window, that the WindowOverViewport_11111111 window has focus.

@ocornut ocornut added bug focus docking test wanted Should add corresponding test to ImGuiTestSuite labels Nov 3, 2024
@ocornut
Copy link
Owner

ocornut commented Nov 4, 2024

Hello Casey, thanks for your report. Your analysis is correct and the suggested bug fix seems correct to me.
I've pushed this as a63220e (I couldn't easily attribute the commit to you as you don't have a commit in the repo, but used your handle in the changelog). Also added a note that in this case we could probably skip submitting the window.
Thanks!

@kcbanner
Copy link
Author

kcbanner commented Nov 4, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug docking focus test wanted Should add corresponding test to ImGuiTestSuite
Projects
None yet
Development

No branches or pull requests

2 participants