mirror of
https://github.com/ocornut/imgui.git
synced 2024-12-11 19:39:29 +08:00
Viewports: fix/amend dcb6335
to (1) avoid refocusing when focus action was actionned from a click within imgui boundaries and (2) restore a null focus as well. (#6299)
This commit is contained in:
parent
1f0b46b93c
commit
63370be0e5
20
imgui.cpp
20
imgui.cpp
@ -13916,13 +13916,21 @@ static void ImGui::UpdateViewportsNewFrame()
|
|||||||
focused_viewport->LastFocusedStampCount = ++g.ViewportFocusedStampCount;
|
focused_viewport->LastFocusedStampCount = ++g.ViewportFocusedStampCount;
|
||||||
g.PlatformLastFocusedViewportId = focused_viewport->ID;
|
g.PlatformLastFocusedViewportId = focused_viewport->ID;
|
||||||
|
|
||||||
// Focus associated dear imgui window (#6299)
|
// Focus associated dear imgui window if focus didn't happen with a click within imgui boundaries (#6299)
|
||||||
// FIXME: perhaps 'FocusTopMostWindowUnderOne()' can handle both cases?
|
// e.g. Clicking platform title bar.
|
||||||
if (focused_viewport->Window != NULL)
|
// FIXME: perhaps 'FocusTopMostWindowUnderOne()' can handle the 'focused_window->Window != NULL' case as well.
|
||||||
FocusWindow(NavRestoreLastChildNavWindow(focused_viewport->Window));
|
if (!IsAnyMouseDown())
|
||||||
else
|
{
|
||||||
FocusTopMostWindowUnderOne(NULL, NULL, focused_viewport);
|
if (focused_viewport->Window != NULL)
|
||||||
|
FocusWindow(NavRestoreLastChildNavWindow(focused_viewport->Window));
|
||||||
|
else if (focused_viewport->LastFocusedHadNavWindow)
|
||||||
|
FocusTopMostWindowUnderOne(NULL, NULL, focused_viewport);
|
||||||
|
else
|
||||||
|
FocusWindow(NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (focused_viewport)
|
||||||
|
focused_viewport->LastFocusedHadNavWindow = (g.NavWindow != NULL) && (g.NavWindow->Viewport == focused_viewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create/update main viewport with current platform position.
|
// Create/update main viewport with current platform position.
|
||||||
|
@ -1738,6 +1738,7 @@ struct ImGuiViewportP : public ImGuiViewport
|
|||||||
ImVec2 LastPos;
|
ImVec2 LastPos;
|
||||||
float Alpha; // Window opacity (when dragging dockable windows/viewports we make them transparent)
|
float Alpha; // Window opacity (when dragging dockable windows/viewports we make them transparent)
|
||||||
float LastAlpha;
|
float LastAlpha;
|
||||||
|
bool LastFocusedHadNavWindow;// Instead of maintaining a LastFocusedWindow (which may harder to correctly maintain), we merely store weither NavWindow != NULL last time the viewport was focused.
|
||||||
short PlatformMonitor;
|
short PlatformMonitor;
|
||||||
int DrawListsLastFrame[2]; // Last frame number the background (0) and foreground (1) draw lists were used
|
int DrawListsLastFrame[2]; // Last frame number the background (0) and foreground (1) draw lists were used
|
||||||
ImDrawList* DrawLists[2]; // Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays.
|
ImDrawList* DrawLists[2]; // Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays.
|
||||||
@ -1751,7 +1752,7 @@ struct ImGuiViewportP : public ImGuiViewport
|
|||||||
ImVec2 BuildWorkOffsetMin; // Work Area: Offset being built during current frame. Generally >= 0.0f.
|
ImVec2 BuildWorkOffsetMin; // Work Area: Offset being built during current frame. Generally >= 0.0f.
|
||||||
ImVec2 BuildWorkOffsetMax; // Work Area: Offset being built during current frame. Generally <= 0.0f.
|
ImVec2 BuildWorkOffsetMax; // Work Area: Offset being built during current frame. Generally <= 0.0f.
|
||||||
|
|
||||||
ImGuiViewportP() { Window = NULL; Idx = -1; LastFrameActive = DrawListsLastFrame[0] = DrawListsLastFrame[1] = LastFocusedStampCount = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; PlatformMonitor = -1; Window = NULL; DrawLists[0] = DrawLists[1] = NULL; LastPlatformPos = LastPlatformSize = LastRendererSize = ImVec2(FLT_MAX, FLT_MAX); }
|
ImGuiViewportP() { Window = NULL; Idx = -1; LastFrameActive = DrawListsLastFrame[0] = DrawListsLastFrame[1] = LastFocusedStampCount = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; LastFocusedHadNavWindow = false; PlatformMonitor = -1; Window = NULL; DrawLists[0] = DrawLists[1] = NULL; LastPlatformPos = LastPlatformSize = LastRendererSize = ImVec2(FLT_MAX, FLT_MAX); }
|
||||||
~ImGuiViewportP() { if (DrawLists[0]) IM_DELETE(DrawLists[0]); if (DrawLists[1]) IM_DELETE(DrawLists[1]); }
|
~ImGuiViewportP() { if (DrawLists[0]) IM_DELETE(DrawLists[0]); if (DrawLists[1]) IM_DELETE(DrawLists[1]); }
|
||||||
void ClearRequestFlags() { PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; }
|
void ClearRequestFlags() { PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user