#9542·imgui

ImGui::IsWindowAppearing detect window opening vs tabbing

Author: amuTBKTCreated Sep 11, 2026Updated Sep 15, 2026

Version/Branch of Dear ImGui:

Version 1.93.0, Branch: docking

Back-ends:

imgui_impl_win32.cpp + imgui_impl_dx11.cpp

Compiler, OS:

Windows 10 + MSVC 2026

Full config/build information:

Dear ImGui 1.93.0 WIP (19295)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1944
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:

Apologies for a bit of a lazy bug-report/question.

I was wondering if there is a way to detect if window is appearing from a closed state vs just becoming active (from inactive tab) ? I have mostly relied on ImGui::IsWindowAppearing for setting focus on widgets and doing heavy per window init work (like refreshing data for list views), but I am noticing when tabbing it triggers that logic too.

I can see that it makes sense (window is appearing), but is there a way to differentiate b/w opening vs getting activated?

I looked around a bit and found this issue which looks relevant (https://github.com/ocornut/imgui/issues/4177) but I am not sure if that answers my question. I can solve this issue by manual bookeeping but wanted to check if theres any better/existing solution.

Screenshots/Video:

Minimal, Complete and Verifiable Example code:

// you will have to dock this window

if (ImGui::Begin("BugRepro"))
{
    if (ImGui::IsWindowAppearing())
    {
        // set focus to first input text when window opens
        ImGui::SetKeyboardFocusHere();
    }

    static char buf1[32] = { 0 };
    ImGui::InputText("Text", buf1, sizeof(buf1));

    // add bloat....
    ImGui::Dummy(ImVec2(0, 400.f));

    static char buf2[32] = { 0 };
    ImGui::InputText("SomeOtherText", buf2, sizeof(buf2));
}
ImGui::End();