1
0
Fork 0

Upgrade to raw-window-handle 0.5, impl HasRawDisplayHandle for macOS

This commit is contained in:
Joakim Frostegård 2022-11-23 22:30:33 +01:00 committed by Robbert van der Helm
parent c129b12ead
commit 1c0490f9ec
3 changed files with 22 additions and 5 deletions

View file

@ -20,7 +20,7 @@ opengl = ["uuid", "x11/glx"]
[dependencies]
keyboard-types = { version = "0.6.1", default-features = false }
raw-window-handle = "0.4.2"
raw-window-handle = "0.5"
[target.'cfg(target_os="linux")'.dependencies]
xcb = { version = "0.9", features = ["thread", "xlib_xcb", "dri2"] }

View file

@ -17,7 +17,10 @@ use keyboard_types::KeyboardEvent;
use objc::{msg_send, runtime::Object, sel, sel_impl};
use raw_window_handle::{AppKitHandle, HasRawWindowHandle, RawWindowHandle};
use raw_window_handle::{
AppKitDisplayHandle, AppKitWindowHandle, HasRawDisplayHandle, HasRawWindowHandle,
RawDisplayHandle, RawWindowHandle,
};
use crate::{
Event, EventStatus, Size, WindowEvent, WindowHandler, WindowInfo, WindowOpenOptions,
@ -62,7 +65,13 @@ unsafe impl HasRawWindowHandle for WindowHandle {
}
}
RawWindowHandle::AppKit(AppKitHandle::empty())
RawWindowHandle::AppKit(AppKitWindowHandle::empty())
}
}
unsafe impl HasRawDisplayHandle for WindowHandle {
fn raw_display_handle(&self) -> RawDisplayHandle {
RawDisplayHandle::AppKit(AppKitDisplayHandle::empty())
}
}
@ -476,7 +485,7 @@ unsafe impl HasRawWindowHandle for Window {
fn raw_window_handle(&self) -> RawWindowHandle {
let ns_window = self.ns_window.unwrap_or(ptr::null_mut()) as *mut c_void;
let mut handle = AppKitHandle::empty();
let mut handle = AppKitWindowHandle::empty();
handle.ns_window = ns_window;
handle.ns_view = self.ns_view as *mut c_void;

View file

@ -1,6 +1,8 @@
use std::marker::PhantomData;
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
use raw_window_handle::{
HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle, RawWindowHandle,
};
use crate::event::{Event, EventStatus};
use crate::window_open_options::WindowOpenOptions;
@ -48,6 +50,12 @@ 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;