Dragging window flickers when using SetNextWindowDockID #9544

Closed
opened 2026-09-15 02:42:21 +00:00 by amuTBKT · 2 comments
amuTBKT commented 2026-09-15 02:42:21 +00:00 (Migrated from github.com)

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 (19297)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1951
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:

Dragging docked window flickers for a frame when using ImGui::SetNextWindowDockID(dockId, ImGuiCond_Always)
If there's only one window the background flickers, if there are multiple the window ordering changes.

I don't have much to say here, maybe we should set a flag on the window inside ImGui::SetWindowDock which can be later used inside ImGui::TabItemEx for can_undock check (disable undocking if dock id was set this frame)?

The flicker comes from the fact that we are undocking the window for a frame which updates ImGuiDockNode::VisibleWindow member (doesn't match our window so window->DockTabIsVisible resets). From there its just a cascade of things ending up with window->HiddenFramesCannotSkipItems getting set causing it to hide for a frame around this code. That code is probably not the issue here, we should just not be allowing undocking requests if the window has requested specific DockingID

Screenshots/Video:

https://github.com/user-attachments/assets/6c799c7c-6e4f-41b6-9229-eb0402374e67

Minimal, Complete and Verifiable Example code:

auto dockId = ImGui::DockSpaceOverViewport();
ImGui::SetNextWindowDockID(dockId, ImGuiCond_Always);
ImGui::Begin("BugRepro");
ImGui::Text("Some text...");
ImGui::End();
### 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: ```cpp Dear ImGui 1.93.0 WIP (19297) -------------------------------- sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20 define: __cplusplus=199711 define: _WIN32 define: _WIN64 define: _MSC_VER=1951 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: Dragging docked window flickers for a frame when using `ImGui::SetNextWindowDockID(dockId, ImGuiCond_Always)` If there's only one window the background flickers, if there are multiple the window ordering changes. I don't have much to say here, maybe we should set a flag on the window inside `ImGui::SetWindowDock` which can be later used inside `ImGui::TabItemEx` for `can_undock` check (disable undocking if dock id was set this frame)? The flicker comes from the fact that we are undocking the window for a frame which updates `ImGuiDockNode::VisibleWindow` member (doesn't match our window so `window->DockTabIsVisible` resets). From there its just a cascade of things ending up with `window->HiddenFramesCannotSkipItems` getting set causing it to hide for a frame around this [code](https://github.com/ocornut/imgui/blob/367b2c24f399988ddafc0bb4628da0106bcc09be/imgui.cpp#L8811-L8853). **That code is probably not the issue here**, we should just not be allowing undocking requests if the window has requested specific DockingID ### Screenshots/Video: https://github.com/user-attachments/assets/6c799c7c-6e4f-41b6-9229-eb0402374e67 ### Minimal, Complete and Verifiable Example code: ```cpp auto dockId = ImGui::DockSpaceOverViewport(); ImGui::SetNextWindowDockID(dockId, ImGuiCond_Always); ImGui::Begin("BugRepro"); ImGui::Text("Some text..."); ImGui::End(); ```
GamingMinds-DanielC commented 2026-09-15 09:48:16 +00:00 (Migrated from github.com)

Technically, setting the dock id to the current dock id is a no op with extra steps. Even though you do it every frame (which looks more like a bad hack), ImGui can't know that you will do it again next frame, it would have to guess your intentions. To make your intentions clear, you could set up the dock node with ImGuiDockNodeFlags_NoUndocking.

Technically, setting the dock id to the current dock id is a no op with extra steps. Even though you do it every frame (which looks more like a bad hack), ImGui can't know that you will do it again next frame, it would have to guess your intentions. To make your intentions clear, you could set up the dock node with `ImGuiDockNodeFlags_NoUndocking`.
amuTBKT commented 2026-09-15 10:46:00 +00:00 (Migrated from github.com)

The minimal example looks hacky but I am sure we can have real applications using a similar pattern to keep windows pinned to a dockspsace?

Image
  • Docking area marked in green (full viewport)
  • Red window needs to stay pinned to the viewport (cannot allow undocking it). This window uses SetNextWindowDockID()
  • Blue and Orange windows are free to rearrange/close.
  • Its ok to dock these windows on top of the Red window, I just don't want the Red window to move!
  • ImGuiDockNodeFlags_NoUndocking will probably pin all windows.

If theres a better solution I would be interested to learn about it.

EDIT: ImGuiWindowFlags_NoMove seems to work too, I can update my code to use that. Thanks for pointing it out :)

The minimal example looks hacky but I am sure we can have real applications using a similar pattern to keep windows pinned to a dockspsace? <img width="383" height="299" alt="Image" src="https://github.com/user-attachments/assets/c7322fc3-d70e-4aec-a648-0ca4b259a9c9" /> - Docking area marked in green (full viewport) - Red window needs to stay pinned to the viewport (cannot allow undocking it). This window uses `SetNextWindowDockID()` - Blue and Orange windows are free to rearrange/close. - Its ok to dock these windows on top of the Red window, I just don't want the Red window to move! - ImGuiDockNodeFlags_NoUndocking will probably pin all windows. If theres a better solution I would be interested to learn about it. **EDIT:** `ImGuiWindowFlags_NoMove` seems to work too, I can update my code to use that. Thanks for pointing it out :)
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#9544
No description provided.