//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplayfadereservationinvalidtoken?language=objc)
pub const kCGDisplayFadeReservationInvalidToken: c_uint = 0;
/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplayblendnormal?language=objc)
pub const kCGDisplayBlendNormal: c_float = 0.0;
/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgdisplayblendsolidcolor?language=objc)
pub const kCGDisplayBlendSolidColor: c_float = 1.0;
/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgmaxdisplayreservationinterval?language=objc)
pub const kCGMaxDisplayReservationInterval: CGDisplayReservationInterval = 15.0;
/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdisplayfadereservationtoken?language=objc)
pub type CGDisplayFadeReservationToken = u32;

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdisplayblendfraction?language=objc)
pub type CGDisplayBlendFraction = c_float;

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdisplayfadeinterval?language=objc)
pub type CGDisplayFadeInterval = c_float;

extern "C-unwind" {
    /// # Safety
    ///
    /// `config` must be a valid pointer or null.
    #[cfg(all(feature = "CGDisplayConfiguration", feature = "CGError"))]
    pub fn CGConfigureDisplayFadeEffect(
        config: CGDisplayConfigRef,
        fade_out_seconds: CGDisplayFadeInterval,
        fade_in_seconds: CGDisplayFadeInterval,
        fade_red: c_float,
        fade_green: c_float,
        fade_blue: c_float,
    ) -> CGError;
}

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdisplayreservationinterval?language=objc)
pub type CGDisplayReservationInterval = c_float;

extern "C-unwind" {
    /// # Safety
    ///
    /// `token` must be a valid pointer or null.
    #[cfg(feature = "CGError")]
    pub fn CGAcquireDisplayFadeReservation(
        seconds: CGDisplayReservationInterval,
        token: *mut CGDisplayFadeReservationToken,
    ) -> CGError;
}

#[cfg(feature = "CGError")]
#[inline]
pub extern "C-unwind" fn CGReleaseDisplayFadeReservation(
    token: CGDisplayFadeReservationToken,
) -> CGError {
    extern "C-unwind" {
        fn CGReleaseDisplayFadeReservation(token: CGDisplayFadeReservationToken) -> CGError;
    }
    unsafe { CGReleaseDisplayFadeReservation(token) }
}

#[cfg(all(feature = "CGError", feature = "libc"))]
#[inline]
pub extern "C-unwind" fn CGDisplayFade(
    token: CGDisplayFadeReservationToken,
    duration: CGDisplayFadeInterval,
    start_blend: CGDisplayBlendFraction,
    end_blend: CGDisplayBlendFraction,
    red_blend: c_float,
    green_blend: c_float,
    blue_blend: c_float,
    synchronous: bool,
) -> CGError {
    extern "C-unwind" {
        fn CGDisplayFade(
            token: CGDisplayFadeReservationToken,
            duration: CGDisplayFadeInterval,
            start_blend: CGDisplayBlendFraction,
            end_blend: CGDisplayBlendFraction,
            red_blend: c_float,
            green_blend: c_float,
            blue_blend: c_float,
            synchronous: libc::boolean_t,
        ) -> CGError;
    }
    unsafe {
        CGDisplayFade(
            token,
            duration,
            start_blend,
            end_blend,
            red_blend,
            green_blend,
            blue_blend,
            synchronous as _,
        )
    }
}

#[cfg(feature = "libc")]
#[deprecated = "No longer supported"]
#[inline]
pub extern "C-unwind" fn CGDisplayFadeOperationInProgress() -> bool {
    extern "C-unwind" {
        fn CGDisplayFadeOperationInProgress() -> libc::boolean_t;
    }
    let ret = unsafe { CGDisplayFadeOperationInProgress() };
    ret != 0
}
