Skip to content

Commit b5fa454

Browse files
remove extra window decorations from macos tray window (#897)
1 parent cd1d1a8 commit b5fa454

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

src-tauri/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ block2 = "0.6"
129129
objc2 = "0.6"
130130
objc2-foundation = "0.3"
131131
objc2-network-extension = "0.3"
132+
objc = "0.2"
132133

133134
[target.'cfg(unix)'.dependencies]
134135
nix = { version = "0.31", features = ["user", "fs"] }

src-tauri/src/window_manager/macos.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ use crate::window_manager::{WindowManager, NEW_UI_WINDOW_ID, OLD_UI_WINDOW_ID};
1010

1111
#[cfg(target_os = "macos")]
1212
use cocoa::{
13-
appkit::{NSView, NSWindow, NSWindowStyleMask},
13+
appkit::{NSView, NSWindow, NSWindowButton, NSWindowStyleMask, NSWindowTitleVisibility},
1414
base::id,
1515
};
1616

17+
#[cfg(target_os = "macos")]
18+
use objc::{msg_send, sel, sel_impl};
19+
1720
#[cfg(target_os = "macos")]
1821
pub fn enable_rounded_corners<R: Runtime>(window: WebviewWindow<R>) -> Result<(), String> {
1922
window
@@ -33,6 +36,26 @@ pub fn enable_rounded_corners<R: Runtime>(window: WebviewWindow<R>) -> Result<()
3336
ns_window.setStyleMask_(style_mask);
3437
ns_window.setTitlebarAppearsTransparent_(cocoa::base::YES);
3538

39+
// Hide the window title
40+
ns_window.setTitleVisibility_(NSWindowTitleVisibility::NSWindowTitleHidden);
41+
42+
// Hide the standard window buttons (close, minimize, zoom)
43+
let close_button =
44+
ns_window.standardWindowButton_(NSWindowButton::NSWindowCloseButton);
45+
if !close_button.is_null() {
46+
let _: () = msg_send![close_button, setHidden: cocoa::base::YES];
47+
}
48+
let miniaturize_button =
49+
ns_window.standardWindowButton_(NSWindowButton::NSWindowMiniaturizeButton);
50+
if !miniaturize_button.is_null() {
51+
let _: () = msg_send![miniaturize_button, setHidden: cocoa::base::YES];
52+
}
53+
let zoom_button =
54+
ns_window.standardWindowButton_(NSWindowButton::NSWindowZoomButton);
55+
if !zoom_button.is_null() {
56+
let _: () = msg_send![zoom_button, setHidden: cocoa::base::YES];
57+
}
58+
3659
let content_view = ns_window.contentView();
3760
content_view.setWantsLayer(cocoa::base::YES);
3861
}

0 commit comments

Comments
 (0)