Window: Fixed position not being clamped while auto-resizing (#5843)

This commit is contained in:
ocornut
2022-11-02 12:36:41 +01:00
parent 6e9dfe1de1
commit 90e9465fa5
2 changed files with 5 additions and 3 deletions

View File

@ -5987,7 +5987,7 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s
return ret_auto_fit;
}
static inline void ClampWindowRect(ImGuiWindow* window, const ImRect& visibility_rect)
static inline void ClampWindowPos(ImGuiWindow* window, const ImRect& visibility_rect)
{
ImGuiContext& g = *GImGui;
ImVec2 size_for_clamping = window->Size;
@ -6576,9 +6576,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// Clamp position/size so window stays visible within its viewport or monitor
// Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing.
if (!window_pos_set_by_api && !(flags & ImGuiWindowFlags_ChildWindow) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0)
if (!window_pos_set_by_api && !(flags & ImGuiWindowFlags_ChildWindow))
if (viewport_rect.GetWidth() > 0.0f && viewport_rect.GetHeight() > 0.0f)
ClampWindowRect(window, visibility_rect);
ClampWindowPos(window, visibility_rect);
window->Pos = ImFloor(window->Pos);
// Lock window rounding for the frame (so that altering them doesn't cause inconsistencies)