|
@@ -16536,13 +16536,14 @@ static int ImGui::FindPlatformMonitorForRect(const ImRect& rect)
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
|
|
const int monitor_count = g.PlatformIO.Monitors.Size;
|
|
|
+ IM_ASSERT(monitor_count > 0);
|
|
|
if (monitor_count <= 1)
|
|
|
- return monitor_count - 1;
|
|
|
+ return 0;
|
|
|
|
|
|
// Use a minimum threshold of 1.0f so a zero-sized rect won't false positive, and will still find the correct monitor given its position.
|
|
|
// This is necessary for tooltips which always resize down to zero at first.
|
|
|
const float surface_threshold = ImMax(rect.GetWidth() * rect.GetHeight() * 0.5f, 1.0f);
|
|
|
- int best_monitor_n = -1;
|
|
|
+ int best_monitor_n = 0; // Default to the first monitor as fallback
|
|
|
float best_monitor_surface = 0.001f;
|
|
|
|
|
|
for (int monitor_n = 0; monitor_n < g.PlatformIO.Monitors.Size && best_monitor_surface < surface_threshold; monitor_n++)
|