Skip to content

SetNextWindowSize and popup overlap issues #9131

@amuTBKT

Description

@amuTBKT

Version/Branch of Dear ImGui:

Version 1.92.6, Branch: docking

Back-ends:

imgui_impl_dx11.cpp + imgui_impl_win32.cpp

Compiler, OS:

Windows 10 + MSVC 2026

Full config/build information:

Dear ImGui 1.92.6 WIP (19255)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1950
define: _MSVC_LANG=201402
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
IM_ASSERT: runs expression: OK. expand size: OK
--------------------------------
io.BackendPlatformName: imgui_impl_win32
io.BackendRendererName: imgui_impl_dx11
io.ConfigFlags: 0x00000483
 NavEnableKeyboard
 NavEnableGamepad
 DockingEnable
 ViewportsEnable
io.ConfigDpiScaleFonts
io.ConfigDpiScaleViewports
io.ConfigViewportsNoDecoration
io.ConfigViewportsNoDefaultParent
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00003C1E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 HasParentViewport
 RendererHasVtxOffset
 RendererHasTextures
 RendererHasViewports
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,128
io.Fonts->FontLoaderName: stb_truetype
io.DisplaySize: 1264.00,761.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:

Hello, I am currently running in to an issue when trying to create a popup of given size.

Describing the issue is a bit difficult so please refer to the video.
If popup is created from a viewport window and the height of the popup is greater than the available height of the parent window it starts submitting draw commands to the main viewport (the Win32 window for popup is never created), given the popup window is completely inside the main viewport window (as shown in the video).

This seems to only happen when using ImGui::SetNextWindowSize before calling ImGui::BeginPopup.
NOTE: If popup size is not specified and it happens to be larger than the parent window it works fine, just calling that function seems to cause the issue.

I couldn't find a reliable source on how best to resize popups so using the same setup used for normal windows.
#676 was probably the closest issue I could find (which recommends the same thing).

Screenshots/Video:

bug_repro.mp4

Minimal, Complete and Verifiable Example code:

if (ImGui::Begin("BugRepro"))
{
    ImGui::SetNextWindowSize(ImVec2(0.f, 256.f), ImGuiCond_Always);         // this causes the issue
    if (ImGui::BeginPopup("MyPopup"))
    {
        // make popup bigger for easier repro
        ImGui::Text("Some text.........");
        ImGui::Text("Some text.........");
        ImGui::Text("Some text.........");
        ImGui::Text("Some text.........");
        ImGui::Text("Some text.........");
        ImGui::Text("Some text.........");
        ImGui::Text("Some text.........");

        ImGui::EndPopup();
    }
    // position button for easier repro
    ImGui::Dummy(ImVec2(128.f, 128.f)); ImGui::SameLine();
    if (ImGui::Button("Open Popup"))
    {
        ImGui::OpenPopup("MyPopup");
    }
}
ImGui::End();

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions