mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-31 05:40:04 -04:00
Add raw-window-handle support to Winit 0.19 and bump version (#1225)
* Add raw-window-handle support to Winit 0.19 and bump version * Hopefully fix linux and ios builds
This commit is contained in:
@@ -1,5 +1,13 @@
|
|||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
|
# Version 0.19.4 (2019-10-16)
|
||||||
|
|
||||||
|
- Add support for `raw-window-handle` 0.3.
|
||||||
|
|
||||||
|
# Version 0.19.3 (2019-08-26)
|
||||||
|
|
||||||
|
- Update parking_lot version.
|
||||||
|
|
||||||
# Version 0.19.2 (2019-07-29)
|
# Version 0.19.2 (2019-07-29)
|
||||||
|
|
||||||
- On X11, fix sanity check which checks that a monitor's reported width and height (in millimeters) are non-zero when calculating the DPI factor.
|
- On X11, fix sanity check which checks that a monitor's reported width and height (in millimeters) are non-zero when calculating the DPI factor.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "winit"
|
name = "winit"
|
||||||
version = "0.19.3"
|
version = "0.19.4"
|
||||||
authors = ["The winit contributors", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
|
authors = ["The winit contributors", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
|
||||||
description = "Cross-platform window creation library."
|
description = "Cross-platform window creation library."
|
||||||
keywords = ["windowing"]
|
keywords = ["windowing"]
|
||||||
@@ -22,6 +22,7 @@ libc = "0.2"
|
|||||||
log = "0.4"
|
log = "0.4"
|
||||||
image = { version = "0.21", optional = true }
|
image = { version = "0.21", optional = true }
|
||||||
serde = { version = "1", optional = true, features = ["serde_derive"] }
|
serde = { version = "1", optional = true, features = ["serde_derive"] }
|
||||||
|
raw-window-handle = "0.3"
|
||||||
|
|
||||||
[target.'cfg(target_os = "android")'.dependencies.android_glue]
|
[target.'cfg(target_os = "android")'.dependencies.android_glue]
|
||||||
version = "0.2"
|
version = "0.2"
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ extern crate parking_lot;
|
|||||||
extern crate percent_encoding;
|
extern crate percent_encoding;
|
||||||
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))]
|
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))]
|
||||||
extern crate smithay_client_toolkit as sctk;
|
extern crate smithay_client_toolkit as sctk;
|
||||||
|
extern crate raw_window_handle;
|
||||||
|
|
||||||
pub(crate) use dpi::*; // TODO: Actually change the imports throughout the codebase.
|
pub(crate) use dpi::*; // TODO: Actually change the imports throughout the codebase.
|
||||||
pub use events::*;
|
pub use events::*;
|
||||||
|
|||||||
@@ -60,6 +60,7 @@
|
|||||||
|
|
||||||
#![cfg(target_os = "ios")]
|
#![cfg(target_os = "ios")]
|
||||||
|
|
||||||
|
use raw_window_handle::{ios::IOSHandle, RawWindowHandle};
|
||||||
use std::{fmt, mem, ptr};
|
use std::{fmt, mem, ptr};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
@@ -527,6 +528,15 @@ impl Window {
|
|||||||
pub fn id(&self) -> WindowId {
|
pub fn id(&self) -> WindowId {
|
||||||
WindowId
|
WindowId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn raw_window_handle(&self) -> RawWindowHandle {
|
||||||
|
let handle = IOSHandle {
|
||||||
|
ui_window: self.get_uiwindow() as *mut _,
|
||||||
|
ui_view: self.get_uiview() as *mut _,
|
||||||
|
..IOSHandle::empty()
|
||||||
|
};
|
||||||
|
RawWindowHandle::IOS(handle)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_delegate_class() {
|
fn create_delegate_class() {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use std::os::raw::*;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
use raw_window_handle::RawWindowHandle;
|
||||||
use sctk::reexports::client::ConnectError;
|
use sctk::reexports::client::ConnectError;
|
||||||
|
|
||||||
use {
|
use {
|
||||||
@@ -379,6 +380,13 @@ impl Window {
|
|||||||
&Window::Wayland(ref window) => MonitorId::Wayland(window.get_primary_monitor()),
|
&Window::Wayland(ref window) => MonitorId::Wayland(window.get_primary_monitor()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn raw_window_handle(&self) -> RawWindowHandle {
|
||||||
|
match self {
|
||||||
|
&Window::X(ref window) => RawWindowHandle::Xlib(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::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::sync::{Arc, Mutex, Weak};
|
use std::sync::{Arc, Mutex, Weak};
|
||||||
|
|
||||||
@@ -300,6 +301,14 @@ impl Window {
|
|||||||
pub fn get_primary_monitor(&self) -> MonitorId {
|
pub fn get_primary_monitor(&self) -> MonitorId {
|
||||||
get_primary_monitor(&self.outputs)
|
get_primary_monitor(&self.outputs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn raw_window_handle(&self) -> WaylandHandle {
|
||||||
|
WaylandHandle {
|
||||||
|
surface: self.get_surface().c_ptr() as *mut _,
|
||||||
|
display: self.get_display().c_ptr() as *mut _,
|
||||||
|
..WaylandHandle::empty()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Window {
|
impl Drop for Window {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use raw_window_handle::unix::XlibHandle;
|
||||||
use std::{cmp, env, mem};
|
use std::{cmp, env, mem};
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::os::raw::*;
|
use std::os::raw::*;
|
||||||
@@ -1217,4 +1218,13 @@ impl UnownedWindow {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn id(&self) -> WindowId { WindowId(self.xwindow) }
|
pub fn id(&self) -> WindowId { WindowId(self.xwindow) }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn raw_window_handle(&self) -> XlibHandle {
|
||||||
|
XlibHandle {
|
||||||
|
window: self.xwindow,
|
||||||
|
display: self.xconn.display as _,
|
||||||
|
..XlibHandle::empty()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use raw_window_handle::{macos::MacOSHandle, RawWindowHandle};
|
||||||
use std;
|
use std;
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::f64;
|
use std::f64;
|
||||||
@@ -1266,6 +1267,16 @@ impl Window2 {
|
|||||||
self::get_current_monitor(*self.window)
|
self::get_current_monitor(*self.window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn raw_window_handle(&self) -> RawWindowHandle {
|
||||||
|
let handle = MacOSHandle {
|
||||||
|
ns_window: self.get_nswindow(),
|
||||||
|
ns_view: self.get_nsview(),
|
||||||
|
..MacOSHandle::empty()
|
||||||
|
};
|
||||||
|
RawWindowHandle::MacOS(handle)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the `cocoa::base::id` associated with a window to a usize to use as a unique identifier
|
// Convert the `cocoa::base::id` associated with a window to a usize to use as a unique identifier
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ use platform::platform::raw_input::register_all_mice_and_keyboards_for_raw_input
|
|||||||
use platform::platform::util;
|
use platform::platform::util;
|
||||||
use platform::platform::window_state::{CursorFlags, SavedWindow, WindowFlags, WindowState};
|
use platform::platform::window_state::{CursorFlags, SavedWindow, WindowFlags, WindowState};
|
||||||
|
|
||||||
|
use raw_window_handle::{windows::WindowsHandle, RawWindowHandle};
|
||||||
|
|
||||||
/// The Win32 implementation of the main `Window` object.
|
/// The Win32 implementation of the main `Window` object.
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
/// Main handle for the window.
|
/// Main handle for the window.
|
||||||
@@ -268,6 +270,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(&self, cursor: MouseCursor) {
|
pub fn set_cursor(&self, cursor: MouseCursor) {
|
||||||
self.window_state.lock().unwrap().mouse.cursor = cursor;
|
self.window_state.lock().unwrap().mouse.cursor = cursor;
|
||||||
|
|||||||
@@ -435,6 +435,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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// An iterator for the list of available monitors.
|
/// An iterator for the list of available monitors.
|
||||||
// Implementation note: we retrieve the list once, then serve each element by one by one.
|
// Implementation note: we retrieve the list once, then serve each element by one by one.
|
||||||
// This may change in the future.
|
// This may change in the future.
|
||||||
|
|||||||
Reference in New Issue
Block a user