/
githubmirror
/
tauri
Обзор
Документация
Войти
/
githubmirror
/
tauri
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
crates/tauri-runtime-wry/src/window/macos.rs
43 строки
1 KB
Tony
chore(deps): update `objc2-*` crates to 0.3.2 (#15790)
28 июл 2026, 12:01
Не верифицирован
28 июл 2026, 12:01
872428f
Код
Авторство
О чём код?
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT use objc2::MainThreadMarker; use objc2_app_kit::{NSBackingStoreType, NSWindow, NSWindowStyleMask}; use tao::platform::macos::WindowExtMacOS; impl super::WindowExt for tao::window::Window { // based on electron implementation // https://github.com/electron/electron/blob/15db63e26df3e3d59ce6281f030624f746518511/shell/browser/native_window_mac.mm#L474 fn set_enabled(&self, enabled: bool) { let ns_window: &NSWindow = unsafe { &*self.ns_window().cast() }; if !enabled { let frame = ns_window.frame(); let mtm = MainThreadMarker::new() .expect("`Window::set_enabled` can only be called on the main thread"); let sheet = unsafe { NSWindow::initWithContentRect_styleMask_backing_defer( mtm.alloc(), frame, NSWindowStyleMask::Titled, NSBackingStoreType::Buffered, false, ) }; sheet.setAlphaValue(0.5); ns_window.beginSheet_completionHandler(&sheet, None); } else if let Some(attached) = ns_window.attachedSheet() { ns_window.endSheet(&attached); } } fn is_enabled(&self) -> bool { let ns_window: &NSWindow = unsafe { &*self.ns_window().cast() }; ns_window.attachedSheet().is_none() } fn center(&self) { let ns_window: &NSWindow = unsafe { &*self.ns_window().cast() }; ns_window.center(); } }