adjust windows scaling settings, fixes #194

This commit is contained in:
FTCHD
2026-08-15 16:37:23 +03:00
parent a0c4525703
commit f3fd4865fe
4 changed files with 32 additions and 11 deletions
+1 -2
View File
@@ -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
+11 -3
View File
@@ -45,9 +45,17 @@ fn create_toolbar_window(app_handle: &AppHandle) -> Result<WebviewWindow, tauri:
let logical_size = physical_size.to_logical::<f64>(scale_factor);
let logical_position = physical_position.to_logical::<f64>(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<WebviewWindow, tauri:
tauri::WebviewUrl::App("/toolbar".into()),
)
.title(TOOLBAR_WINDOW_LABEL)
.inner_size(TOOLBAR_WIDTH, TOOLBAR_HEIGHT)
.inner_size(toolbar_width, toolbar_height)
.position(pos_x, pos_y)
.resizable(false)
.decorations(false)
+19 -5
View File
@@ -157,16 +157,30 @@ pub async fn open_window(
return Ok(());
}
let os = std::env::consts::OS;
let default_height = if os == "windows" { 755.0 } else { 725.0 };
let width = width.unwrap_or(840.0);
let height = height.unwrap_or(default_height);
let height = height.unwrap_or(725.0);
#[cfg(target_os = "windows")]
{
let monitor = match app_handle.primary_monitor().map_err(|e| e.to_string())? {
Some(monitor) => 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)
+1 -1
View File
@@ -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();