Merge pull request #242 from lummax/fix-xcb-xlib-surface-create-info

vk-sys/vulkano{-win}: correct type of native window
This commit is contained in:
tomaka 2016-09-01 18:45:20 +02:00 committed by GitHub
commit 42276b30fc
3 changed files with 12 additions and 10 deletions

View File

@ -17,6 +17,7 @@ use std::ffi::CString;
use std::fmt;
use std::os::raw::c_char;
use std::os::raw::c_void;
use std::os::raw::c_ulong;
pub type Flags = u32;
pub type Bool32 = u32;
@ -2297,7 +2298,7 @@ pub struct XlibSurfaceCreateInfoKHR {
pub pNext: *const c_void,
pub flags: XlibSurfaceCreateFlagsKHR,
pub dpy: *mut c_void,
pub window: *const c_void,
pub window: c_ulong,
}
pub type XcbSurfaceCreateFlagsKHR = Flags;
@ -2308,7 +2309,7 @@ pub struct XcbSurfaceCreateInfoKHR {
pub pNext: *const c_void,
pub flags: XcbSurfaceCreateFlagsKHR,
pub connection: *const c_void,
pub window: *const c_void,
pub window: u32,
}

View File

@ -133,11 +133,11 @@ unsafe fn winit_to_surface(instance: &Arc<Instance>,
if instance.loaded_extensions().khr_xlib_surface {
Surface::from_xlib(instance,
win.get_xlib_display().unwrap(),
win.get_xlib_window().unwrap())
win.get_xlib_window().unwrap() as _)
} else {
Surface::from_xcb(instance,
win.get_xcb_connection().unwrap(),
win.get_xlib_window().unwrap())
win.get_xlib_window().unwrap() as _)
}
}
}

View File

@ -10,6 +10,7 @@
use std::error;
use std::fmt;
use std::mem;
use std::os::raw::c_ulong;
use std::ptr;
use std::sync::Arc;
use std::sync::atomic::AtomicBool;
@ -142,7 +143,7 @@ impl Surface {
///
/// The caller must ensure that the `connection` and the `window` are both correct and stay
/// alive for the entire lifetime of the surface.
pub unsafe fn from_xcb<C, W>(instance: &Arc<Instance>, connection: *const C, window: *const W)
pub unsafe fn from_xcb<C>(instance: &Arc<Instance>, connection: *const C, window: u32)
-> Result<Arc<Surface>, SurfaceCreationError>
{
let vk = instance.pointers();
@ -157,7 +158,7 @@ impl Surface {
pNext: ptr::null(),
flags: 0, // reserved
connection: connection as *mut _,
window: window as *mut _,
window: window,
};
let mut output = mem::uninitialized();
@ -181,7 +182,7 @@ impl Surface {
///
/// The caller must ensure that the `display` and the `window` are both correct and stay
/// alive for the entire lifetime of the surface.
pub unsafe fn from_xlib<D, W>(instance: &Arc<Instance>, display: *const D, window: *const W)
pub unsafe fn from_xlib<D>(instance: &Arc<Instance>, display: *const D, window: c_ulong)
-> Result<Arc<Surface>, SurfaceCreationError>
{
let vk = instance.pointers();
@ -196,7 +197,7 @@ impl Surface {
pNext: ptr::null(),
flags: 0, // reserved
dpy: display as *mut _,
window: window as *mut _,
window: window,
};
let mut output = mem::uninitialized();
@ -913,7 +914,7 @@ mod tests {
#[test]
fn khr_xcb_surface_ext_missing() {
let instance = instance!();
match unsafe { Surface::from_xcb(&instance, ptr::null::<u8>(), ptr::null::<u8>()) } {
match unsafe { Surface::from_xcb(&instance, ptr::null::<u8>(), 0) } {
Err(SurfaceCreationError::MissingExtension { .. }) => (),
_ => panic!()
}
@ -922,7 +923,7 @@ mod tests {
#[test]
fn khr_xlib_surface_ext_missing() {
let instance = instance!();
match unsafe { Surface::from_xlib(&instance, ptr::null::<u8>(), ptr::null::<u8>()) } {
match unsafe { Surface::from_xlib(&instance, ptr::null::<u8>(), 0) } {
Err(SurfaceCreationError::MissingExtension { .. }) => (),
_ => panic!()
}