pub unsafe fn toggle_full_screen_async(
    ns_window: id,
    ns_view: id,
    not_fullscreen: bool,
    shared_state: Weak<Mutex<SharedState>>,
) {
    let ns_window = MainThreadSafe(ns_window);
    let ns_view = MainThreadSafe(ns_view);
    let shared_state = MainThreadSafe(shared_state);
    Queue::main().exec_async(move || {
        // `toggleFullScreen` doesn't work if the `StyleMask` is none, so we
        // set a normal style temporarily. The previous state will be
        // restored in `WindowDelegate::window_did_exit_fullscreen`.
        if not_fullscreen {
            let curr_mask = ns_window.styleMask();
            let required =
                NSWindowStyleMask::NSTitledWindowMask | NSWindowStyleMask::NSResizableWindowMask;
            if !curr_mask.contains(required) {
                set_style_mask(*ns_window, *ns_view, required);
                if let Some(shared_state) = shared_state.upgrade() {
                    log::trace!("Locked shared state in `toggle_full_screen_callback`");

                    let mut shared_state_lock = shared_state.lock();
                    (*shared_state_lock).saved_style = Some(curr_mask);

                    log::trace!("Unlocked shared state in `toggle_full_screen_callback`");
                }
            }
        }
        // Window level must be restored from `CGShieldingWindowLevel()
        // + 1` back to normal in order for `toggleFullScreen` to do
        // anything
        ns_window.setLevel_(0);
        ns_window.toggleFullScreen_(nil);
    });
}
// `toggleFullScreen` is thread-safe, but our additional logic to account for
// window styles isn't.
`toggleFullScreen` is thread-safe, but our additional logic to account for
window styles isn't.
` toggleFullScreen ` is thread - safe but our additional logic to account for window styles isn ' t .
pub unsafe fn toggle_full_screen_async(
    ns_window: id,
    ns_view: id,
    not_fullscreen: bool,
    shared_state: Weak<Mutex<SharedState>>,
) {
    let ns_window = MainThreadSafe(ns_window);
    let ns_view = MainThreadSafe(ns_view);
    let shared_state = MainThreadSafe(shared_state);
    Queue::main().exec_async(move || {
        // `toggleFullScreen` doesn't work if the `StyleMask` is none, so we
        // set a normal style temporarily. The previous state will be
        // restored in `WindowDelegate::window_did_exit_fullscreen`.
        if not_fullscreen {
            let curr_mask = ns_window.styleMask();
            let required =
                NSWindowStyleMask::NSTitledWindowMask | NSWindowStyleMask::NSResizableWindowMask;
            if !curr_mask.contains(required) {
                set_style_mask(*ns_window, *ns_view, required);
                if let Some(shared_state) = shared_state.upgrade() {
                    log::trace!("Locked shared state in `toggle_full_screen_callback`");
                    let mut shared_state_lock = shared_state.lock();
                    (*shared_state_lock).saved_style = Some(curr_mask);
                    log::trace!("Unlocked shared state in `toggle_full_screen_callback`");
                }
            }
        }
        // Window level must be restored from `CGShieldingWindowLevel()
        // + 1` back to normal in order for `toggleFullScreen` to do
        // anything
        ns_window.setLevel_(0);
        ns_window.toggleFullScreen_(nil);
    });
}
pub unsafe fn toggle_full_screen_async ( ns_window : id , ns_view : id , not_fullscreen : bool , shared_state : Weak < Mutex < SharedState > > , ) { let ns_window = MainThreadSafe ( ns_window ) ; let ns_view = MainThreadSafe ( ns_view ) ; let shared_state = MainThreadSafe ( shared_state ) ; Queue :: main ( ) . exec_async ( move | | { // `toggleFullScreen` doesn't work if the `StyleMask` is none, so we // set a normal style temporarily. The previous state will be // restored in `WindowDelegate::window_did_exit_fullscreen`. if not_fullscreen { let curr_mask = ns_window . styleMask ( ) ; let required = NSWindowStyleMask :: NSTitledWindowMask | NSWindowStyleMask :: NSResizableWindowMask ; if ! curr_mask . contains ( required ) { set_style_mask ( * ns_window , * ns_view , required ) ; if let Some ( shared_state ) = shared_state . upgrade ( ) { log :: trace ! ( " " ) ; let mut shared_state_lock = shared_state . lock ( ) ; ( * shared_state_lock ) . saved_style = Some ( curr_mask ) ; log :: trace ! ( " " ) ; } } } // Window level must be restored from `CGShieldingWindowLevel() // + 1` back to normal in order for `toggleFullScreen` to do // anything ns_window . setLevel_ ( 0 ) ; ns_window . toggleFullScreen_ ( nil ) ; } ) ; }
`toggleFullScreen` is thread-safe, but our additional logic to account for
window styles isn't.
` toggleFullScreen ` is thread - safe but our additional logic to account for window styles isn ' t .
ns_window
id
ns_view
id
not_fullscreen
bool
shared_state
Weak<Mutex<SharedState>>
ns_window
id
ns_view
id
not_fullscreen
bool
shared_state
Weak<Mutex<SharedState>>