You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you start an application with already open platform ImGui windows, then these windows are opened on top of the main application window. As I understand, in ImGui::UpdatePlatformWindows() it tries hard to maintain initial focus on the main window using this:
if (g.FrameCount < 3)
viewport->Flags |= ImGuiViewportFlags_NoFocusOnAppearing;
So when these new windows are opened on top of the main window, the actual main window remains focused. At this point ImGui correctly treats external windows as being on top. But when you bring the main window to the top above those platform windows there's no event (since main window already has focus), so ImGui doesn't know that and still thinks that external windows are on top of it. And at this point if you're trying to interact with ImGui in main window, you end up interacting with the ImGui in platform windows below the main window. If you focus one of the platform windows and focus back on the main window then everything fixes itself.
Removing above code snippet fixes the issue.
Repro steps:
Start example_glfw_opengl3 (tested on macOS, but I get the same behavior on Windows with my app too)
Move the demo window outside the main window so it creates a new platform window. But leave it overlapping with the main window.
Restart the app, so it opens with demo window outside the main window from the start.
Optional: example_glfw_opengl3 already brings main window to the top, but for other apps you can bring it manually.
Move mouse above main window and see that it interacts with the demo window bellow it.
Focus demo window and then back to the main window.
See that this problem is gone now.
Video of above scenario after the example_glfw_opengl3 was just started:
Version: v1.89.9-docking
Branch: docking
Running example_glfw_opengl3 on macOS.
The text was updated successfully, but these errors were encountered:
if (g.FrameCount < 3)
viewport->Flags |= ImGuiViewportFlags_NoFocusOnAppearing;
Tangentially relates to #2304, if we had better control over imgui-windows focus restore, it would likely be easier to restore platform-focus appropriately instead of doing this.
If you start an application with already open platform ImGui windows, then these windows are opened on top of the main application window. As I understand, in
ImGui::UpdatePlatformWindows()
it tries hard to maintain initial focus on the main window using this:So when these new windows are opened on top of the main window, the actual main window remains focused. At this point ImGui correctly treats external windows as being on top. But when you bring the main window to the top above those platform windows there's no event (since main window already has focus), so ImGui doesn't know that and still thinks that external windows are on top of it. And at this point if you're trying to interact with ImGui in main window, you end up interacting with the ImGui in platform windows below the main window. If you focus one of the platform windows and focus back on the main window then everything fixes itself.
Removing above code snippet fixes the issue.
Repro steps:
Video of above scenario after the example_glfw_opengl3 was just started:
Version: v1.89.9-docking
Branch: docking
Running example_glfw_opengl3 on macOS.
The text was updated successfully, but these errors were encountered: