mirror of
https://github.com/ocornut/imgui.git
synced 2026-10-29 07:54:40 +00:00
Viewports: 1-frame rogue OS window glitch with BeginPopupModal + AlwaysAutoResize + Pivot + NoAutoMerge #9568
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#9568
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Details:
When a parent window is forced into its own viewport using
ImGuiViewportFlags_NoAutoMerge(viaImGuiWindowClass), opening a Modal Popup withImGuiWindowFlags_AlwaysAutoResizeand centering it viaSetNextWindowPos(with a pivot) creates a 1-frame rogue OS window outside the parent boundaries.The root cause (Inheritance & Pivot calculation delay):
NoAutoMergeviewport flag from the parent'sImGuiWindowClass.0x0) due toAlwaysAutoResize. Thus,window->HiddenFramesCannotSkipItemsis set to 1.imgui.cppBegin(), the booleanwindow_pos_with_pivotevaluates tofalsebecause of the hidden frames condition.60, 60).NoAutoMergeflag, the Viewport system panics and creates a temporary standalone OS window (HWND) with a drop shadow for exactly 1 frame.Proposed Fix:
We can prevent this rogue viewport creation by honoring the target position (without the pivot) for the first measuring frame. This keeps the window safely within the host boundaries until the exact size/pivot is resolved.
In
imgui.cpp(insideBegin()):Screenshots/Video:
Before: https://github.com/user-attachments/assets/34df4fe8-fb19-4dc2-879d-03026c1950ed
(Attached screenshots from the Metrics/Debugger illustrate Viewport #3 being transiently created on the first frame due to the fallback positioning and later merged successfully)
After: https://github.com/user-attachments/assets/01c9b9e2-311b-4a93-a647-c1f853c2c4fb
Minimal, Complete and Verifiable Example code: