mirror of
https://github.com/kunkunsh/kunkun.git
synced 2025-04-11 17:29:44 +00:00

* chore: add tauri-plugin-user-input submodule * feat: add key display extension There is delay, affecting key combination from being detected. I guess it's due to rdev grab, I have to remove grab and use listen directly. * chore: upgrade tauri-plugin-user-input submodule The user-input plugin improves mac's listen feature * chore: upgrade user-input submodule * fix: a platform-specific window command * ci: add libxdo-dev dep for ubuntu * chore: update tauri-plugin-user-input submodule to latest commit 5766c04
54 lines
2.0 KiB
Rust
54 lines
2.0 KiB
Rust
use tauri::{is_dev, App, AppHandle, LogicalSize, Manager, Runtime, Size, WebviewWindow, Window};
|
|
|
|
#[cfg(target_os = "macos")]
|
|
use cocoa::appkit::{NSWindow, NSWindowButton, NSWindowStyleMask, NSWindowTitleVisibility};
|
|
|
|
#[cfg(target_os = "macos")]
|
|
use objc::runtime::YES;
|
|
|
|
pub trait WindowExt {
|
|
#[cfg(target_os = "macos")]
|
|
fn set_transparent_titlebar(&self, title_transparent: bool, remove_toolbar: bool);
|
|
}
|
|
|
|
impl<R: Runtime> WindowExt for WebviewWindow<R> {
|
|
#[cfg(target_os = "macos")]
|
|
fn set_transparent_titlebar(&self, title_transparent: bool, remove_tool_bar: bool) {
|
|
use objc::{msg_send, sel, sel_impl};
|
|
|
|
unsafe {
|
|
let id = self.ns_window().unwrap() as cocoa::base::id;
|
|
NSWindow::setTitlebarAppearsTransparent_(id, cocoa::base::YES);
|
|
let mut style_mask = id.styleMask();
|
|
style_mask.set(
|
|
NSWindowStyleMask::NSFullSizeContentViewWindowMask,
|
|
title_transparent,
|
|
);
|
|
|
|
id.setStyleMask_(style_mask);
|
|
|
|
if remove_tool_bar {
|
|
let close_button = id.standardWindowButton_(NSWindowButton::NSWindowCloseButton);
|
|
let _: () = msg_send![close_button, setHidden: YES];
|
|
let min_button =
|
|
id.standardWindowButton_(NSWindowButton::NSWindowMiniaturizeButton);
|
|
let _: () = msg_send![min_button, setHidden: YES];
|
|
let zoom_button = id.standardWindowButton_(NSWindowButton::NSWindowZoomButton);
|
|
let _: () = msg_send![zoom_button, setHidden: YES];
|
|
}
|
|
|
|
id.setTitleVisibility_(if title_transparent {
|
|
NSWindowTitleVisibility::NSWindowTitleHidden
|
|
} else {
|
|
NSWindowTitleVisibility::NSWindowTitleVisible
|
|
});
|
|
|
|
id.setTitlebarAppearsTransparent_(if title_transparent {
|
|
cocoa::base::YES
|
|
} else {
|
|
cocoa::base::NO
|
|
});
|
|
}
|
|
}
|
|
}
|