linux raw-window-handle 0.6.0
This commit is contained in:
parent
fab0f5210e
commit
7df00dba07
|
@ -46,14 +46,13 @@ impl WindowHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl HasRawWindowHandle for WindowHandle {
|
unsafe impl HasRawWindowHandle for WindowHandle {
|
||||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
fn raw_window_handle(&self) -> Result<RawWindowHandle, raw_window_handle::HandleError> {
|
||||||
if let Some(raw_window_handle) = self.raw_window_handle {
|
if let Some(raw_window_handle) = self.raw_window_handle {
|
||||||
if self.is_open.load(Ordering::Relaxed) {
|
if self.is_open.load(Ordering::Relaxed) {
|
||||||
return raw_window_handle;
|
return Ok(raw_window_handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Err(raw_window_handle::HandleError::Unavailable)
|
||||||
RawWindowHandle::Xlib(XlibWindowHandle::empty())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,8 +125,8 @@ impl<'a> Window<'a> {
|
||||||
{
|
{
|
||||||
// Convert parent into something that X understands
|
// Convert parent into something that X understands
|
||||||
let parent_id = match parent.raw_window_handle() {
|
let parent_id = match parent.raw_window_handle() {
|
||||||
RawWindowHandle::Xlib(h) => h.window as u32,
|
Ok(RawWindowHandle::Xlib(h)) => h.window as u32,
|
||||||
RawWindowHandle::Xcb(h) => h.window,
|
Ok(RawWindowHandle::Xcb(h)) => h.window.get(),
|
||||||
h => panic!("unsupported parent handle type {:?}", h),
|
h => panic!("unsupported parent handle type {:?}", h),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -341,7 +340,9 @@ impl<'a> Window<'a> {
|
||||||
// the correct dpi scaling.
|
// the correct dpi scaling.
|
||||||
handler.on_event(&mut window, Event::Window(WindowEvent::Resized(window_info)));
|
handler.on_event(&mut window, Event::Window(WindowEvent::Resized(window_info)));
|
||||||
|
|
||||||
let _ = tx.send(Ok(SendableRwh(window.raw_window_handle())));
|
if let Ok(rwh) = window.raw_window_handle() {
|
||||||
|
let _ = tx.send(Ok(SendableRwh(rwh)));
|
||||||
|
}
|
||||||
|
|
||||||
inner.run_event_loop(&mut handler);
|
inner.run_event_loop(&mut handler);
|
||||||
}
|
}
|
||||||
|
@ -700,25 +701,24 @@ impl WindowInner {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<'a> HasRawWindowHandle for Window<'a> {
|
unsafe impl<'a> HasRawWindowHandle for Window<'a> {
|
||||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
fn raw_window_handle(&self) -> Result<RawWindowHandle, raw_window_handle::HandleError> {
|
||||||
let mut handle = XlibWindowHandle::empty();
|
let mut handle = XlibWindowHandle::new(self.inner.window_id.into());
|
||||||
|
|
||||||
handle.window = self.inner.window_id.into();
|
|
||||||
handle.visual_id = self.inner.visual_id.into();
|
handle.visual_id = self.inner.visual_id.into();
|
||||||
|
|
||||||
RawWindowHandle::Xlib(handle)
|
Ok(RawWindowHandle::Xlib(handle))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<'a> HasRawDisplayHandle for Window<'a> {
|
unsafe impl<'a> HasRawDisplayHandle for Window<'a> {
|
||||||
fn raw_display_handle(&self) -> RawDisplayHandle {
|
fn raw_display_handle(&self) -> Result<RawDisplayHandle, raw_window_handle::HandleError> {
|
||||||
let display = self.inner.xcb_connection.conn.get_raw_dpy();
|
let display = self.inner.xcb_connection.conn.get_raw_dpy();
|
||||||
let mut handle = XlibDisplayHandle::empty();
|
let handle =
|
||||||
|
XlibDisplayHandle::new(std::ptr::NonNull::new(display as *mut c_void), unsafe {
|
||||||
|
x11::xlib::XDefaultScreen(display)
|
||||||
|
});
|
||||||
|
|
||||||
handle.display = display as *mut c_void;
|
Ok(RawDisplayHandle::Xlib(handle))
|
||||||
handle.screen = unsafe { x11::xlib::XDefaultScreen(display) };
|
|
||||||
|
|
||||||
RawDisplayHandle::Xlib(handle)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue