From da74cbe3920b65e3e527835fd8609bb1ddf51996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Tue, 10 Sep 2024 19:46:26 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E5=AD=90?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E5=88=86=E8=BE=A8=E7=8E=87=E9=80=82=E5=BA=94?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/client/utils.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/client/utils.rs b/src-tauri/src/client/utils.rs index 883f506d..3041f8b0 100644 --- a/src-tauri/src/client/utils.rs +++ b/src-tauri/src/client/utils.rs @@ -1,6 +1,6 @@ //! @file src/client/utils.rs //! @desc 结合屏幕分辨率获取窗口大小 -//! @since Beta v0.5.2 +//! @since Beta v0.5.5 use tauri::{AppHandle, Manager, Monitor}; @@ -14,9 +14,10 @@ pub fn get_window_size2(monitor: Monitor, width: f64, height: f64) -> (f64, f64) let monitor_size = monitor.size(); let monitor_width = monitor_size.width as f64; let monitor_height = monitor_size.height as f64; + let monitor_scale = monitor.scale_factor(); let width_scale = monitor_width / 1920.0; let height_scale = monitor_height / 1080.0; - let get_width = (width * width_scale).round(); - let get_height = (height * height_scale).round(); + let get_width = (width * width_scale / monitor_scale).round(); + let get_height = (height * height_scale / monitor_scale).round(); (get_width, get_height) }