|
@@ -21,6 +21,7 @@
|
|
|
|
|
|
// CHANGELOG
|
|
// CHANGELOG
|
|
// (minor and older changes stripped away, please see git history for details)
|
|
// (minor and older changes stripped away, please see git history for details)
|
|
|
|
+// 2025-06-11: Added ImGui_ImplSDL2_GetContentScaleForWindow(SDL_Window* window) and ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index) helper to facilitate making DPI-aware apps.
|
|
// 2025-04-09: Don't attempt to call SDL_CaptureMouse() on drivers where we don't call SDL_GetGlobalMouseState(). (#8561)
|
|
// 2025-04-09: Don't attempt to call SDL_CaptureMouse() on drivers where we don't call SDL_GetGlobalMouseState(). (#8561)
|
|
// 2025-03-21: Fill gamepad inputs and set ImGuiBackendFlags_HasGamepad regardless of ImGuiConfigFlags_NavEnableGamepad being set.
|
|
// 2025-03-21: Fill gamepad inputs and set ImGuiBackendFlags_HasGamepad regardless of ImGuiConfigFlags_NavEnableGamepad being set.
|
|
// 2025-03-10: When dealing with OEM keys, use scancodes instead of translated keycodes to choose ImGuiKey values. (#7136, #7201, #7206, #7306, #7670, #7672, #8468)
|
|
// 2025-03-10: When dealing with OEM keys, use scancodes instead of translated keycodes to choose ImGuiKey values. (#7136, #7201, #7206, #7306, #7670, #7672, #8468)
|
|
@@ -702,6 +703,26 @@ static void ImGui_ImplSDL2_UpdateMouseCursor()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// - On Windows the process needs to be marked DPI-aware!! SDL2 doesn't do it by default. You can call ::SetProcessDPIAware() or call ImGui_ImplWin32_EnableDpiAwareness() from Win32 backend.
|
|
|
|
+// - Apple platforms use FramebufferScale so we always return 1.0f.
|
|
|
|
+// - Some accessibility applications are declaring virtual monitors with a DPI of 0.0f, see #7902. We preserve this value for caller to handle.
|
|
|
|
+float ImGui_ImplSDL2_GetContentScaleForWindow(SDL_Window* window)
|
|
|
|
+{
|
|
|
|
+ return ImGui_ImplSDL2_GetContentScaleForDisplay(SDL_GetWindowDisplayIndex(window));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+float ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index)
|
|
|
|
+{
|
|
|
|
+#if SDL_HAS_PER_MONITOR_DPI
|
|
|
|
+#ifndef __APPLE__
|
|
|
|
+ float dpi = 0.0f;
|
|
|
|
+ if (SDL_GetDisplayDPI(display_index, &dpi, nullptr, nullptr) == 0)
|
|
|
|
+ return dpi / 96.0f;
|
|
|
|
+#endif
|
|
|
|
+#endif
|
|
|
|
+ return 1.0f;
|
|
|
|
+}
|
|
|
|
+
|
|
static void ImGui_ImplSDL2_CloseGamepads()
|
|
static void ImGui_ImplSDL2_CloseGamepads()
|
|
{
|
|
{
|
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|