From eb94b4d7ab10e721512b0ec8c65ad383d73e5db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Wed, 23 Nov 2022 23:18:10 +0100 Subject: [PATCH] Impl HasRawDisplayHandle on Window, not WindowHandle --- src/macos/window.rs | 14 +++++++------- src/win/window.rs | 12 ++++++------ src/window.rs | 12 ++++++------ src/x11/window.rs | 12 ++++++------ 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/macos/window.rs b/src/macos/window.rs index 136d9ab..2587fa9 100644 --- a/src/macos/window.rs +++ b/src/macos/window.rs @@ -69,12 +69,6 @@ unsafe impl HasRawWindowHandle for WindowHandle { } } -unsafe impl HasRawDisplayHandle for WindowHandle { - fn raw_display_handle(&self) -> RawDisplayHandle { - RawDisplayHandle::AppKit(AppKitDisplayHandle::empty()) - } -} - struct ParentHandle { _close_requested: Arc, is_open: Arc, @@ -354,7 +348,7 @@ impl Window { #[cfg(feature = "opengl")] fn create_gl_context(ns_window: Option, ns_view: id, config: GlConfig) -> GlContext { - let mut handle = AppKitHandle::empty(); + let mut handle = AppKitWindowHandle::empty(); handle.ns_window = ns_window.unwrap_or(ptr::null_mut()) as *mut c_void; handle.ns_view = ns_view as *mut c_void; let handle = RawWindowHandleWrapper { handle: RawWindowHandle::AppKit(handle) }; @@ -493,6 +487,12 @@ unsafe impl HasRawWindowHandle for Window { } } +unsafe impl HasRawDisplayHandle for Window { + fn raw_display_handle(&self) -> RawDisplayHandle { + RawDisplayHandle::AppKit(AppKitDisplayHandle::empty()) + } +} + pub fn copy_to_clipboard(string: &str) { unsafe { let pb = NSPasteboard::generalPasteboard(nil); diff --git a/src/win/window.rs b/src/win/window.rs index f8c6156..02d2481 100644 --- a/src/win/window.rs +++ b/src/win/window.rs @@ -97,12 +97,6 @@ unsafe impl HasRawWindowHandle for WindowHandle { } } -unsafe impl HasRawDisplayHandle for WindowHandle { - fn raw_display_handle(&self) -> RawDisplayHandle { - RawDisplayHandle::Windows(WindowsDisplayHandle::empty()) - } -} - struct ParentHandle { is_open: Rc>, } @@ -773,6 +767,12 @@ unsafe impl HasRawWindowHandle for Window<'_> { } } +unsafe impl HasRawDisplayHandle for Window<'_> { + fn raw_display_handle(&self) -> RawDisplayHandle { + RawDisplayHandle::Windows(WindowsDisplayHandle::empty()) + } +} + pub fn copy_to_clipboard(data: &str) { todo!() } diff --git a/src/window.rs b/src/window.rs index d83f6cf..f662990 100644 --- a/src/window.rs +++ b/src/window.rs @@ -50,12 +50,6 @@ unsafe impl HasRawWindowHandle for WindowHandle { } } -unsafe impl HasRawDisplayHandle for WindowHandle { - fn raw_display_handle(&self) -> RawDisplayHandle { - self.window_handle.raw_display_handle() - } -} - pub trait WindowHandler { fn on_frame(&mut self, window: &mut Window); fn on_event(&mut self, window: &mut Window, event: Event) -> EventStatus; @@ -137,6 +131,12 @@ unsafe impl<'a> HasRawWindowHandle for Window<'a> { } } +unsafe impl<'a> HasRawDisplayHandle for Window<'a> { + fn raw_display_handle(&self) -> RawDisplayHandle { + self.window.raw_display_handle() + } +} + unsafe impl HasRawWindowHandle for RawWindowHandleWrapper { fn raw_window_handle(&self) -> RawWindowHandle { self.handle diff --git a/src/x11/window.rs b/src/x11/window.rs index b6ba8b3..b8f89bb 100644 --- a/src/x11/window.rs +++ b/src/x11/window.rs @@ -64,12 +64,6 @@ unsafe impl HasRawWindowHandle for WindowHandle { } } -unsafe impl HasRawDisplayHandle for WindowHandle { - fn raw_display_handle(&self) -> RawDisplayHandle { - RawDisplayHandle::Xlib(XlibDisplayHandle::empty()) - } -} - struct ParentHandle { close_requested: Arc, is_open: Arc, @@ -703,6 +697,12 @@ unsafe impl HasRawWindowHandle for Window { } } +unsafe impl HasRawDisplayHandle for Window { + fn raw_display_handle(&self) -> RawDisplayHandle { + RawDisplayHandle::Xlib(XlibDisplayHandle::empty()) + } +} + fn mouse_id(id: u8) -> MouseButton { match id { 1 => MouseButton::Left,