From 3c4408c620bec12822dc6208a324872e83521db6 Mon Sep 17 00:00:00 2001
From: Casey Mulcahy
Date: Tue, 26 Aug 2025 09:00:47 -0400
Subject: [PATCH] Avoid loss of precision in update_dimensions
Fixes #422
---
src/native/windows.rs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/native/windows.rs b/src/native/windows.rs
index 28bf447c..09140be0 100644
--- a/src/native/windows.rs
+++ b/src/native/windows.rs
@@ -799,13 +799,13 @@ impl WindowsDisplay {
if GetClientRect(hwnd, &mut client_rect as *mut _ as _) != 0 {
// Calculate window width and height based on the client area
let window_width =
- ((client_rect.right - client_rect.left) as f32 / self.window_scale) as i32;
+ (client_rect.right - client_rect.left) as f32 / self.window_scale;
let window_height =
- ((client_rect.bottom - client_rect.top) as f32 / self.window_scale) as i32;
+ (client_rect.bottom - client_rect.top) as f32 / self.window_scale;
// Prevent a framebuffer size of 0 when the window is minimized
- let fb_width = ((window_width as f32 * self.content_scale) as i32).max(1);
- let fb_height = ((window_height as f32 * self.content_scale) as i32).max(1);
+ let fb_width = ((window_width * self.content_scale).round() as i32).max(1);
+ let fb_height = ((window_height * self.content_scale).round() as i32).max(1);
// Check for size changes
if fb_width != d.screen_width || fb_height != d.screen_height {