Skip to content

Commit

Permalink
fix(tauri): mac issue with setting size
Browse files Browse the repository at this point in the history
  • Loading branch information
sekwah41 committed Nov 14, 2023
1 parent dd49ba2 commit 3d1b91a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl WindowSize {
};
pub const COMPACT: LogicalSize<u32> = LogicalSize {
width: 340,
height: 90,
height: 60,
};
}

Expand Down Expand Up @@ -192,7 +192,7 @@ fn set_native_titlebar<R: Runtime>(use_native_titlebar: bool, window: tauri::Win
try_set_native_titlebar(use_native_titlebar, &window);
}

fn try_set_native_titlebar<R: Runtime>(use_native_titlebar: bool, window: &tauri::Window<R>) {
pub fn try_set_native_titlebar<R: Runtime>(use_native_titlebar: bool, window: &tauri::Window<R>) {
match window.set_decorations(use_native_titlebar) {
Ok(_) => (),
Err(e) => println!(
Expand Down
14 changes: 12 additions & 2 deletions app/tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mod updater;
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 All @@ -42,13 +43,22 @@ fn main() {
.build(tauri::generate_context!())
.expect("error while running tauri application");

#[cfg(desktop)]
app.run(|app_handle, e| match e {
RunEvent::Ready => {
#[cfg(desktop)]
app_handle.register_global_shortcuts();

let window = app_handle.get_window("main").unwrap();

// There is a bug on mac where the size is not properly respected initially, though this seems to fix it.
#[cfg(target_os = "macos")]
{
try_set_native_titlebar(false, &window);
try_set_native_titlebar(true, &window);
}

#[cfg(debug_assertions)]
app_handle.get_window("main").unwrap().open_devtools();
window.open_devtools();

println!("Pomatez is ready");
}
Expand Down

0 comments on commit 3d1b91a

Please sign in to comment.