mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 21:31:29 +11:00
Implement raw_window_handle::HasRawWindowHandle for Window type (#1105)
* Implement raw_window_handle::HasRawWindowHandle for Window type * Format * Address compilation issues * Fix Linux build hopefully * Fix iOS build
This commit is contained in:
parent
1aab328e2a
commit
604016d69d
|
@ -23,6 +23,7 @@
|
||||||
hijacking `set_decorations` for this purpose.
|
hijacking `set_decorations` for this purpose.
|
||||||
- On macOS and iOS, corrected the auto trait impls of `EventLoopProxy`.
|
- On macOS and iOS, corrected the auto trait impls of `EventLoopProxy`.
|
||||||
- On iOS, add touch pressure information for touch events.
|
- On iOS, add touch pressure information for touch events.
|
||||||
|
- Implement `raw_window_handle::HasRawWindowHandle` for `Window` type on all supported platforms.
|
||||||
- On macOS, fix the signature of `-[NSView drawRect:]`.
|
- On macOS, fix the signature of `-[NSView drawRect:]`.
|
||||||
|
|
||||||
# 0.20.0 Alpha 2 (2019-07-09)
|
# 0.20.0 Alpha 2 (2019-07-09)
|
||||||
|
|
|
@ -20,6 +20,7 @@ libc = "0.2"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
serde = { version = "1", optional = true, features = ["serde_derive"] }
|
serde = { version = "1", optional = true, features = ["serde_derive"] }
|
||||||
derivative = "1.0.2"
|
derivative = "1.0.2"
|
||||||
|
raw-window-handle = "0.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
image = "0.21"
|
image = "0.21"
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use raw_window_handle::{ios::IOSHandle, RawWindowHandle};
|
||||||
use std::{
|
use std::{
|
||||||
collections::VecDeque,
|
collections::VecDeque,
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
|
@ -250,6 +251,16 @@ impl Inner {
|
||||||
pub fn id(&self) -> WindowId {
|
pub fn id(&self) -> WindowId {
|
||||||
self.window.into()
|
self.window.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn raw_window_handle(&self) -> RawWindowHandle {
|
||||||
|
let handle = IOSHandle {
|
||||||
|
ui_window: self.window as _,
|
||||||
|
ui_view: self.view as _,
|
||||||
|
ui_view_controller: self.view_controller as _,
|
||||||
|
..IOSHandle::empty()
|
||||||
|
};
|
||||||
|
RawWindowHandle::IOS(handle)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use std::{collections::VecDeque, env, ffi::CStr, fmt, mem::MaybeUninit, os::raw::*, sync::Arc};
|
use std::{collections::VecDeque, env, ffi::CStr, fmt, mem::MaybeUninit, os::raw::*, sync::Arc};
|
||||||
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
use raw_window_handle::RawWindowHandle;
|
||||||
use smithay_client_toolkit::reexports::client::ConnectError;
|
use smithay_client_toolkit::reexports::client::ConnectError;
|
||||||
|
|
||||||
pub use self::x11::XNotSupported;
|
pub use self::x11::XNotSupported;
|
||||||
|
@ -440,6 +441,13 @@ impl Window {
|
||||||
&Window::Wayland(ref window) => MonitorHandle::Wayland(window.primary_monitor()),
|
&Window::Wayland(ref window) => MonitorHandle::Wayland(window.primary_monitor()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn raw_window_handle(&self) -> RawWindowHandle {
|
||||||
|
match self {
|
||||||
|
&Window::X(ref window) => RawWindowHandle::X11(window.raw_window_handle()),
|
||||||
|
&Window::Wayland(ref window) => RawWindowHandle::Wayland(window.raw_window_handle()),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn x_error_callback(
|
unsafe extern "C" fn x_error_callback(
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use raw_window_handle::unix::WaylandHandle;
|
||||||
use std::{
|
use std::{
|
||||||
collections::VecDeque,
|
collections::VecDeque,
|
||||||
sync::{Arc, Mutex, Weak},
|
sync::{Arc, Mutex, Weak},
|
||||||
|
@ -333,6 +334,14 @@ impl Window {
|
||||||
pub fn primary_monitor(&self) -> MonitorHandle {
|
pub fn primary_monitor(&self) -> MonitorHandle {
|
||||||
primary_monitor(&self.outputs)
|
primary_monitor(&self.outputs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn raw_window_handle(&self) -> WaylandHandle {
|
||||||
|
WaylandHandle {
|
||||||
|
surface: self.surface().as_ref().c_ptr() as *mut _,
|
||||||
|
display: self.display().as_ref().c_ptr() as *mut _,
|
||||||
|
..WaylandHandle::empty()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Window {
|
impl Drop for Window {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use raw_window_handle::unix::X11Handle;
|
||||||
use std::{
|
use std::{
|
||||||
cmp,
|
cmp,
|
||||||
collections::HashSet,
|
collections::HashSet,
|
||||||
|
@ -1375,4 +1376,13 @@ impl UnownedWindow {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.insert(WindowId(self.xwindow));
|
.insert(WindowId(self.xwindow));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn raw_window_handle(&self) -> X11Handle {
|
||||||
|
X11Handle {
|
||||||
|
window: self.xwindow,
|
||||||
|
display: self.xconn.display as _,
|
||||||
|
..X11Handle::empty()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use raw_window_handle::{macos::MacOSHandle, RawWindowHandle};
|
||||||
use std::{
|
use std::{
|
||||||
collections::VecDeque,
|
collections::VecDeque,
|
||||||
f64,
|
f64,
|
||||||
|
@ -904,6 +905,16 @@ impl UnownedWindow {
|
||||||
pub fn primary_monitor(&self) -> MonitorHandle {
|
pub fn primary_monitor(&self) -> MonitorHandle {
|
||||||
monitor::primary_monitor()
|
monitor::primary_monitor()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn raw_window_handle(&self) -> RawWindowHandle {
|
||||||
|
let handle = MacOSHandle {
|
||||||
|
ns_window: *self.ns_window as *mut _,
|
||||||
|
ns_view: *self.ns_view as *mut _,
|
||||||
|
..MacOSHandle::empty()
|
||||||
|
};
|
||||||
|
RawWindowHandle::MacOS(handle)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowExtMacOS for UnownedWindow {
|
impl WindowExtMacOS for UnownedWindow {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![cfg(target_os = "windows")]
|
#![cfg(target_os = "windows")]
|
||||||
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
use raw_window_handle::{windows::WindowsHandle, RawWindowHandle};
|
||||||
use std::{
|
use std::{
|
||||||
cell::Cell,
|
cell::Cell,
|
||||||
ffi::OsStr,
|
ffi::OsStr,
|
||||||
|
@ -339,6 +340,15 @@ impl Window {
|
||||||
self.window.0
|
self.window.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn raw_window_handle(&self) -> RawWindowHandle {
|
||||||
|
let handle = WindowsHandle {
|
||||||
|
hwnd: self.window.0 as *mut _,
|
||||||
|
..WindowsHandle::empty()
|
||||||
|
};
|
||||||
|
RawWindowHandle::Windows(handle)
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_cursor_icon(&self, cursor: CursorIcon) {
|
pub fn set_cursor_icon(&self, cursor: CursorIcon) {
|
||||||
self.window_state.lock().mouse.cursor = cursor;
|
self.window_state.lock().mouse.cursor = cursor;
|
||||||
|
|
|
@ -721,6 +721,12 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe impl raw_window_handle::HasRawWindowHandle for Window {
|
||||||
|
fn raw_window_handle(&self) -> raw_window_handle::RawWindowHandle {
|
||||||
|
self.window.raw_window_handle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Describes the appearance of the mouse cursor.
|
/// Describes the appearance of the mouse cursor.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
|
Loading…
Reference in a new issue