From deba6fd2a0a8ab3812aa838189d8dd1bca05fa8b Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Sat, 5 Jun 2021 19:16:44 +0200 Subject: [PATCH] Update raw-window-handle to `0.4.0` See https://github.com/rust-windowing/raw-window-handle/pull/70 --- CHANGELOG.md | 1 + Cargo.toml | 3 ++- src/platform_impl/android/mod.rs | 10 +++++----- src/platform_impl/ios/window.rs | 14 ++++++-------- src/platform_impl/linux/wayland/window/mod.rs | 14 +++++--------- src/platform_impl/linux/x11/window.rs | 11 +++++------ src/platform_impl/macos/window.rs | 12 +++++------- src/platform_impl/web/window.rs | 13 +++++-------- src/platform_impl/windows/window.rs | 12 +++++------- 9 files changed, 39 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 355a415ca0..36dc371b89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Unreleased +- **Breaking:** Update `raw-window-handle` to `0.4.0`. - On Android, implement `Window::request_redraw` - **Breaking:** On Web, remove the `stdweb` backend. - Added `Window::focus_window`to bring the window to the front and set input focus. diff --git a/Cargo.toml b/Cargo.toml index 88ac1cc66c..6b5f948c69 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,8 @@ lazy_static = "1" libc = "0.2.64" log = "0.4" serde = { version = "1", optional = true, features = ["serde_derive"] } -raw-window-handle = "0.3" +# PR: https://github.com/rust-windowing/raw-window-handle/pull/70 +raw-window-handle = { git = "https://github.com/Friz64/raw-window-handle.git", rev = "6c0665649435a31cddc5e895bf4f74c656f200ad" } bitflags = "1" mint = { version = "0.5.6", optional = true } diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index b7853cf073..4fe481f5f5 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -12,6 +12,7 @@ use ndk::{ looper::{ForeignLooper, Poll, ThreadLooper}, }; use ndk_glue::{Event, Rect}; +use raw_window_handle::{AndroidNDKHandle, RawWindowHandle}; use std::{ collections::VecDeque, sync::{Arc, Mutex, RwLock}, @@ -587,15 +588,14 @@ impl Window { )) } - pub fn raw_window_handle(&self) -> raw_window_handle::RawWindowHandle { - let a_native_window = if let Some(native_window) = ndk_glue::native_window().as_ref() { + pub fn raw_window_handle(&self) -> RawWindowHandle { + let mut handle = AndroidNDKHandle::empty(); + handle.a_native_window = if let Some(native_window) = ndk_glue::native_window().as_ref() { unsafe { native_window.ptr().as_mut() as *mut _ as *mut _ } } else { panic!("Cannot get the native window, it's null and will always be null before Event::Resumed and after Event::Suspended. Make sure you only call this function between those events."); }; - let mut handle = raw_window_handle::android::AndroidHandle::empty(); - handle.a_native_window = a_native_window; - raw_window_handle::RawWindowHandle::Android(handle) + RawWindowHandle::AndroidNDK(handle) } pub fn config(&self) -> Configuration { diff --git a/src/platform_impl/ios/window.rs b/src/platform_impl/ios/window.rs index b6d32ffd90..7d0e7d05f1 100644 --- a/src/platform_impl/ios/window.rs +++ b/src/platform_impl/ios/window.rs @@ -1,4 +1,4 @@ -use raw_window_handle::{ios::IOSHandle, RawWindowHandle}; +use raw_window_handle::{RawWindowHandle, UIKitHandle}; use std::{ collections::VecDeque, ops::{Deref, DerefMut}, @@ -307,13 +307,11 @@ impl Inner { } 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) + let mut handle = UIKitHandle::empty(); + handle.ui_window = self.window as _; + handle.ui_view = self.view as _; + handle.ui_view_controller = self.view_controller as _; + RawWindowHandle::UIKit(handle) } } diff --git a/src/platform_impl/linux/wayland/window/mod.rs b/src/platform_impl/linux/wayland/window/mod.rs index 5f59651edb..4fc1e1908c 100644 --- a/src/platform_impl/linux/wayland/window/mod.rs +++ b/src/platform_impl/linux/wayland/window/mod.rs @@ -11,7 +11,7 @@ use sctk::window::{ ARGBColor, ButtonColorSpec, ColorSpec, ConceptConfig, ConceptFrame, Decorations, }; -use raw_window_handle::unix::WaylandHandle; +use raw_window_handle::WaylandHandle; use crate::dpi::{LogicalSize, PhysicalPosition, PhysicalSize, Position, Size}; use crate::error::{ExternalError, NotSupportedError, OsError as RootOsError}; @@ -638,14 +638,10 @@ impl Window { #[inline] pub fn raw_window_handle(&self) -> WaylandHandle { - let display = self.display.get_display_ptr() as *mut _; - let surface = self.surface.as_ref().c_ptr() as *mut _; - - WaylandHandle { - display, - surface, - ..WaylandHandle::empty() - } + let mut handle = WaylandHandle::empty(); + handle.display = self.display.get_display_ptr() as *mut _; + handle.surface = self.surface.as_ref().c_ptr() as *mut _; + handle } } diff --git a/src/platform_impl/linux/x11/window.rs b/src/platform_impl/linux/x11/window.rs index 1e5a32a200..1e5623e5f3 100644 --- a/src/platform_impl/linux/x11/window.rs +++ b/src/platform_impl/linux/x11/window.rs @@ -1,4 +1,4 @@ -use raw_window_handle::unix::XlibHandle; +use raw_window_handle::XlibHandle; use std::{ cmp, env, ffi::CString, @@ -1404,10 +1404,9 @@ impl UnownedWindow { #[inline] pub fn raw_window_handle(&self) -> XlibHandle { - XlibHandle { - window: self.xwindow, - display: self.xconn.display as _, - ..XlibHandle::empty() - } + let mut handle = XlibHandle::empty(); + handle.window = self.xwindow; + handle.display = self.xconn.display as _; + handle } } diff --git a/src/platform_impl/macos/window.rs b/src/platform_impl/macos/window.rs index 68ef526df3..1c46222e46 100644 --- a/src/platform_impl/macos/window.rs +++ b/src/platform_impl/macos/window.rs @@ -1,4 +1,4 @@ -use raw_window_handle::{macos::MacOSHandle, RawWindowHandle}; +use raw_window_handle::{AppKitHandle, RawWindowHandle}; use std::{ collections::VecDeque, f64, @@ -1022,12 +1022,10 @@ impl UnownedWindow { #[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) + let mut handle = AppKitHandle::empty(); + handle.ns_window = *self.ns_window as *mut _; + handle.ns_view = *self.ns_view as *mut _; + RawWindowHandle::AppKit(handle) } } diff --git a/src/platform_impl/web/window.rs b/src/platform_impl/web/window.rs index 9e1b84256f..5cbf923f70 100644 --- a/src/platform_impl/web/window.rs +++ b/src/platform_impl/web/window.rs @@ -7,7 +7,7 @@ use crate::window::{ CursorIcon, Fullscreen, UserAttentionType, WindowAttributes, WindowId as RootWI, }; -use raw_window_handle::web::WebHandle; +use raw_window_handle::{RawWindowHandle, WebHandle}; use super::{backend, monitor, EventLoopWindowTarget}; @@ -322,13 +322,10 @@ impl Window { } #[inline] - pub fn raw_window_handle(&self) -> raw_window_handle::RawWindowHandle { - let handle = WebHandle { - id: self.id.0, - ..WebHandle::empty() - }; - - raw_window_handle::RawWindowHandle::Web(handle) + pub fn raw_window_handle(&self) -> RawWindowHandle { + let mut handle = WebHandle::empty(); + handle.id = self.id.0; + RawWindowHandle::Web(handle) } } diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index 081009dc0b..abe793924b 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -1,7 +1,7 @@ #![cfg(target_os = "windows")] use parking_lot::Mutex; -use raw_window_handle::{windows::WindowsHandle, RawWindowHandle}; +use raw_window_handle::{RawWindowHandle, Win32Handle}; use std::{ cell::Cell, ffi::OsStr, @@ -284,12 +284,10 @@ impl Window { #[inline] pub fn raw_window_handle(&self) -> RawWindowHandle { - let handle = WindowsHandle { - hwnd: self.window.0 as *mut _, - hinstance: self.hinstance() as *mut _, - ..WindowsHandle::empty() - }; - RawWindowHandle::Windows(handle) + let mut handle = Win32Handle::empty(); + handle.hwnd = self.window.0 as *mut _; + handle.hinstance = self.hinstance() as *mut _; + RawWindowHandle::Win32(handle) } #[inline]