|
@@ -32,10 +32,11 @@
|
|
|
// SDL
|
|
|
#include <SDL.h>
|
|
|
#include <SDL_syswm.h>
|
|
|
-#define SDL_HAS_CAPTURE_MOUSE SDL_VERSION_ATLEAST(2,0,4)
|
|
|
-#define SDL_HAS_WINDOW_OPACITY SDL_VERSION_ATLEAST(2,0,5)
|
|
|
-#define SDL_HAS_ALWAYS_ON_TOP SDL_VERSION_ATLEAST(2,0,5)
|
|
|
-#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
|
|
|
+#define SDL_HAS_CAPTURE_MOUSE SDL_VERSION_ATLEAST(2,0,4)
|
|
|
+#define SDL_HAS_WINDOW_OPACITY SDL_VERSION_ATLEAST(2,0,5)
|
|
|
+#define SDL_HAS_ALWAYS_ON_TOP SDL_VERSION_ATLEAST(2,0,5)
|
|
|
+#define SDL_HAS_PER_MONITOR_DPI SDL_VERSION_ATLEAST(2,0,4)
|
|
|
+#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
|
|
|
#if !SDL_HAS_VULKAN
|
|
|
static const Uint32 SDL_WINDOW_VULKAN = 0x10000000;
|
|
|
#endif
|
|
@@ -446,13 +447,19 @@ static void ImGui_ImplSDL2_UpdateMonitors()
|
|
|
{
|
|
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
|
int display_count = SDL_GetNumVideoDisplays();
|
|
|
- platform_io.Monitors.resize(display_count);
|
|
|
+ platform_io.Monitors.resize(display_count, ImGuiPlatformMonitor());
|
|
|
for (int n = 0; n < display_count; n++)
|
|
|
{
|
|
|
+ // Warning: the validity of monitor DPI information on Windows depends on the application DPI awareness settings, which generally needs to be set in the manifest or at runtime.
|
|
|
SDL_Rect r;
|
|
|
SDL_GetDisplayBounds(n, &r);
|
|
|
platform_io.Monitors[n].Pos = ImVec2((float)r.x, (float)r.y);
|
|
|
platform_io.Monitors[n].Size = ImVec2((float)r.w, (float)r.h);
|
|
|
+#if SDL_HAS_PER_MONITOR_DPI
|
|
|
+ float dpi = 0.0f;
|
|
|
+ SDL_GetDisplayDPI(n, &dpi, NULL, NULL);
|
|
|
+ platform_io.Monitors[n].DpiScale = dpi / 96.0f;
|
|
|
+#endif
|
|
|
}
|
|
|
}
|
|
|
|