Skip to content

Commit 2f7f177

Browse files
committed
Move RawWindowHandleWrapper to a shared module
We're going to need this for the other platforms as well.
1 parent 690a94f commit 2f7f177

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/window.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ pub struct WindowHandle {
1818
phantom: PhantomData<*mut ()>,
1919
}
2020

21+
/// Quick wrapper to satisfy [HasRawWindowHandle], because of course a raw window handle wouldn't
22+
/// have a raw window handle, that would be silly.
23+
pub(crate) struct RawWindowHandleWrapper {
24+
pub handle: RawWindowHandle,
25+
}
26+
2127
impl WindowHandle {
2228
fn new(window_handle: platform::WindowHandle) -> Self {
2329
Self { window_handle, phantom: PhantomData::default() }
@@ -105,3 +111,9 @@ unsafe impl<'a> HasRawWindowHandle for Window<'a> {
105111
self.window.raw_window_handle()
106112
}
107113
}
114+
115+
unsafe impl HasRawWindowHandle for RawWindowHandleWrapper {
116+
fn raw_window_handle(&self) -> RawWindowHandle {
117+
self.handle
118+
}
119+
}

src/x11/window.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use xcb::ffi::xcb_screen_t;
1111
use xcb::StructPtr;
1212

1313
use super::XcbConnection;
14+
use crate::window::RawWindowHandleWrapper;
1415
use crate::{
1516
Event, MouseButton, MouseCursor, MouseEvent, PhyPoint, PhySize, ScrollDelta, WindowEvent,
1617
WindowHandler, WindowInfo, WindowOpenOptions, WindowScalePolicy,
@@ -109,12 +110,6 @@ pub struct Window {
109110
// Hack to allow sending a RawWindowHandle between threads. Do not make public
110111
struct SendableRwh(RawWindowHandle);
111112

112-
/// Quick wrapper to satisfy [HasRawWindowHandle], because of course a raw window handle wouldn't
113-
/// have a raw window handle, that would be silly.
114-
struct RawWindowHandleWrapper {
115-
handle: RawWindowHandle,
116-
}
117-
118113
unsafe impl Send for SendableRwh {}
119114

120115
type WindowOpenResult = Result<SendableRwh, ()>;
@@ -667,12 +662,6 @@ unsafe impl HasRawWindowHandle for Window {
667662
}
668663
}
669664

670-
unsafe impl HasRawWindowHandle for RawWindowHandleWrapper {
671-
fn raw_window_handle(&self) -> RawWindowHandle {
672-
self.handle
673-
}
674-
}
675-
676665
fn mouse_id(id: u8) -> MouseButton {
677666
match id {
678667
1 => MouseButton::Left,

0 commit comments

Comments
 (0)