From 7ddd05e98e801144e4398b36adadab59366307e4 Mon Sep 17 00:00:00 2001 From: sekwah Date: Thu, 16 Nov 2023 17:46:09 +0000 Subject: [PATCH] wip: scaling issues --- app/tauri/src/commands.rs | 16 +++++++++++++++- app/tauri/src/main.rs | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/tauri/src/commands.rs b/app/tauri/src/commands.rs index 053f9f93..e2a25018 100644 --- a/app/tauri/src/commands.rs +++ b/app/tauri/src/commands.rs @@ -25,6 +25,8 @@ impl WindowSize { static ORIGINAL_SIZE: Mutex> = Mutex::new(WindowSize::MIN); +static UNDECORATED_TITLE_SIZE: u32 = 40; + static HAS_DECORATIONS: Mutex = Mutex::new(true); static IS_COMPACT: Mutex = Mutex::new(false); @@ -69,6 +71,7 @@ fn set_fullscreen_break( "set_fullscreen_break! {} {}", should_fullscreen, always_on_top ); + try_set_always_on_top(always_on_top, &window); if should_fullscreen { try_set_native_titlebar(true, &window); @@ -127,7 +130,7 @@ fn set_window_fixed_size(size: LogicalSize, window: &tauri::Win + (if *decorations { 0 } else { - (10f64 * window.scale_factor().unwrap()).round() as u32 + WindowSize::COMPACT.height + UNDECORATED_TITLE_SIZE }); let new_size = LogicalSize { @@ -201,6 +204,17 @@ pub fn try_set_native_titlebar(use_native_titlebar: bool, window: &t ), } println!("set_native_titlebar! {}", use_native_titlebar); + + // Check DECORATIONS and IS_COMPACT + let decorated = HAS_DECORATIONS.lock().unwrap(); + let compact = IS_COMPACT.lock().unwrap(); + if !*decorated && *compact { + let size = LogicalSize { + width: WindowSize::COMPACT.width, + height: WindowSize::COMPACT.height + UNDECORATED_TITLE_SIZE, + }; + try_set_size(size, window); + } } /** diff --git a/app/tauri/src/main.rs b/app/tauri/src/main.rs index c29d42fe..68a4f3a5 100644 --- a/app/tauri/src/main.rs +++ b/app/tauri/src/main.rs @@ -15,10 +15,10 @@ mod global_shortcuts; mod system_tray; mod updater; +use crate::commands::try_set_native_titlebar; use commands::PomatezCommands; use global_shortcuts::{PomatezGlobalShortcutsRegister, PomatezGlobalShortcutsSetup}; use system_tray::PomatezTray; -use crate::commands::try_set_native_titlebar; fn main() { let app = tauri::Builder::default()