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

update viewport flags from window flags every frame

Fixes WindowFlags_NoInputs only being taken in consideration when the viewport is intially created.
This commit is contained in:
cfillion 2024-03-11 20:49:27 -04:00
parent adcc3217c3
commit 64971a8866
No known key found for this signature in database
GPG key ID: A8EF86DBBF0445BA

View file

@ -14952,7 +14952,6 @@ static void ImGui::UpdateViewportsEndFrame()
g.Viewports[0]->ClearRequestFlags(); // Clear main viewport flags because UpdatePlatformWindows() won't do it and may not even be called g.Viewports[0]->ClearRequestFlags(); // Clear main viewport flags because UpdatePlatformWindows() won't do it and may not even be called
} }
// FIXME: We should ideally refactor the system to call this every frame (we currently don't)
ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const ImVec2& pos, const ImVec2& size, ImGuiViewportFlags flags) ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const ImVec2& pos, const ImVec2& size, ImGuiViewportFlags flags)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
@ -14969,7 +14968,12 @@ ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const
flags |= ImGuiViewportFlags_NoFocusOnAppearing; flags |= ImGuiViewportFlags_NoFocusOnAppearing;
} }
ImGuiViewportP* viewport = (ImGuiViewportP*)FindViewportByID(id); ImGuiViewportP* viewport;
if (window && window->Viewport && window->Viewport->ID == id)
viewport = window->Viewport;
else
viewport = (ImGuiViewportP*)FindViewportByID(id);
if (viewport) if (viewport)
{ {
// Always update for main viewport as we are already pulling correct platform pos/size (see #4900) // Always update for main viewport as we are already pulling correct platform pos/size (see #4900)
@ -15111,18 +15115,14 @@ static void ImGui::WindowSelectViewport(ImGuiWindow* window)
{ {
window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_None); window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_None);
} }
else if (g.MovingWindow && g.MovingWindow->RootWindowDockTree == window && IsMousePosValid()) else if (window->Viewport && window->Viewport->Window == window)
{
if (window->Viewport != NULL && window->Viewport->Window == window)
window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_None);
}
else
{ {
window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_None);
// Merge into host viewport? // Merge into host viewport?
// We cannot test window->ViewportOwned as it set lower in the function. // We cannot test window->ViewportOwned as it set lower in the function.
// Testing (g.ActiveId == 0 || g.ActiveIdAllowOverlap) to avoid merging during a short-term widget interaction. Main intent was to avoid during resize (see #4212) // Testing (g.ActiveId == 0 || g.ActiveIdAllowOverlap) to avoid merging during a short-term widget interaction. Main intent was to avoid during resize (see #4212)
bool try_to_merge_into_host_viewport = (window->Viewport && window == window->Viewport->Window && (g.ActiveId == 0 || g.ActiveIdAllowOverlap)); if (!g.MovingWindow || g.MovingWindow->RootWindowDockTree != window || !IsMousePosValid() || g.ActiveId == 0 || g.ActiveIdAllowOverlap)
if (try_to_merge_into_host_viewport)
UpdateTryMergeWindowIntoHostViewports(window); UpdateTryMergeWindowIntoHostViewports(window);
} }