1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-23 02:04:22 +00:00

Viewports: update LastFocusedStampCount earlier. Fix (#8948, #9172, #9131, #9128) but probably have other side effects too.

Amend f1ae07e532. Initial value of LastFocusedStampCount was set at the time of platform ShowWindow which is too late for first-frame UpdateTryMergeWindowIntoHostViewport() evaluation.
This commit is contained in:
ocornut 2026-01-16 16:26:19 +01:00
parent 7038e71ae2
commit 9eebd37b59
2 changed files with 10 additions and 7 deletions

View file

@ -210,9 +210,13 @@ Other Changes:
Docking+Viewports Branch:
- Fixed an assert in background dimming code, which could trigger after using
gamepad/keyboard to move a window to another viewport. (#9053) [@lut0pia, @ocornut]
- Fixed implicit/fallback "Debug" window from staying visible if once docked. (#9151)
- Viewports:
- Fixed a regression in 1.92.4 which could cause combos/popups window from
appearing under their parent viewport if their geometry overlapped the main
viewport. (#8948, #9172, #9131, #9128)
- Fixed an assert in background dimming code, which could trigger after using
gamepad/keyboard to move a window to another viewport. (#9053) [@lut0pia, @ocornut]
- Backends:
- GLFW: dynamically load X11 functions to avoid -lx11 linking requirement introduced
in 1.92.3. (#9116, #9109) [@ramenguy99]

View file

@ -16989,6 +16989,10 @@ ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const
g.ViewportCreatedCount++;
IMGUI_DEBUG_LOG_VIEWPORT("[viewport] Add Viewport %08X '%s'\n", id, window ? window->Name : "<NULL>");
// We assume the window becomes front-most (even when ImGuiViewportFlags_NoFocusOnAppearing is used).
// This is useful for our platform z-order heuristic when io.MouseHoveredViewport is not available.
viewport->LastFocusedStampCount = ++g.ViewportFocusedStampCount;
// We normally setup for all viewports in NewFrame() but here need to handle the mid-frame creation of a new viewport.
// We need to extend the fullscreen clip rect so the OverlayDrawList clip is correct for that the first frame
g.DrawListSharedData.ClipRectFullscreen.x = ImMin(g.DrawListSharedData.ClipRectFullscreen.x, viewport->Pos.x);
@ -17363,11 +17367,6 @@ void ImGui::UpdatePlatformWindows()
// Show window
g.PlatformIO.Platform_ShowWindow(viewport);
// Even without focus, we assume the window becomes front-most.
// This is useful for our platform z-order heuristic when io.MouseHoveredViewport is not available.
if (viewport->LastFocusedStampCount != g.ViewportFocusedStampCount)
viewport->LastFocusedStampCount = ++g.ViewportFocusedStampCount;
}
// Clear request flags