Add dummy HasRawDisplayHandle impls for Windows and X11
This commit is contained in:
parent
1c0490f9ec
commit
5c23c62030
|
@ -24,7 +24,10 @@ use std::os::windows::ffi::OsStrExt;
|
||||||
use std::ptr::null_mut;
|
use std::ptr::null_mut;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle, Win32Handle};
|
use raw_window_handle::{
|
||||||
|
HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle, RawWindowHandle, Win32WindowHandle,
|
||||||
|
Win32WindowHandle, WindowsDisplayHandle,
|
||||||
|
};
|
||||||
|
|
||||||
const BV_WINDOW_MUST_CLOSE: UINT = WM_USER + 1;
|
const BV_WINDOW_MUST_CLOSE: UINT = WM_USER + 1;
|
||||||
|
|
||||||
|
@ -84,16 +87,22 @@ impl WindowHandle {
|
||||||
unsafe impl HasRawWindowHandle for WindowHandle {
|
unsafe impl HasRawWindowHandle for WindowHandle {
|
||||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
fn raw_window_handle(&self) -> RawWindowHandle {
|
||||||
if let Some(hwnd) = self.hwnd {
|
if let Some(hwnd) = self.hwnd {
|
||||||
let mut handle = Win32Handle::empty();
|
let mut handle = Win32WindowHandle::empty();
|
||||||
handle.hwnd = hwnd as *mut c_void;
|
handle.hwnd = hwnd as *mut c_void;
|
||||||
|
|
||||||
RawWindowHandle::Win32(handle)
|
RawWindowHandle::Windows(handle)
|
||||||
} else {
|
} else {
|
||||||
RawWindowHandle::Win32(Win32Handle::empty())
|
RawWindowHandle::Windows(Win32WindowHandle::empty())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe impl HasRawDisplayHandle for WindowHandle {
|
||||||
|
fn raw_display_handle(&self) -> RawDisplayHandle {
|
||||||
|
RawDisplayHandle::Windows(WindowsDisplayHandle::empty())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct ParentHandle {
|
struct ParentHandle {
|
||||||
is_open: Rc<Cell<bool>>,
|
is_open: Rc<Cell<bool>>,
|
||||||
}
|
}
|
||||||
|
@ -536,7 +545,7 @@ impl Window<'_> {
|
||||||
B: Send + 'static,
|
B: Send + 'static,
|
||||||
{
|
{
|
||||||
let parent = match parent.raw_window_handle() {
|
let parent = match parent.raw_window_handle() {
|
||||||
RawWindowHandle::Win32(h) => h.hwnd as HWND,
|
RawWindowHandle::Windows(h) => h.hwnd as HWND,
|
||||||
h => panic!("unsupported parent handle {:?}", h),
|
h => panic!("unsupported parent handle {:?}", h),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -644,9 +653,9 @@ impl Window<'_> {
|
||||||
|
|
||||||
#[cfg(feature = "opengl")]
|
#[cfg(feature = "opengl")]
|
||||||
let gl_context: Option<GlContext> = options.gl_config.map(|gl_config| {
|
let gl_context: Option<GlContext> = options.gl_config.map(|gl_config| {
|
||||||
let mut handle = Win32Handle::empty();
|
let mut handle = Win32WindowHandle::empty();
|
||||||
handle.hwnd = hwnd as *mut c_void;
|
handle.hwnd = hwnd as *mut c_void;
|
||||||
let handle = RawWindowHandleWrapper { handle: RawWindowHandle::Win32(handle) };
|
let handle = RawWindowHandleWrapper { handle: RawWindowHandle::Windows(handle) };
|
||||||
|
|
||||||
GlContext::create(&handle, gl_config).expect("Could not create OpenGL context")
|
GlContext::create(&handle, gl_config).expect("Could not create OpenGL context")
|
||||||
});
|
});
|
||||||
|
@ -757,10 +766,10 @@ impl Window<'_> {
|
||||||
|
|
||||||
unsafe impl HasRawWindowHandle for Window<'_> {
|
unsafe impl HasRawWindowHandle for Window<'_> {
|
||||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
fn raw_window_handle(&self) -> RawWindowHandle {
|
||||||
let mut handle = Win32Handle::empty();
|
let mut handle = Win32WindowHandle::empty();
|
||||||
handle.hwnd = self.state.hwnd as *mut c_void;
|
handle.hwnd = self.state.hwnd as *mut c_void;
|
||||||
|
|
||||||
RawWindowHandle::Win32(handle)
|
RawWindowHandle::Windows(handle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,10 @@ use std::sync::Arc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::*;
|
use std::time::*;
|
||||||
|
|
||||||
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle, XlibHandle};
|
use raw_window_handle::{
|
||||||
|
HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle, RawWindowHandle, XlibDisplayHandle,
|
||||||
|
XlibWindowHandle,
|
||||||
|
};
|
||||||
use xcb::ffi::xcb_screen_t;
|
use xcb::ffi::xcb_screen_t;
|
||||||
use xcb::StructPtr;
|
use xcb::StructPtr;
|
||||||
|
|
||||||
|
@ -57,7 +60,13 @@ unsafe impl HasRawWindowHandle for WindowHandle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RawWindowHandle::Xlib(XlibHandle::empty())
|
RawWindowHandle::Xlib(XlibWindowHandle::empty())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl HasRawDisplayHandle for WindowHandle {
|
||||||
|
fn raw_display_handle(&self) -> RawDisplayHandle {
|
||||||
|
RawDisplayHandle::Xlib(XlibDisplayHandle::empty())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +332,7 @@ impl Window {
|
||||||
// compared to when raw-gl-context was a separate crate.
|
// compared to when raw-gl-context was a separate crate.
|
||||||
#[cfg(feature = "opengl")]
|
#[cfg(feature = "opengl")]
|
||||||
let gl_context = fb_config.map(|fb_config| {
|
let gl_context = fb_config.map(|fb_config| {
|
||||||
let mut handle = XlibHandle::empty();
|
let mut handle = XlibWindowHandle::empty();
|
||||||
handle.window = window_id as c_ulong;
|
handle.window = window_id as c_ulong;
|
||||||
handle.display = xcb_connection.conn.get_raw_dpy() as *mut c_void;
|
handle.display = xcb_connection.conn.get_raw_dpy() as *mut c_void;
|
||||||
let handle = RawWindowHandleWrapper { handle: RawWindowHandle::Xlib(handle) };
|
let handle = RawWindowHandleWrapper { handle: RawWindowHandle::Xlib(handle) };
|
||||||
|
@ -686,7 +695,7 @@ impl Window {
|
||||||
|
|
||||||
unsafe impl HasRawWindowHandle for Window {
|
unsafe impl HasRawWindowHandle for Window {
|
||||||
fn raw_window_handle(&self) -> RawWindowHandle {
|
fn raw_window_handle(&self) -> RawWindowHandle {
|
||||||
let mut handle = XlibHandle::empty();
|
let mut handle = XlibWindowHandle::empty();
|
||||||
handle.window = self.window_id as c_ulong;
|
handle.window = self.window_id as c_ulong;
|
||||||
handle.display = self.xcb_connection.conn.get_raw_dpy() as *mut c_void;
|
handle.display = self.xcb_connection.conn.get_raw_dpy() as *mut c_void;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue