|
@@ -28,6 +28,7 @@
|
|
|
|
|
|
// CHANGELOG
|
|
|
// (minor and older changes stripped away, please see git history for details)
|
|
|
+// 2025-06-11: Added ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window) and ImGui_ImplGlfw_GetContentScaleForMonitor(GLFWmonitor* monitor) helper to facilitate making DPI-aware apps.
|
|
|
// 2025-03-10: Map GLFW_KEY_WORLD_1 and GLFW_KEY_WORLD_2 into ImGuiKey_Oem102.
|
|
|
// 2025-03-03: Fixed clipboard handler assertion when using GLFW <= 3.2.1 compiled with asserts enabled.
|
|
|
// 2024-08-22: Moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
|
|
@@ -840,6 +841,33 @@ static void ImGui_ImplGlfw_UpdateGamepads()
|
|
|
#undef MAP_ANALOG
|
|
|
}
|
|
|
|
|
|
+// - 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_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window)
|
|
|
+{
|
|
|
+#if GLFW_HAS_PER_MONITOR_DPI && !defined(__APPLE__)
|
|
|
+ float x_scale, y_scale;
|
|
|
+ glfwGetWindowContentScale(window, &x_scale, &y_scale);
|
|
|
+ return x_scale;
|
|
|
+#else
|
|
|
+ IM_UNUSED(window);
|
|
|
+ return 1.0f;
|
|
|
+#endif
|
|
|
+}
|
|
|
+
|
|
|
+float ImGui_ImplGlfw_GetContentScaleForMonitor(GLFWmonitor* monitor)
|
|
|
+{
|
|
|
+#if GLFW_HAS_PER_MONITOR_DPI && !defined(__APPLE__)
|
|
|
+ float x_scale, y_scale;
|
|
|
+ glfwGetMonitorContentScale(monitor, &x_scale, &y_scale);
|
|
|
+ return x_scale;
|
|
|
+#else
|
|
|
+ IM_UNUSED(monitor);
|
|
|
+ return 1.0f;
|
|
|
+#endif
|
|
|
+}
|
|
|
+
|
|
|
void ImGui_ImplGlfw_NewFrame()
|
|
|
{
|
|
|
ImGuiIO& io = ImGui::GetIO();
|