From a9b34b43c590e8362219f9f8ca54fa2b3860d0ef Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 25 Aug 2022 15:53:29 -0700 Subject: [PATCH] code for getting physical DPI we don't need it but I want to put it in Git history --- src/Window.zig | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Window.zig b/src/Window.zig index 154a9befb..82ed28cfc 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -193,6 +193,23 @@ pub fn create(alloc: Allocator, loop: libuv.Loop, config: *const Config) !*Windo } } + if (builtin.mode == .Debug) { + // Get our physical DPI - debug only because we don't have a use for + // this but the logging of it may be useful + const monitor = window.getMonitor() orelse monitor: { + log.warn("window had null monitor, getting primary monitor", .{}); + break :monitor glfw.Monitor.getPrimary().?; + }; + const physical_size = monitor.getPhysicalSize(); + const video_mode = try monitor.getVideoMode(); + const physical_x_dpi = @intToFloat(f32, video_mode.getWidth()) / (@intToFloat(f32, physical_size.width_mm) / 25.4); + const physical_y_dpi = @intToFloat(f32, video_mode.getHeight()) / (@intToFloat(f32, physical_size.height_mm) / 25.4); + log.debug("physical dpi x={} y={}", .{ + physical_x_dpi, + physical_y_dpi, + }); + } + // Determine our DPI configurations so we can properly configure // font points to pixels and handle other high-DPI scaling factors. const content_scale = try window.getContentScale();