Browse Source

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

pull/6468/head
ocornut 1 year ago
parent
commit
19b436f68d
  1. 6
      backends/imgui_impl_glfw.cpp
  2. 2
      docs/CHANGELOG.txt

6
backends/imgui_impl_glfw.cpp

@ -877,10 +877,14 @@ static void ImGui_ImplGlfw_UpdateMonitors()
{ {
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
bd->WantUpdateMonitors = false;
int monitors_count = 0; int monitors_count = 0;
GLFWmonitor** glfw_monitors = glfwGetMonitors(&monitors_count); 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); platform_io.Monitors.resize(0);
bd->WantUpdateMonitors = false;
for (int n = 0; n < monitors_count; n++) for (int n = 0; n < monitors_count; n++)
{ {
ImGuiPlatformMonitor monitor; ImGuiPlatformMonitor monitor;

2
docs/CHANGELOG.txt

@ -165,6 +165,8 @@ Docking+Viewports Branch:
main viewport, due to platform-side handling changes. Regression from 1.89.5 (#6299) main viewport, due to platform-side handling changes. Regression from 1.89.5 (#6299)
- Viewports: Added void* ImGuiPlatformMonitor::PlatformHandle field (backend-dependant), - Viewports: Added void* ImGuiPlatformMonitor::PlatformHandle field (backend-dependant),
for usage by user code. for usage by user code.
- Backends: GLFW: Preserve monitor list when there are no monitor, may briefly
happen when recovering from macOS sleeping mode. (#5683) [@Guistac]
- Backends: SDL2: Update monitor list when receiving a display event. (#6348) - Backends: SDL2: Update monitor list when receiving a display event. (#6348)
Note however that SDL2 currently doesn't have an event for a DPI/Scaling change, Note however that SDL2 currently doesn't have an event for a DPI/Scaling change,
so monitor data won't be updated in this situation. so monitor data won't be updated in this situation.

Loading…
Cancel
Save