mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 22:26:34 +00:00
Viewports: made standalone modals appear in taskbar + new window perform z-check before merging in main host viewport. (#3511, #1542)
This should fix a good amount of "lost modal" problems, however it is still possible to loose a modal in a host viewport if secondary viewports are configured as children above the host.
This commit is contained in:
parent
b2a91dc390
commit
cecf6b4209
16
imgui.cpp
16
imgui.cpp
@ -6227,10 +6227,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
// Update common viewport flags
|
||||
const ImGuiViewportFlags viewport_flags_to_clear = ImGuiViewportFlags_TopMost | ImGuiViewportFlags_NoTaskBarIcon | ImGuiViewportFlags_NoDecoration | ImGuiViewportFlags_NoRendererClear;
|
||||
ImGuiViewportFlags viewport_flags = window->Viewport->Flags & ~viewport_flags_to_clear;
|
||||
const bool is_short_lived_floating_window = (flags & (ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup)) != 0;
|
||||
const bool is_modal = (flags & ImGuiWindowFlags_Modal) != 0;
|
||||
const bool is_short_lived_floating_window = (flags & (ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup)) != 0 && !is_modal;
|
||||
if (flags & ImGuiWindowFlags_Tooltip)
|
||||
viewport_flags |= ImGuiViewportFlags_TopMost;
|
||||
if (g.IO.ConfigViewportsNoTaskBarIcon || is_short_lived_floating_window)
|
||||
//if (flags & ImGuiWindowFlags_Modal)
|
||||
// viewport_flags |= ImGuiViewportFlags_TopMost; // Not correct because other popups can be stack above a modal?
|
||||
if ((g.IO.ConfigViewportsNoTaskBarIcon || is_short_lived_floating_window) && !is_modal)
|
||||
viewport_flags |= ImGuiViewportFlags_NoTaskBarIcon;
|
||||
if (g.IO.ConfigViewportsNoDecoration || is_short_lived_floating_window)
|
||||
viewport_flags |= ImGuiViewportFlags_NoDecoration;
|
||||
@ -6239,7 +6242,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
// won't steal the OS focus away from their parent window (which may be reflected in OS the title bar decoration).
|
||||
// Setting _NoFocusOnClick would technically prevent us from bringing back to front in case they are being covered by an OS window from a different app,
|
||||
// but it shouldn't be much of a problem considering those are already popups that are closed when clicking elsewhere.
|
||||
if (is_short_lived_floating_window && (flags & ImGuiWindowFlags_Modal) == 0)
|
||||
if (is_short_lived_floating_window && !is_modal)
|
||||
viewport_flags |= ImGuiViewportFlags_NoFocusOnAppearing | ImGuiViewportFlags_NoFocusOnClick;
|
||||
|
||||
// We can overwrite viewport flags using ImGuiWindowClass (advanced users)
|
||||
@ -11426,10 +11429,11 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
|
||||
UpdateTryMergeWindowIntoHostViewports(window);
|
||||
}
|
||||
|
||||
// Fallback to default viewport
|
||||
// Fallback: merge in default viewport if z-order matches, otherwise create a new viewport
|
||||
if (window->Viewport == NULL)
|
||||
window->Viewport = main_viewport;
|
||||
|
||||
if (!UpdateTryMergeWindowIntoHostViewport(window, main_viewport))
|
||||
window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_None);
|
||||
|
||||
// Mark window as allowed to protrude outside of its viewport and into the current monitor
|
||||
if (!lock_viewport)
|
||||
{
|
||||
|
2
imgui.h
2
imgui.h
@ -1609,7 +1609,7 @@ struct ImGuiIO
|
||||
// Viewport options (when ImGuiConfigFlags_ViewportsEnable is set)
|
||||
bool ConfigViewportsNoAutoMerge; // = false; // Set to make all floating imgui windows always create their own viewport. Otherwise, they are merged into the main host viewports when overlapping it. May also set ImGuiViewportFlags_NoAutoMerge on individual viewport.
|
||||
bool ConfigViewportsNoTaskBarIcon; // = false // Disable default OS task bar icon flag for secondary viewports. When a viewport doesn't want a task bar icon, ImGuiViewportFlags_NoTaskBarIcon will be set on it.
|
||||
bool ConfigViewportsNoDecoration; // = true // [BETA] Disable default OS window decoration flag for secondary viewports. When a viewport doesn't want window decorations, ImGuiViewportFlags_NoDecoration will be set on it. Enabling decoration can create subsequent issues at OS levels (e.g. minimum window size).
|
||||
bool ConfigViewportsNoDecoration; // = true // Disable default OS window decoration flag for secondary viewports. When a viewport doesn't want window decorations, ImGuiViewportFlags_NoDecoration will be set on it. Enabling decoration can create subsequent issues at OS levels (e.g. minimum window size).
|
||||
bool ConfigViewportsNoDefaultParent; // = false // Disable default OS parenting to main viewport for secondary viewports. By default, viewports are marked with ParentViewportId = <main_viewport>, expecting the platform backend to setup a parent/child relationship between the OS windows (some backend may ignore this). Set to true if you want the default to be 0, then all viewports will be top-level OS windows.
|
||||
|
||||
// Miscellaneous options
|
||||
|
Loading…
Reference in New Issue
Block a user