Backends: GLFW: Preserve monitor list when there are no monitor. (#5683)

This commit is contained in:
ocornut
2023-05-25 15:38:35 +02:00
parent 54c1ac3e38
commit 19b436f68d
2 changed files with 7 additions and 1 deletions

View File

@@ -877,10 +877,14 @@ static void ImGui_ImplGlfw_UpdateMonitors()
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
bd->WantUpdateMonitors = false;
int monitors_count = 0;
GLFWmonitor** glfw_monitors = glfwGetMonitors(&monitors_count);
if (monitors_count) // Preserve existing monitor list if there are none. Happens on macOS sleeping (#5683)
return;
platform_io.Monitors.resize(0);
bd->WantUpdateMonitors = false;
for (int n = 0; n < monitors_count; n++)
{
ImGuiPlatformMonitor monitor;