From f3fd4865fed76529f7640c6d6f8af2053ede9cf4 Mon Sep 17 00:00:00 2001 From: FTCHD <144691102+FTCHD@users.noreply.github.com> Date: Sat, 15 Aug 2026 16:37:23 +0300 Subject: [PATCH] adjust windows scaling settings, fixes #194 --- lib/window.ts | 3 +-- src-tauri/common/shortcut.rs | 14 +++++++++++--- src-tauri/common/window.rs | 24 +++++++++++++++++++----- src-tauri/src/main.rs | 2 +- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/lib/window.ts b/lib/window.ts index 801a3f8..10ae90e 100644 --- a/lib/window.ts +++ b/lib/window.ts @@ -1,6 +1,5 @@ import { invoke } from '@tauri-apps/api/core' import { WebviewWindow } from '@tauri-apps/api/webviewWindow' -import { platform } from '@tauri-apps/plugin-os' export async function openFullWindow({ name, @@ -20,7 +19,7 @@ export async function openWindow({ name, url, width = 840, - height = platform() === 'windows' ? 755 : 725, + height = 725, }: { name: string url: string diff --git a/src-tauri/common/shortcut.rs b/src-tauri/common/shortcut.rs index 2e2b8c6..a7398f6 100644 --- a/src-tauri/common/shortcut.rs +++ b/src-tauri/common/shortcut.rs @@ -45,9 +45,17 @@ fn create_toolbar_window(app_handle: &AppHandle) -> Result(scale_factor); let logical_position = physical_position.to_logical::(scale_factor); + let toolbar_width = TOOLBAR_WIDTH / scale_factor; + let toolbar_height = TOOLBAR_HEIGHT / scale_factor; + // Calculate position in logical pixels, centered on the primary monitor - let pos_x = logical_position.x + (logical_size.width - TOOLBAR_WIDTH) / 2.0; - let pos_y = logical_position.y + logical_size.height / 4.0; + let pos_x = + logical_position.x + + (logical_size.width - toolbar_width) / 2.0; + + let pos_y = + logical_position.y + + logical_size.height / 4.0; WebviewWindowBuilder::new( app_handle, @@ -55,7 +63,7 @@ fn create_toolbar_window(app_handle: &AppHandle) -> Result monitor, + None => app_handle + .available_monitors() + .map_err(|e| e.to_string())? + .into_iter() + .next() + .ok_or("No monitors available")?, + }; + + let scale_factor = monitor.scale_factor(); + width = width / scale_factor; + height = height / scale_factor; + } let mut builder = WebviewWindowBuilder::new(&app_handle, &name, WebviewUrl::App(url.into())) .title(&name) .inner_size(width, height) - .min_inner_size(700.0, 700.0) + .min_inner_size(650.0, 500.0) .max_inner_size(1000.0, 1000.0) .resizable(true) .visible(false) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index f71ab3c..b7f56ed 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -48,7 +48,7 @@ fn main() { } #[cfg(target_os = "windows")] { - std::env::set_var("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "--ignore-gpu-blocklist"); + std::env::set_var("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "--ignore-gpu-blocklist --force-device-scale-factor=1 --disable-features=msWebOOUI"); } let _ = fix_path_env::fix(); app_lib::run();