1
0
Fork 0

Move RawWindowHandleWrapper to a shared module

We're going to need this for the other platforms as well.
This commit is contained in:
Robbert van der Helm 2022-02-07 21:51:54 +01:00
parent 690a94f9f1
commit 2f7f177be8
2 changed files with 13 additions and 12 deletions

View file

@ -18,6 +18,12 @@ pub struct WindowHandle {
phantom: PhantomData<*mut ()>,
}
/// Quick wrapper to satisfy [HasRawWindowHandle], because of course a raw window handle wouldn't
/// have a raw window handle, that would be silly.
pub(crate) struct RawWindowHandleWrapper {
pub handle: RawWindowHandle,
}
impl WindowHandle {
fn new(window_handle: platform::WindowHandle) -> Self {
Self { window_handle, phantom: PhantomData::default() }
@ -105,3 +111,9 @@ unsafe impl<'a> HasRawWindowHandle for Window<'a> {
self.window.raw_window_handle()
}
}
unsafe impl HasRawWindowHandle for RawWindowHandleWrapper {
fn raw_window_handle(&self) -> RawWindowHandle {
self.handle
}
}

View file

@ -11,6 +11,7 @@ use xcb::ffi::xcb_screen_t;
use xcb::StructPtr;
use super::XcbConnection;
use crate::window::RawWindowHandleWrapper;
use crate::{
Event, MouseButton, MouseCursor, MouseEvent, PhyPoint, PhySize, ScrollDelta, WindowEvent,
WindowHandler, WindowInfo, WindowOpenOptions, WindowScalePolicy,
@ -109,12 +110,6 @@ pub struct Window {
// Hack to allow sending a RawWindowHandle between threads. Do not make public
struct SendableRwh(RawWindowHandle);
/// Quick wrapper to satisfy [HasRawWindowHandle], because of course a raw window handle wouldn't
/// have a raw window handle, that would be silly.
struct RawWindowHandleWrapper {
handle: RawWindowHandle,
}
unsafe impl Send for SendableRwh {}
type WindowOpenResult = Result<SendableRwh, ()>;
@ -667,12 +662,6 @@ unsafe impl HasRawWindowHandle for Window {
}
}
unsafe impl HasRawWindowHandle for RawWindowHandleWrapper {
fn raw_window_handle(&self) -> RawWindowHandle {
self.handle
}
}
fn mouse_id(id: u8) -> MouseButton {
match id {
1 => MouseButton::Left,