Torn-off (secondary) multi-viewport windows now stay above the main window, but not above
other apps. While the app is active they are independent windows at NSFloatingWindowLevel
(above the main window, but not children — so dragging the main window doesn't drag them).
While the app is inactive they become children of the main window at the normal level:
children are occluded together with the app by other apps, and the window server keeps a
child above its parent at all times, so clicking the main window to reactivate can't flash
it over them for a frame. Relative order is preserved across the transitions, and the main
window is brought forward on activation so the whole app comes up as a unit.
Replaces the previous transient parenting (attach-on-create / detach-on-mouse-release in
ImGui_ImplOSX_UpdateWindow, which is removed). ImGui_ImplOSX_RestackSecondaryWindows is
driven from the app activate/deactivate observers; DestroyWindow now detaches a parented
window before hiding it.
Examples: Metal4: resume rendering on app activation (idle-throttle fix)
Cmd-Tab / clicking to reactivate the app doesn't produce a local input event, so the idle
render throttle left the window on the slow heartbeat for up to ~1s after switching back,
which looked like a lag. Bump the render counter on NSApplicationDidBecomeActive so the
window redraws immediately on activation while keeping the idle CPU savings.
Rework the Metal 4 backend and example for correct, glitch-free multi-viewport
rendering on macOS, and convert example_apple_metal4 off MTKView.
Backend (imgui_impl_metal4.mm):
- Per-window argument tables so overlapping per-window GPU work within a frame can't
corrupt each other's bindings (multi-viewport flicker).
- Hold per-slot vertex/index buffers until their frame completes, so a second viewport
rendered later in the same frame can't overwrite a buffer still in flight (blink).
- Make hand-built render-pass drawables resident, and evict stale (resized-away)
drawables from the residency set so it can't grow without bound during a live resize.
- Present secondary viewports in-transaction on the frame they were resized so content
stays glued to the new size (no stutter).
Example (example_apple_metal4/main.mm):
- Replace MTKView with a custom NSView/UIView + CAMetalLayer driven by a display link.
- Proper frames-in-flight: per-slot command allocators, rotating slots, and a semaphore
gate released on GPU completion via an MTLSharedEvent listener.
- Glitch-free main-window resize: present in-transaction during a live resize, driven by
AppKit (the display link steps aside) so the transaction commits and drawables aren't
starved; async present otherwise (avoids a ~1s nextDrawable stall / freeze).
- Idle CPU throttling: only redraw on input/activity plus a slow heartbeat, so the main
thread sleeps when nothing changes.