From 3ff13edad91b58a45ebdf73e56461903a15631d6 Mon Sep 17 00:00:00 2001 From: Rokas Kupstys Date: Mon, 24 Feb 2020 15:14:04 +0200 Subject: [PATCH] Viewports: Improve menu positioning in multi-monitor setups. This change uses mouse position for initial positioning of popup menus. It ensures that menu appears in expected location on monitor mouse is currently hovering. This change fixes incorrect menu positioning (permanent or on the first frame) when menu item spans multiple monitors. --- imgui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 54fe7dc6..3d98a605 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -10986,7 +10986,7 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window) ImVec2 mouse_ref = (flags & ImGuiWindowFlags_Tooltip) ? g.IO.MousePos : g.BeginPopupStack.back().OpenMousePos; bool use_mouse_ref = (g.NavDisableHighlight || !g.NavDisableMouseHover || !g.NavWindow); bool mouse_valid = IsMousePosValid(&mouse_ref); - if ((window->Appearing || (flags & ImGuiWindowFlags_Tooltip)) && (!use_mouse_ref || mouse_valid)) + if ((window->Appearing || (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_ChildMenu))) && (!use_mouse_ref || mouse_valid)) window->ViewportAllowPlatformMonitorExtend = FindPlatformMonitorForPos((use_mouse_ref && mouse_valid) ? mouse_ref : NavCalcPreferredRefPos()); else window->ViewportAllowPlatformMonitorExtend = window->Viewport->PlatformMonitor;