Skip to content

Commit

Permalink
Update raw-window-handle to 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
17cupsofcoffee committed Dec 19, 2021
1 parent 8f056ad commit 9dab73d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pollster = "0.2.4"
env_logger = "0.9.0"

[dependencies.raw-window-handle]
version = "0.3.3"
version = "0.4.2"
optional = true

[features]
Expand Down
75 changes: 41 additions & 34 deletions src/sdl2/raw_window_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ unsafe impl HasRawWindowHandle for Window {
match wm_info.subsystem {
#[cfg(target_os = "windows")]
SDL_SYSWM_WINDOWS => {
use self::raw_window_handle::windows::WindowsHandle;
RawWindowHandle::Windows(WindowsHandle {
hwnd: unsafe { wm_info.info.win }.window as *mut libc::c_void,
..WindowsHandle::empty()
})
use self::raw_window_handle::Win32Handle;

let mut handle = Win32Handle::empty();
handle.hwnd = unsafe { wm_info.info.win }.window as *mut libc::c_void;

RawWindowHandle::Win32(handle)
}
#[cfg(any(
target_os = "linux",
Expand All @@ -36,12 +37,13 @@ unsafe impl HasRawWindowHandle for Window {
target_os = "openbsd",
))]
SDL_SYSWM_WAYLAND => {
use self::raw_window_handle::unix::WaylandHandle;
RawWindowHandle::Wayland(WaylandHandle {
surface: unsafe { wm_info.info.wl }.surface as *mut libc::c_void,
display: unsafe { wm_info.info.wl }.display as *mut libc::c_void,
..WaylandHandle::empty()
})
use self::raw_window_handle::WaylandHandle;

let mut handle = WaylandHandle::empty();
handle.surface = unsafe { wm_info.info.wl }.surface as *mut libc::c_void;
handle.display = unsafe { wm_info.info.wl }.display as *mut libc::c_void;

RawWindowHandle::Wayland(handle)
}
#[cfg(any(
target_os = "linux",
Expand All @@ -51,38 +53,43 @@ unsafe impl HasRawWindowHandle for Window {
target_os = "openbsd",
))]
SDL_SYSWM_X11 => {
use self::raw_window_handle::unix::XlibHandle;
RawWindowHandle::Xlib(XlibHandle {
window: unsafe { wm_info.info.x11 }.window,
display: unsafe { wm_info.info.x11 }.display as *mut libc::c_void,
..XlibHandle::empty()
})
use self::raw_window_handle::XlibHandle;

let mut handle = XlibHandle::empty();
handle.window = unsafe { wm_info.info.x11 }.window;
handle.display = unsafe { wm_info.info.x11 }.display as *mut libc::c_void;

RawWindowHandle::Xlib(handle)
}
#[cfg(target_os = "macos")]
SDL_SYSWM_COCOA => {
use self::raw_window_handle::macos::MacOSHandle;
RawWindowHandle::MacOS(MacOSHandle {
ns_window: unsafe { wm_info.info.cocoa }.window as *mut libc::c_void,
ns_view: 0 as *mut libc::c_void, // consumer of RawWindowHandle should determine this
..MacOSHandle::empty()
})
use self::raw_window_handle::AppKitHandle;

let mut handle = AppKitHandle::empty();
handle.ns_window = unsafe { wm_info.info.cocoa }.window as *mut libc::c_void;
handle.ns_view = 0 as *mut libc::c_void; // consumer of RawWindowHandle should determine this

RawWindowHandle::AppKit(handle)
}
#[cfg(any(target_os = "ios"))]
SDL_SYSWM_UIKIT => {
use self::raw_window_handle::ios::IOSHandle;
RawWindowHandle::IOS(IOSHandle {
ui_window: unsafe { wm_info.info.uikit }.window as *mut libc::c_void,
ui_view: 0 as *mut libc::c_void, // consumer of RawWindowHandle should determine this
..IOSHandle::empty()
})
use self::raw_window_handle::UiKitHandle;

let mut handle = UiKitHandle::empty();
handle.ui_window = unsafe { wm_info.info.uikit }.window as *mut libc::c_void;
handle.ui_view = 0 as *mut libc::c_void; // consumer of RawWindowHandle should determine this

RawWindowHandle::UiKit(handle)
}
#[cfg(any(target_os = "android"))]
SDL_SYSWM_ANDROID => {
use self::raw_window_handle::android::AndroidHandle;
RawWindowHandle::Android(AndroidHandle {
a_native_window: unsafe { wm_info.info.android }.window as *mut libc::c_void,
..AndroidHandle::empty()
})
use self::raw_window_handle::AndroidNdkHandle;

let mut handle = AndroidNdkHandle::empty();
handle.a_native_window =
unsafe { wm_info.info.android }.window as *mut libc::c_void;

RawWindowHandle::AndroidNdk(handle)
}
x => {
let window_system = match x {
Expand Down

0 comments on commit 9dab73d

Please sign in to comment.