Skip to content

Multi-Viewport: Maximizing/Restoring primary viewport causes other viewports to move (mostly) out of screen #9384

@Bizzarrus

Description

@Bizzarrus

Version/Branch of Dear ImGui:

Version 1.92.8 WIP, Branch:docking

Back-ends:

imgui_impl_dx12.cpp + imgui_impl_win32.cpp

Compiler, OS:

Windows 11 + MSVC 2026

Full config/build information:

// (Copy from the next line. Keep the ``` markers for formatting.)

Dear ImGui 1.92.8 WIP (19275)
--------------------------------
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_dx12
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:

My Issue:

When the primary viewport gets maximized and then restored (aka, turned back into a non-maximized window), all other windows that were inside the primary viewport when it was maximized, but do not fit into it when not maximized, are moved towards the right. This shift becomes larger if the primary viewport has been moved to the right before maximizing it (effectively, the other windows are moved by the delta between the maximized viewport position and non-maximized viewport position of the maximized viewport). See the attached video for a visual demonstration (it's much easier to show than to explain in words).
The problem is much more noticable on my 1440p ultra-wide monitor than on my 1080p 16:9 monitor, but it can be observed on both.

In the worst case (when moving the primary window to the right edge of the screen before maximizing it), this can cause the other windows to move almost completely off screen. There seems to be some safe-guard that ensures to have at least a small edge of the window always stays on screen, so they aren't completely lost, but especially on a ultra-wide monitor this small edge can be easily overlooked, even more so as one would expect the window position to stay where it was.

My expectation is, that all non-docked windows stay at the same position on screen when I maximize or restore the primary viewport (or, at the very least, don't move off screen), as this is also the behaviour when I resize the primary viewport to become smaller.

I could track down, that this is caused by the logic in ImGui::TranslateWindowsInViewport. If I simply remove the check in this function related to test_still_fit_rect (so the if condition becomes if (translate_all_windows || (window->Viewport == viewport && old_size == new_size))), it fixes the maximize/restore issue while maintaining correct behaviour when moving or resizing the window manually - though I don't know if I might be overlooking some edge case that required this test_still_fit_rect check (I'm obviously not very familiar with the inner workings of the ImGui code and just quickly tried some simple test cases).

Screenshots/Video:

2026-04-28.22-50-14.mp4

Minimal, Complete and Verifiable Example code:

Just run the Win32 (DirectX 12) example, move the primary window, then maximize and restore repeatedly. No code modification needed.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions