extern "C" fn window_did_fail_to_enter_fullscreen(this: &Object, _: Sel, _: id) {
    trace!("Triggered `windowDidFailToEnterFullscreen:`");
    with_state(this, |state| {
        if state.initial_fullscreen {
            let _: () = unsafe {
                msg_send![*state.ns_window,
                    performSelector:sel!(toggleFullScreen:)
                    withObject:nil
                    afterDelay: 0.5
                ]
            };
        } else {
            state.with_window(|window| window.restore_state_from_fullscreen());
        }
    });
    trace!("Completed `windowDidFailToEnterFullscreen:`");
}
/// Invoked when fail to enter fullscreen
///
/// When this window launch from a fullscreen app (e.g. launch from VS Code
/// terminal), it creates a new virtual destkop and a transition animation.
/// This animation takes one second and cannot be disable without
/// elevated privileges. In this animation time, all toggleFullscreen events
/// will be failed. In this implementation, we will try again by using
/// performSelector:withObject:afterDelay: until window_did_enter_fullscreen.
/// It should be fine as we only do this at initialzation (i.e with_fullscreen
/// was set).
///
/// From Apple doc:
/// In some cases, the transition to enter full-screen mode can fail,
/// due to being in the midst of handling some other animation or user gesture.
/// This method indicates that there was an error, and you should clean up any
/// work you may have done to prepare to enter full-screen mode.
Invoked when fail to enter fullscreen
When this window launch from a fullscreen app , it creates a new virtual destkop and a transition animation.
This animation takes one second and cannot be disable without
elevated privileges. In this animation time, all toggleFullscreen events
will be failed. In this implementation, we will try again by using
performSelector:withObject:afterDelay: until window_did_enter_fullscreen.
It should be fine as we only do this at initialzation .

From Apple doc:
In some cases, the transition to enter full-screen mode can fail,
due to being in the midst of handling some other animation or user gesture.
This method indicates that there was an error, and you should clean up any
work you may have done to prepare to enter full-screen mode.
Invoked when fail to enter fullscreen When this window launch from a fullscreen app it creates a new virtual destkop and a transition animation . This animation takes one second and cannot be disable without elevated privileges . In this animation time all toggleFullscreen events will be failed . In this implementation we will try again by using performSelector : withObject : afterDelay : until window_did_enter_fullscreen . It should be fine as we only do this at initialzation . From Apple doc : In some cases the transition to enter full - screen mode can fail due to being in the midst of handling some other animation or user gesture . This method indicates that there was an error and you should clean up any work you may have done to prepare to enter full - screen mode .
extern "C" fn window_did_fail_to_enter_fullscreen(this: &Object, _: Sel, _: id) {
    trace!("Triggered `windowDidFailToEnterFullscreen:`");
    with_state(this, |state| {
        if state.initial_fullscreen {
            let _: () = unsafe {
                msg_send![*state.ns_window,
                    performSelector:sel!(toggleFullScreen:)
                    withObject:nil
                    afterDelay: 0.5
                ]
            };
        } else {
            state.with_window(|window| window.restore_state_from_fullscreen());
        }
    });
    trace!("Completed `windowDidFailToEnterFullscreen:`");
}
extern " " fn window_did_fail_to_enter_fullscreen ( this : & Object , _ : Sel , _ : id ) { trace ! ( " " ) ; with_state ( this , | state | { if state . initial_fullscreen { let _ : ( ) = unsafe { msg_send ! [ state ns_window performSelector sel ( toggleFullScreen ) withObject nil afterDelay 0.5 ] } ; } else { state . with_window ( | window | window . restore_state_from_fullscreen ( ) ) ; } } ) ; trace ! ( " " ) ; }
Invoked when fail to enter fullscreen
When this window launch from a fullscreen app (e.g.
Invoked when fail to enter fullscreen When this window launch from a fullscreen app ( e . g .
this
id
this
id