use crate::{c_uint, c_ulong, c_void, stdinc::*, version::*, video::*};
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct SDL_SYSWM_TYPE(pub i32);
#[allow(missing_docs)]
pub const SDL_SYSWM_UNKNOWN: SDL_SYSWM_TYPE = SDL_SYSWM_TYPE(0);
#[allow(missing_docs)]
pub const SDL_SYSWM_WINDOWS: SDL_SYSWM_TYPE = SDL_SYSWM_TYPE(1);
#[allow(missing_docs)]
pub const SDL_SYSWM_X11: SDL_SYSWM_TYPE = SDL_SYSWM_TYPE(2);
#[allow(missing_docs)]
pub const SDL_SYSWM_DIRECTFB: SDL_SYSWM_TYPE = SDL_SYSWM_TYPE(3);
#[allow(missing_docs)]
pub const SDL_SYSWM_COCOA: SDL_SYSWM_TYPE = SDL_SYSWM_TYPE(4);
#[allow(missing_docs)]
pub const SDL_SYSWM_UIKIT: SDL_SYSWM_TYPE = SDL_SYSWM_TYPE(5);
#[allow(missing_docs)]
pub const SDL_SYSWM_WAYLAND: SDL_SYSWM_TYPE = SDL_SYSWM_TYPE(6);
#[allow(missing_docs)]
pub const SDL_SYSWM_MIR: SDL_SYSWM_TYPE = SDL_SYSWM_TYPE(7);
#[allow(missing_docs)]
pub const SDL_SYSWM_WINRT: SDL_SYSWM_TYPE = SDL_SYSWM_TYPE(8);
#[allow(missing_docs)]
pub const SDL_SYSWM_ANDROID: SDL_SYSWM_TYPE = SDL_SYSWM_TYPE(9);
#[allow(missing_docs)]
pub const SDL_SYSWM_VIVANTE: SDL_SYSWM_TYPE = SDL_SYSWM_TYPE(10);
#[allow(missing_docs)]
pub const SDL_SYSWM_OS2: SDL_SYSWM_TYPE = SDL_SYSWM_TYPE(11);
#[allow(missing_docs)]
pub const SDL_SYSWM_HAIKU: SDL_SYSWM_TYPE = SDL_SYSWM_TYPE(12);
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_SysWMinfo_windows {
pub window: *mut c_void,
pub hdc: *mut c_void,
pub hinstance: *mut c_void,
}
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_SysWMinfo_winrt {
pub window: *mut c_void,
}
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_SysWMinfo_x11 {
pub display: *mut c_void,
pub window: c_ulong,
}
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_SysWMinfo_directfb {
pub dfb: *mut c_void,
pub window: *mut c_void,
pub surface: *mut c_void,
}
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_SysWMinfo_cocoa {
pub window: *mut c_void,
}
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_SysWMinfo_uikit {
pub window: *mut c_void,
pub framebuffer: c_uint,
pub colorbuffer: c_uint,
pub resolveFramebuffer: c_uint,
}
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_SysWMinfo_wayland {
pub display: *mut c_void,
pub surface: *mut c_void,
pub shell_surface: *mut c_void,
}
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_SysWMinfo_android {
pub window: *mut c_void,
pub surface: *mut c_void,
}
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_SysWMinfo_vivante {
pub display: *mut c_void,
pub window: *mut c_void,
}
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(missing_docs)]
pub union SDL_SysWMinfo_union {
pub win: SDL_SysWMinfo_windows,
pub winrt: SDL_SysWMinfo_winrt,
pub x11: SDL_SysWMinfo_x11,
pub dfb: SDL_SysWMinfo_directfb,
pub cocoa: SDL_SysWMinfo_cocoa,
pub uikit: SDL_SysWMinfo_uikit,
pub wl: SDL_SysWMinfo_wayland,
pub android: SDL_SysWMinfo_android,
pub vivante: SDL_SysWMinfo_vivante,
pub dummy: [u8; 64],
}
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(missing_docs)]
pub struct SDL_SysWMinfo {
pub version: SDL_version,
pub subsystem: SDL_SYSWM_TYPE,
pub info: SDL_SysWMinfo_union,
}
impl Default for SDL_SysWMinfo {
#[inline]
#[must_use]
fn default() -> Self {
unsafe { core::mem::zeroed() }
}
}
#[cfg(feature = "raw-window-handle")]
#[cfg_attr(docs_rs, doc(cfg(feature = "raw-window-handle")))]
impl SDL_SysWMinfo {
pub unsafe fn try_into(self) -> Option<raw_window_handle::RawWindowHandle> {
use raw_window_handle::*;
Some(match self.subsystem {
SDL_SYSWM_WINDOWS => {
let mut win32_handle = Win32WindowHandle::empty();
win32_handle.hinstance = self.info.win.hinstance;
win32_handle.hwnd = self.info.win.window;
RawWindowHandle::Win32(win32_handle)
}
SDL_SYSWM_X11 => {
let mut xlib_handle = XlibWindowHandle::empty();
xlib_handle.window = self.info.x11.window;
RawWindowHandle::Xlib(xlib_handle)
}
SDL_SYSWM_COCOA => {
let mut appkit_handle = AppKitWindowHandle::empty();
appkit_handle.ns_window = self.info.cocoa.window;
RawWindowHandle::AppKit(appkit_handle)
}
SDL_SYSWM_UIKIT => {
let mut uikit_handle = UiKitWindowHandle::empty();
uikit_handle.ui_window = self.info.uikit.window;
RawWindowHandle::UiKit(uikit_handle)
}
SDL_SYSWM_WAYLAND => {
let mut wayland_handle = WaylandWindowHandle::empty();
wayland_handle.surface = self.info.wl.surface;
RawWindowHandle::Wayland(wayland_handle)
}
SDL_SYSWM_WINRT => {
let mut winrt_handle = WinRtWindowHandle::empty();
winrt_handle.core_window = self.info.winrt.window;
RawWindowHandle::WinRt(winrt_handle)
}
SDL_SYSWM_ANDROID => {
let mut android_handle = AndroidNdkWindowHandle::empty();
android_handle.a_native_window = self.info.android.window;
RawWindowHandle::AndroidNdk(android_handle)
}
SDL_SYSWM_MIR | SDL_SYSWM_VIVANTE | SDL_SYSWM_OS2 | SDL_SYSWM_HAIKU
| SDL_SYSWM_DIRECTFB => return None,
_ => return None,
})
}
}
extern "C" {
pub fn SDL_GetWindowWMInfo(
window: *mut SDL_Window, info: *mut SDL_SysWMinfo,
) -> SDL_bool;
}