|
|
@@ -1187,13 +1187,8 @@ void ImGuiIO::ClearInputCharacters()
|
|
|
InputQueueCharacters.resize(0);
|
|
|
}
|
|
|
|
|
|
-void ImGuiIO::AddFocusEvent(bool focused)
|
|
|
+void ImGuiIO::ClearInputKeys()
|
|
|
{
|
|
|
- if (focused)
|
|
|
- return;
|
|
|
-
|
|
|
- // Clear buttons state when focus is lost
|
|
|
- // (this is useful so e.g. releasing Alt after focus loss on Alt-Tab doesn't trigger the Alt menu toggle)
|
|
|
memset(KeysDown, 0, sizeof(KeysDown));
|
|
|
for (int n = 0; n < IM_ARRAYSIZE(KeysDownDuration); n++)
|
|
|
KeysDownDuration[n] = KeysDownDurationPrev[n] = -1.0f;
|
|
|
@@ -1203,6 +1198,13 @@ void ImGuiIO::AddFocusEvent(bool focused)
|
|
|
NavInputsDownDuration[n] = NavInputsDownDurationPrev[n] = -1.0f;
|
|
|
}
|
|
|
|
|
|
+void ImGuiIO::AddFocusEvent(bool focused)
|
|
|
+{
|
|
|
+ // We intentionally overwrite this and process in NewFrame(), in order to give a chance
|
|
|
+ // to multi-viewports backends to queue AddFocusEvent(false),AddFocusEvent(true) in same frame.
|
|
|
+ AppFocusLost = !focused;
|
|
|
+}
|
|
|
+
|
|
|
//-----------------------------------------------------------------------------
|
|
|
// [SECTION] MISC HELPERS/UTILITIES (Geometry functions)
|
|
|
//-----------------------------------------------------------------------------
|
|
|
@@ -3285,13 +3287,13 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged)
|
|
|
+bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
|
if (!bb.Overlaps(window->ClipRect))
|
|
|
if (id == 0 || (id != g.ActiveId && id != g.NavId))
|
|
|
- if (clip_even_when_logged || !g.LogEnabled)
|
|
|
+ if (!g.LogEnabled)
|
|
|
return true;
|
|
|
return false;
|
|
|
}
|
|
|
@@ -3888,7 +3890,7 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
|
|
|
|
|
|
// Modal windows prevents mouse from hovering behind them.
|
|
|
ImGuiWindow* modal_window = GetTopMostPopupModal();
|
|
|
- if (modal_window && g.HoveredWindow && !IsWindowChildOf(g.HoveredWindow->RootWindow, modal_window))
|
|
|
+ if (modal_window && g.HoveredWindow && !IsWindowChildOf(g.HoveredWindow->RootWindow, modal_window, true))
|
|
|
clear_hovered_windows = true;
|
|
|
|
|
|
// Disabled mouse?
|
|
|
@@ -4072,6 +4074,18 @@ void ImGui::NewFrame()
|
|
|
g.DragDropWithinTarget = false;
|
|
|
g.DragDropHoldJustPressedId = 0;
|
|
|
|
|
|
+ // Close popups on focus lost (currently wip/opt-in)
|
|
|
+ //if (g.IO.AppFocusLost)
|
|
|
+ // ClosePopupsExceptModals();
|
|
|
+
|
|
|
+ // Clear buttons state when focus is lost
|
|
|
+ // (this is useful so e.g. releasing Alt after focus loss on Alt-Tab doesn't trigger the Alt menu toggle)
|
|
|
+ if (g.IO.AppFocusLost)
|
|
|
+ {
|
|
|
+ g.IO.ClearInputKeys();
|
|
|
+ g.IO.AppFocusLost = false;
|
|
|
+ }
|
|
|
+
|
|
|
// Update keyboard input state
|
|
|
// Synchronize io.KeyMods with individual modifiers io.KeyXXX bools
|
|
|
g.IO.KeyMods = GetMergedKeyModFlags();
|
|
|
@@ -5120,7 +5134,7 @@ void ImGui::EndChild()
|
|
|
ItemAdd(bb, window->ChildId);
|
|
|
RenderNavHighlight(bb, window->ChildId);
|
|
|
|
|
|
- // When browsing a window that has no activable items (scroll only) we keep a highlight on the child
|
|
|
+ // When browsing a window that has no activable items (scroll only) we keep a highlight on the child (pass g.NavId to trick into always displaying)
|
|
|
if (window->DC.NavLayersActiveMask == 0 && window == g.NavWindow)
|
|
|
RenderNavHighlight(ImRect(bb.Min - ImVec2(2, 2), bb.Max + ImVec2(2, 2)), g.NavId, ImGuiNavHighlightFlags_TypeThin);
|
|
|
}
|
|
|
@@ -5766,9 +5780,11 @@ void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& titl
|
|
|
void ImGui::UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window)
|
|
|
{
|
|
|
window->ParentWindow = parent_window;
|
|
|
- window->RootWindow = window->RootWindowForTitleBarHighlight = window->RootWindowForNav = window;
|
|
|
+ window->RootWindow = window->RootWindowPopupTree = window->RootWindowForTitleBarHighlight = window->RootWindowForNav = window;
|
|
|
if (parent_window && (flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Tooltip))
|
|
|
window->RootWindow = parent_window->RootWindow;
|
|
|
+ if (parent_window && (flags & ImGuiWindowFlags_Popup))
|
|
|
+ window->RootWindowPopupTree = parent_window->RootWindowPopupTree;
|
|
|
if (parent_window && !(flags & ImGuiWindowFlags_Modal) && (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)))
|
|
|
window->RootWindowForTitleBarHighlight = parent_window->RootWindowForTitleBarHighlight;
|
|
|
while (window->RootWindowForNav->Flags & ImGuiWindowFlags_NavFlattened)
|
|
|
@@ -5847,12 +5863,12 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
|
|
|
// Add to stack
|
|
|
// We intentionally set g.CurrentWindow to NULL to prevent usage until when the viewport is set, then will call SetCurrentWindow()
|
|
|
+ g.CurrentWindow = window;
|
|
|
ImGuiWindowStackData window_stack_data;
|
|
|
window_stack_data.Window = window;
|
|
|
window_stack_data.ParentLastItemDataBackup = g.LastItemData;
|
|
|
+ window_stack_data.StackSizesOnBegin.SetToCurrentState();
|
|
|
g.CurrentWindowStack.push_back(window_stack_data);
|
|
|
- g.CurrentWindow = window;
|
|
|
- window->DC.StackSizesOnBegin.SetToCurrentState();
|
|
|
g.CurrentWindow = NULL;
|
|
|
|
|
|
if (flags & ImGuiWindowFlags_Popup)
|
|
|
@@ -6467,10 +6483,10 @@ void ImGui::End()
|
|
|
|
|
|
// Pop from window stack
|
|
|
g.LastItemData = g.CurrentWindowStack.back().ParentLastItemDataBackup;
|
|
|
- g.CurrentWindowStack.pop_back();
|
|
|
if (window->Flags & ImGuiWindowFlags_Popup)
|
|
|
g.BeginPopupStack.pop_back();
|
|
|
- window->DC.StackSizesOnBegin.CompareWithCurrentState();
|
|
|
+ g.CurrentWindowStack.back().StackSizesOnBegin.CompareWithCurrentState();
|
|
|
+ g.CurrentWindowStack.pop_back();
|
|
|
SetCurrentWindow(g.CurrentWindowStack.Size == 0 ? NULL : g.CurrentWindowStack.back().Window);
|
|
|
}
|
|
|
|
|
|
@@ -6663,11 +6679,14 @@ void ImGui::BeginDisabled(bool disabled)
|
|
|
if (was_disabled || disabled)
|
|
|
g.CurrentItemFlags |= ImGuiItemFlags_Disabled;
|
|
|
g.ItemFlagsStack.push_back(g.CurrentItemFlags);
|
|
|
+ g.DisabledStackSize++;
|
|
|
}
|
|
|
|
|
|
void ImGui::EndDisabled()
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
+ IM_ASSERT(g.DisabledStackSize > 0);
|
|
|
+ g.DisabledStackSize--;
|
|
|
bool was_disabled = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0;
|
|
|
//PopItemFlag();
|
|
|
g.ItemFlagsStack.pop_back();
|
|
|
@@ -6711,14 +6730,25 @@ void ImGui::PopTextWrapPos()
|
|
|
window->DC.TextWrapPosStack.pop_back();
|
|
|
}
|
|
|
|
|
|
-bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent)
|
|
|
+static ImGuiWindow* GetCombinedRootWindow(ImGuiWindow* window, bool popup_hierarchy)
|
|
|
{
|
|
|
- if (window->RootWindow == potential_parent)
|
|
|
+ window = window->RootWindow;
|
|
|
+ if (popup_hierarchy)
|
|
|
+ window = window->RootWindowPopupTree;
|
|
|
+ return window;
|
|
|
+}
|
|
|
+
|
|
|
+bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent, bool popup_hierarchy)
|
|
|
+{
|
|
|
+ ImGuiWindow* window_root = GetCombinedRootWindow(window, popup_hierarchy);
|
|
|
+ if (window_root == potential_parent)
|
|
|
return true;
|
|
|
while (window != NULL)
|
|
|
{
|
|
|
if (window == potential_parent)
|
|
|
return true;
|
|
|
+ if (window == window_root) // end of chain
|
|
|
+ return false;
|
|
|
window = window->ParentWindow;
|
|
|
}
|
|
|
return false;
|
|
|
@@ -6750,13 +6780,13 @@ bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags)
|
|
|
if ((flags & ImGuiHoveredFlags_AnyWindow) == 0)
|
|
|
{
|
|
|
IM_ASSERT(cur_window); // Not inside a Begin()/End()
|
|
|
-
|
|
|
+ const bool popup_hierarchy = (flags & ImGuiHoveredFlags_NoPopupHierarchy) == 0;
|
|
|
if (flags & ImGuiHoveredFlags_RootWindow)
|
|
|
- cur_window = cur_window->RootWindow;
|
|
|
+ cur_window = GetCombinedRootWindow(cur_window, popup_hierarchy);
|
|
|
|
|
|
bool result;
|
|
|
if (flags & ImGuiHoveredFlags_ChildWindows)
|
|
|
- result = IsWindowChildOf(ref_window, cur_window);
|
|
|
+ result = IsWindowChildOf(ref_window, cur_window, popup_hierarchy);
|
|
|
else
|
|
|
result = (ref_window == cur_window);
|
|
|
if (!result)
|
|
|
@@ -6783,11 +6813,12 @@ bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags)
|
|
|
return true;
|
|
|
IM_ASSERT(cur_window); // Not inside a Begin()/End()
|
|
|
|
|
|
+ const bool popup_hierarchy = (flags & ImGuiFocusedFlags_NoPopupHierarchy) == 0;
|
|
|
if (flags & ImGuiHoveredFlags_RootWindow)
|
|
|
- cur_window = cur_window->RootWindow;
|
|
|
+ cur_window = GetCombinedRootWindow(cur_window, popup_hierarchy);
|
|
|
|
|
|
if (flags & ImGuiHoveredFlags_ChildWindows)
|
|
|
- return IsWindowChildOf(ref_window, cur_window);
|
|
|
+ return IsWindowChildOf(ref_window, cur_window, popup_hierarchy);
|
|
|
else
|
|
|
return (ref_window == cur_window);
|
|
|
}
|
|
|
@@ -7313,53 +7344,13 @@ void ImGui::ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, voi
|
|
|
{
|
|
|
// PVS-Studio V1044 is "Loop break conditions do not depend on the number of iterations"
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
- while (g.CurrentWindowStack.Size > 0)
|
|
|
+ while (g.CurrentWindowStack.Size > 0) //-V1044
|
|
|
{
|
|
|
- while (g.CurrentTable && (g.CurrentTable->OuterWindow == g.CurrentWindow || g.CurrentTable->InnerWindow == g.CurrentWindow))
|
|
|
- {
|
|
|
- if (log_callback) log_callback(user_data, "Recovered from missing EndTable() in '%s'", g.CurrentTable->OuterWindow->Name);
|
|
|
- EndTable();
|
|
|
- }
|
|
|
+ ErrorCheckEndWindowRecover(log_callback, user_data);
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
|
- IM_ASSERT(window != NULL);
|
|
|
- while (g.CurrentTabBar != NULL) //-V1044
|
|
|
- {
|
|
|
- if (log_callback) log_callback(user_data, "Recovered from missing EndTabBar() in '%s'", window->Name);
|
|
|
- EndTabBar();
|
|
|
- }
|
|
|
- while (window->DC.TreeDepth > 0)
|
|
|
- {
|
|
|
- if (log_callback) log_callback(user_data, "Recovered from missing TreePop() in '%s'", window->Name);
|
|
|
- TreePop();
|
|
|
- }
|
|
|
- while (g.GroupStack.Size > window->DC.StackSizesOnBegin.SizeOfGroupStack)
|
|
|
- {
|
|
|
- if (log_callback) log_callback(user_data, "Recovered from missing EndGroup() in '%s'", window->Name);
|
|
|
- EndGroup();
|
|
|
- }
|
|
|
- while (window->IDStack.Size > 1)
|
|
|
- {
|
|
|
- if (log_callback) log_callback(user_data, "Recovered from missing PopID() in '%s'", window->Name);
|
|
|
- PopID();
|
|
|
- }
|
|
|
- while (g.ColorStack.Size > window->DC.StackSizesOnBegin.SizeOfColorStack)
|
|
|
- {
|
|
|
- if (log_callback) log_callback(user_data, "Recovered from missing PopStyleColor() in '%s' for ImGuiCol_%s", window->Name, GetStyleColorName(g.ColorStack.back().Col));
|
|
|
- PopStyleColor();
|
|
|
- }
|
|
|
- while (g.StyleVarStack.Size > window->DC.StackSizesOnBegin.SizeOfStyleVarStack)
|
|
|
- {
|
|
|
- if (log_callback) log_callback(user_data, "Recovered from missing PopStyleVar() in '%s'", window->Name);
|
|
|
- PopStyleVar();
|
|
|
- }
|
|
|
- while (g.FocusScopeStack.Size > window->DC.StackSizesOnBegin.SizeOfFocusScopeStack)
|
|
|
- {
|
|
|
- if (log_callback) log_callback(user_data, "Recovered from missing PopFocusScope() in '%s'", window->Name);
|
|
|
- PopFocusScope();
|
|
|
- }
|
|
|
if (g.CurrentWindowStack.Size == 1)
|
|
|
{
|
|
|
- IM_ASSERT(g.CurrentWindow->IsFallbackWindow);
|
|
|
+ IM_ASSERT(window->IsFallbackWindow);
|
|
|
break;
|
|
|
}
|
|
|
IM_ASSERT(window == g.CurrentWindow);
|
|
|
@@ -7376,6 +7367,66 @@ void ImGui::ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, voi
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// Must be called before End()/EndChild()
|
|
|
+void ImGui::ErrorCheckEndWindowRecover(ImGuiErrorLogCallback log_callback, void* user_data)
|
|
|
+{
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ while (g.CurrentTable && (g.CurrentTable->OuterWindow == g.CurrentWindow || g.CurrentTable->InnerWindow == g.CurrentWindow))
|
|
|
+ {
|
|
|
+ if (log_callback) log_callback(user_data, "Recovered from missing EndTable() in '%s'", g.CurrentTable->OuterWindow->Name);
|
|
|
+ EndTable();
|
|
|
+ }
|
|
|
+
|
|
|
+ ImGuiWindow* window = g.CurrentWindow;
|
|
|
+ ImGuiStackSizes* stack_sizes = &g.CurrentWindowStack.back().StackSizesOnBegin;
|
|
|
+ IM_ASSERT(window != NULL);
|
|
|
+ while (g.CurrentTabBar != NULL) //-V1044
|
|
|
+ {
|
|
|
+ if (log_callback) log_callback(user_data, "Recovered from missing EndTabBar() in '%s'", window->Name);
|
|
|
+ EndTabBar();
|
|
|
+ }
|
|
|
+ while (window->DC.TreeDepth > 0)
|
|
|
+ {
|
|
|
+ if (log_callback) log_callback(user_data, "Recovered from missing TreePop() in '%s'", window->Name);
|
|
|
+ TreePop();
|
|
|
+ }
|
|
|
+ while (g.GroupStack.Size > stack_sizes->SizeOfGroupStack) //-V1044
|
|
|
+ {
|
|
|
+ if (log_callback) log_callback(user_data, "Recovered from missing EndGroup() in '%s'", window->Name);
|
|
|
+ EndGroup();
|
|
|
+ }
|
|
|
+ while (window->IDStack.Size > 1)
|
|
|
+ {
|
|
|
+ if (log_callback) log_callback(user_data, "Recovered from missing PopID() in '%s'", window->Name);
|
|
|
+ PopID();
|
|
|
+ }
|
|
|
+ while (g.DisabledStackSize > stack_sizes->SizeOfDisabledStack) //-V1044
|
|
|
+ {
|
|
|
+ if (log_callback) log_callback(user_data, "Recovered from missing EndDisabled() in '%s'", window->Name);
|
|
|
+ EndDisabled();
|
|
|
+ }
|
|
|
+ while (g.ColorStack.Size > stack_sizes->SizeOfColorStack)
|
|
|
+ {
|
|
|
+ if (log_callback) log_callback(user_data, "Recovered from missing PopStyleColor() in '%s' for ImGuiCol_%s", window->Name, GetStyleColorName(g.ColorStack.back().Col));
|
|
|
+ PopStyleColor();
|
|
|
+ }
|
|
|
+ while (g.ItemFlagsStack.Size > stack_sizes->SizeOfItemFlagsStack) //-V1044
|
|
|
+ {
|
|
|
+ if (log_callback) log_callback(user_data, "Recovered from missing PopItemFlag() in '%s'", window->Name);
|
|
|
+ PopItemFlag();
|
|
|
+ }
|
|
|
+ while (g.StyleVarStack.Size > stack_sizes->SizeOfStyleVarStack) //-V1044
|
|
|
+ {
|
|
|
+ if (log_callback) log_callback(user_data, "Recovered from missing PopStyleVar() in '%s'", window->Name);
|
|
|
+ PopStyleVar();
|
|
|
+ }
|
|
|
+ while (g.FocusScopeStack.Size > stack_sizes->SizeOfFocusScopeStack) //-V1044
|
|
|
+ {
|
|
|
+ if (log_callback) log_callback(user_data, "Recovered from missing PopFocusScope() in '%s'", window->Name);
|
|
|
+ PopFocusScope();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// Save current stack sizes for later compare
|
|
|
void ImGuiStackSizes::SetToCurrentState()
|
|
|
{
|
|
|
@@ -7387,7 +7438,9 @@ void ImGuiStackSizes::SetToCurrentState()
|
|
|
SizeOfFontStack = (short)g.FontStack.Size;
|
|
|
SizeOfFocusScopeStack = (short)g.FocusScopeStack.Size;
|
|
|
SizeOfGroupStack = (short)g.GroupStack.Size;
|
|
|
+ SizeOfItemFlagsStack = (short)g.ItemFlagsStack.Size;
|
|
|
SizeOfBeginPopupStack = (short)g.BeginPopupStack.Size;
|
|
|
+ SizeOfDisabledStack = (short)g.DisabledStackSize;
|
|
|
}
|
|
|
|
|
|
// Compare to detect usage errors
|
|
|
@@ -7405,6 +7458,8 @@ void ImGuiStackSizes::CompareWithCurrentState()
|
|
|
// For color, style and font stacks there is an incentive to use Push/Begin/Pop/.../End patterns, so we relax our checks a little to allow them.
|
|
|
IM_ASSERT(SizeOfGroupStack == g.GroupStack.Size && "BeginGroup/EndGroup Mismatch!");
|
|
|
IM_ASSERT(SizeOfBeginPopupStack == g.BeginPopupStack.Size && "BeginPopup/EndPopup or BeginMenu/EndMenu Mismatch!");
|
|
|
+ IM_ASSERT(SizeOfDisabledStack == g.DisabledStackSize && "BeginDisabled/EndDisabled Mismatch!");
|
|
|
+ IM_ASSERT(SizeOfItemFlagsStack >= g.ItemFlagsStack.Size && "PushItemFlag/PopItemFlag Mismatch!");
|
|
|
IM_ASSERT(SizeOfColorStack >= g.ColorStack.Size && "PushStyleColor/PopStyleColor Mismatch!");
|
|
|
IM_ASSERT(SizeOfStyleVarStack >= g.StyleVarStack.Size && "PushStyleVar/PopStyleVar Mismatch!");
|
|
|
IM_ASSERT(SizeOfFontStack >= g.FontStack.Size && "PushFont/PopFont Mismatch!");
|
|
|
@@ -7536,7 +7591,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu
|
|
|
#endif
|
|
|
|
|
|
// Clipping test
|
|
|
- const bool is_clipped = IsClippedEx(bb, id, false);
|
|
|
+ const bool is_clipped = IsClippedEx(bb, id);
|
|
|
if (is_clipped)
|
|
|
return false;
|
|
|
//if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG]
|
|
|
@@ -8326,6 +8381,21 @@ void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void ImGui::ClosePopupsExceptModals()
|
|
|
+{
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+
|
|
|
+ int popup_count_to_keep;
|
|
|
+ for (popup_count_to_keep = g.OpenPopupStack.Size; popup_count_to_keep > 0; popup_count_to_keep--)
|
|
|
+ {
|
|
|
+ ImGuiWindow* window = g.OpenPopupStack[popup_count_to_keep - 1].Window;
|
|
|
+ if (!window || window->Flags & ImGuiWindowFlags_Modal)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (popup_count_to_keep < g.OpenPopupStack.Size) // This test is not required but it allows to set a convenient breakpoint on the statement below
|
|
|
+ ClosePopupToLevel(popup_count_to_keep, true);
|
|
|
+}
|
|
|
+
|
|
|
void ImGui::ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
@@ -9752,8 +9822,9 @@ static void ImGui::NavUpdateWindowing()
|
|
|
}
|
|
|
|
|
|
// Start CTRL-TAB or Square+L/R window selection
|
|
|
- bool start_windowing_with_gamepad = allow_windowing && !g.NavWindowingTarget && IsNavInputTest(ImGuiNavInput_Menu, ImGuiInputReadMode_Pressed);
|
|
|
- bool start_windowing_with_keyboard = allow_windowing && !g.NavWindowingTarget && io.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab) && (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard);
|
|
|
+ const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
|
|
|
+ const bool start_windowing_with_gamepad = allow_windowing && !g.NavWindowingTarget && IsNavInputTest(ImGuiNavInput_Menu, ImGuiInputReadMode_Pressed);
|
|
|
+ const bool start_windowing_with_keyboard = allow_windowing && !g.NavWindowingTarget && nav_keyboard_active && io.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab);
|
|
|
if (start_windowing_with_gamepad || start_windowing_with_keyboard)
|
|
|
if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1))
|
|
|
{
|
|
|
@@ -9804,7 +9875,7 @@ static void ImGui::NavUpdateWindowing()
|
|
|
// Keyboard: Press and Release ALT to toggle menu layer
|
|
|
// - Testing that only Alt is tested prevents Alt+Shift or AltGR from toggling menu layer.
|
|
|
// - AltGR is normally Alt+Ctrl but we can't reliably detect it (not all backends/systems/layout emit it as Alt+Ctrl). But even on keyboards without AltGR we don't want Alt+Ctrl to open menu anyway.
|
|
|
- if (io.KeyMods == ImGuiKeyModFlags_Alt && (io.KeyModsPrev & ImGuiKeyModFlags_Alt) == 0)
|
|
|
+ if (nav_keyboard_active && io.KeyMods == ImGuiKeyModFlags_Alt && (io.KeyModsPrev & ImGuiKeyModFlags_Alt) == 0)
|
|
|
{
|
|
|
g.NavWindowingToggleLayer = true;
|
|
|
g.NavInputSource = ImGuiInputSource_Keyboard;
|