Skip to content

Commit

Permalink
wip: scaling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sekwah41 committed Nov 16, 2023
1 parent 3d1b91a commit 7ddd05e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion app/tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ impl WindowSize {

static ORIGINAL_SIZE: Mutex<LogicalSize<u32>> = Mutex::new(WindowSize::MIN);

static UNDECORATED_TITLE_SIZE: u32 = 40;

static HAS_DECORATIONS: Mutex<bool> = Mutex::new(true);
static IS_COMPACT: Mutex<bool> = Mutex::new(false);

Expand Down Expand Up @@ -69,6 +71,7 @@ fn set_fullscreen_break<R: Runtime>(
"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);
Expand Down Expand Up @@ -127,7 +130,7 @@ fn set_window_fixed_size<R: Runtime>(size: LogicalSize<u32>, 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 {
Expand Down Expand Up @@ -201,6 +204,17 @@ pub fn try_set_native_titlebar<R: Runtime>(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);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 7ddd05e

Please sign in to comment.