imgui icon indicating copy to clipboard operation
imgui copied to clipboard

Nested menu closes when tooltip goes outside window (1.91.6-docking)

Open briaguya0 opened this issue 1 year ago • 5 comments

Version/Branch of Dear ImGui:

Version 1.91.6, Branch: docking

Back-ends:

imgui_impl_sdl2.cpp + imgui_impl_opengl3.cpp

Compiler, OS:

debian sid, gcc/g++ 14.2.0

Full config/build information:

Dear ImGui 1.91.7 WIP (19162)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201103
define: __linux__
define: __GNUC__=14
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_sdl2
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000483
 NavEnableKeyboard
 NavEnableGamepad
 DockingEnable
 ViewportsEnable
io.ConfigViewportsNoDecoration
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C0E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,128
io.DisplaySize: 1280.00,720.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:

after hovering over an item in a nested menu that has a tooltip that goes outside the main window, moving the cursor anywhere else closes the nested menu

my repro example is based on the latest commit on the docking branch (as of writing), but i have encountered this issue in 1.91.6-docking and 1.90.6-docking (and a few earlier docking versions but i don't remember which)

i also think this has been reproduced outside of sdl/opengl with dxgi/dx11 but i can't confirm that

this is not an issue on the non-docking branch, the tooltip is just cut off in that case

Screenshots/Video:

https://github.com/user-attachments/assets/d7e53fa4-f7a6-4ce1-bab7-eb88bf244899

Minimal, Complete and Verifiable Example code:

diff --git a/imgui_demo.cpp b/imgui_demo.cpp
index ed205011..cf760d9b 100644
--- a/imgui_demo.cpp
+++ b/imgui_demo.cpp
@@ -8338,6 +8338,12 @@ static void ShowExampleMenuFile()
     if (ImGui::MenuItem("Open", "Ctrl+O")) {}
     if (ImGui::BeginMenu("Open Recent"))
     {
+        // BEGIN MENU CLOSE ISSUE
+        ImGui::MenuItem("HOVER OVER ME");
+        if (ImGui::IsItemHovered()) {
+            ImGui::SetTooltip("this is a really long tooltip that will overflow and go outside of the window space and hopefully reproduce the issue i was seeing before");
+        }
+        // END MENU CLOSE ISSUE
         ImGui::MenuItem("fish_hat.c");
         ImGui::MenuItem("fish_hat.inl");
         ImGui::MenuItem("fish_hat.h");

briaguya0 avatar Dec 20 '24 01:12 briaguya0

What’s your SDL version? What’s your window manager? Do you have a feature enabled to focus windows on hover?

ocornut avatar Dec 20 '24 08:12 ocornut

What’s your SDL version?

2.30.10 (from debian sid repos)

libsdl2-2.0-0/unstable,now 2.30.10+dfsg-1 amd64 [installed,automatic]
  Simple DirectMedia Layer

libsdl2-dev/unstable,now 2.30.10+dfsg-1 amd64 [installed]
  Simple DirectMedia Layer development files

What’s your window manager?

GNOME Wayland

Do you have a feature enabled to focus windows on hover?

I don't think so, unless it is a default I'm not aware of.

I also want to emphasize that this is not a Linux/Wayland/GNOME specific issue, I know @Archez has encountered this on macOS and @Malkierian has encountered it on Windows

briaguya0 avatar Dec 20 '24 19:12 briaguya0

FWIW, I cannot reproduce this on Windows. Do they see this issue with your specific repro?

PathogenDavid avatar Dec 20 '24 23:12 PathogenDavid

I used to be able to reproduce on Windows, but I no longer can, on DX11 or OGL.

Malkierian avatar Dec 21 '24 05:12 Malkierian

I have a similar issue with SDL2 + OpenGL3 on Linux. #7950 My same app runs in Windows DX11 and it has no issues there.

I also noticed that for that single frame where the popup opens, keymods (holding ctrl) is seen as released for that frame. It's as if ImGui loses focus for an instant when the viewport is created. Probably related to how the SDL window viewports are opened, or also likely another bug in SDL2.

I'm not using Wayland either, plain X11 with xfce4.

lailoken avatar Apr 01 '25 16:04 lailoken