fix mac decorations

This commit is contained in:
Gregory Schier
2024-01-14 17:22:31 -08:00
parent 2ef6885949
commit 3e9a89a4c9
2 changed files with 26 additions and 18 deletions
+7 -3
View File
@@ -865,7 +865,6 @@ fn create_window(handle: &AppHandle<Wry>, url: Option<&str>) -> Window<Wry> {
100.0 + random::<f64>() * 30.0, 100.0 + random::<f64>() * 30.0,
100.0 + random::<f64>() * 30.0, 100.0 + random::<f64>() * 30.0,
) )
.decorations(false) // Doesn't seem to work from Rust, here, so we do it in JS
.title(handle.package_info().name.to_string()); .title(handle.package_info().name.to_string());
// Add macOS-only things // Add macOS-only things
@@ -874,11 +873,16 @@ fn create_window(handle: &AppHandle<Wry>, url: Option<&str>) -> Window<Wry> {
win_builder = win_builder win_builder = win_builder
.menu(app_menu) .menu(app_menu)
.hidden_title(true) .hidden_title(true)
.decoratons(true)
.transparent(false)
.title_bar_style(TitleBarStyle::Overlay); .title_bar_style(TitleBarStyle::Overlay);
} }
// Add non-MacOS things
#[cfg(not(target_os = "macos"))]
{
// Doesn't seem to work from Rust, here, so we do it in JS
win_builder = win_builder.decorations(false);
}
let win = win_builder.build().expect("failed to build window"); let win = win_builder.build().expect("failed to build window");
// Tauri doesn't support shadows when hiding decorations, so we add our own // Tauri doesn't support shadows when hiding decorations, so we add our own
+5 -1
View File
@@ -7,10 +7,14 @@ import './main.css';
import { getSettings } from './lib/store'; import { getSettings } from './lib/store';
import type { Appearance } from './lib/theme/window'; import type { Appearance } from './lib/theme/window';
import { setAppearanceOnDocument } from './lib/theme/window'; import { setAppearanceOnDocument } from './lib/theme/window';
import {appWindow} from "@tauri-apps/api/window"; import { appWindow } from '@tauri-apps/api/window';
import { type } from '@tauri-apps/api/os';
// Hide decorations here because it doesn't work in Rust for some reason (bug?) // Hide decorations here because it doesn't work in Rust for some reason (bug?)
const osType = await type();
if (osType !== 'Darwin') {
await appWindow.setDecorations(false); await appWindow.setDecorations(false);
}
await attachConsole(); await attachConsole();
await maybeRestorePathname(); await maybeRestorePathname();