mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-24 05:19:02 +08:00
Backends: SDL2, SDL3, Win32: don't submit monitor with 0 DpiScale (e.g. accessibility virtual monitor?). to prevent assert. (#7902)
I am not too confident on this but I believe pushing this is the fastest way we will get feedback.
This commit is contained in:
parent
fa65dcf24c
commit
65840c19c4
@ -907,7 +907,7 @@ static void ImGui_ImplGlfw_UpdateMonitors()
|
||||
float x_scale, y_scale;
|
||||
glfwGetMonitorContentScale(glfw_monitors[n], &x_scale, &y_scale);
|
||||
if (x_scale == 0.0f)
|
||||
continue; // Some accessibility applications are declaring fake monitors with a DPI of 0, see (#7902)
|
||||
continue; // Some accessibility applications are declaring virtual monitors with a DPI of 0, see #7902.
|
||||
monitor.DpiScale = x_scale;
|
||||
#endif
|
||||
monitor.PlatformHandle = (void*)glfw_monitors[n]; // [...] GLFW doc states: "guaranteed to be valid only until the monitor configuration changes"
|
||||
|
@ -848,7 +848,11 @@ static void ImGui_ImplSDL2_UpdateMonitors()
|
||||
// DpiScale to cocoa_window.backingScaleFactor here.
|
||||
float dpi = 0.0f;
|
||||
if (!SDL_GetDisplayDPI(n, &dpi, nullptr, nullptr))
|
||||
{
|
||||
if (dpi <= 0.0f)
|
||||
continue; // Some accessibility applications are declaring virtual monitors with a DPI of 0, see #7902.
|
||||
monitor.DpiScale = dpi / 96.0f;
|
||||
}
|
||||
#endif
|
||||
monitor.PlatformHandle = (void*)(intptr_t)n;
|
||||
platform_io.Monitors.push_back(monitor);
|
||||
|
@ -806,6 +806,8 @@ static void ImGui_ImplSDL3_UpdateMonitors()
|
||||
// DpiScale to cocoa_window.backingScaleFactor here.
|
||||
monitor.DpiScale = SDL_GetDisplayContentScale(display_id);
|
||||
monitor.PlatformHandle = (void*)(intptr_t)n;
|
||||
if (monitor.DpiScale <= 0.0f)
|
||||
continue; // Some accessibility applications are declaring virtual monitors with a DPI of 0, see #7902.
|
||||
platform_io.Monitors.push_back(monitor);
|
||||
}
|
||||
}
|
||||
|
@ -437,6 +437,8 @@ static BOOL CALLBACK ImGui_ImplWin32_UpdateMonitors_EnumFunc(HMONITOR monitor, H
|
||||
imgui_monitor.WorkSize = ImVec2((float)(info.rcWork.right - info.rcWork.left), (float)(info.rcWork.bottom - info.rcWork.top));
|
||||
imgui_monitor.DpiScale = ImGui_ImplWin32_GetDpiScaleForMonitor(monitor);
|
||||
imgui_monitor.PlatformHandle = (void*)monitor;
|
||||
if (imgui_monitor.DpiScale <= 0.0f)
|
||||
return TRUE; // Some accessibility applications are declaring virtual monitors with a DPI of 0, see #7902.
|
||||
ImGuiPlatformIO& io = ImGui::GetPlatformIO();
|
||||
if (info.dwFlags & MONITORINFOF_PRIMARY)
|
||||
io.Monitors.push_front(imgui_monitor);
|
||||
|
@ -56,8 +56,8 @@ Docking+Viewports Branch:
|
||||
|
||||
- Viewports: added optional platform_io.Platform_GetWindowWorkAreaInsets() hook
|
||||
to allow backends to alter the default per-viewport work-area. (#7823)
|
||||
- Backends: don't report monitors with DpiScale of 0, which seemed to be reported
|
||||
for virtual monitors instead by accessibility drivers. (#7902) [@nicolasnoble]
|
||||
- Backends: don't report monitors with DpiScale of 0, which seemed to be reported for
|
||||
virtual monitors instead by accessibility drivers. (#7902) [@nicolasnoble, @ocornut]
|
||||
- Backends: SDL2, SDL3: using SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN to support the
|
||||
ImGuiViewportFlags_NoFocusOnAppearing flag, instead of using a Win32-specific hack.
|
||||
(#7896) [@RT2Code]
|
||||
|
Loading…
Reference in New Issue
Block a user