mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-26 22:53:15 -04:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a815a12627 | ||
|
|
2455ab8a03 | ||
|
|
b33fbc0806 | ||
|
|
341fe47c56 |
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,5 +1,17 @@
|
||||
# Unreleased
|
||||
|
||||
# Version 0.19.5 (2019-11-04)
|
||||
|
||||
- On Android, fix the missing `raw-window-handle` support
|
||||
|
||||
# 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)
|
||||
|
||||
- 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]
|
||||
name = "winit"
|
||||
version = "0.19.2"
|
||||
version = "0.19.5"
|
||||
authors = ["The winit contributors", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
|
||||
description = "Cross-platform window creation library."
|
||||
keywords = ["windowing"]
|
||||
@@ -22,6 +22,7 @@ libc = "0.2"
|
||||
log = "0.4"
|
||||
image = { version = "0.21", optional = true }
|
||||
serde = { version = "1", optional = true, features = ["serde_derive"] }
|
||||
raw-window-handle = "0.3"
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies.android_glue]
|
||||
version = "0.2"
|
||||
@@ -66,5 +67,5 @@ features = [
|
||||
wayland-client = { version = "0.21", features = [ "dlopen", "egl", "cursor"] }
|
||||
smithay-client-toolkit = "0.4.3"
|
||||
x11-dl = "2.18.3"
|
||||
parking_lot = "0.8"
|
||||
parking_lot = "0.9"
|
||||
percent-encoding = "2.0"
|
||||
|
||||
@@ -13,7 +13,7 @@ Please direct all work against `master`.
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
winit = "0.19.2"
|
||||
winit = "0.19.5"
|
||||
```
|
||||
|
||||
## [Documentation](https://docs.rs/winit)
|
||||
|
||||
@@ -120,6 +120,7 @@ extern crate parking_lot;
|
||||
extern crate percent_encoding;
|
||||
#[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 raw_window_handle;
|
||||
|
||||
pub(crate) use dpi::*; // TODO: Actually change the imports throughout the codebase.
|
||||
pub use events::*;
|
||||
|
||||
@@ -4,6 +4,7 @@ extern crate android_glue;
|
||||
|
||||
mod ffi;
|
||||
|
||||
use raw_window_handle::{android::AndroidHandle, RawWindowHandle};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::VecDeque;
|
||||
use std::fmt;
|
||||
@@ -422,6 +423,14 @@ impl Window {
|
||||
pub fn id(&self) -> WindowId {
|
||||
WindowId
|
||||
}
|
||||
|
||||
pub fn raw_window_handle(&self) -> RawWindowHandle {
|
||||
let handle = AndroidHandle {
|
||||
a_native_window: self.native_window as _,
|
||||
..AndroidHandle::empty()
|
||||
};
|
||||
RawWindowHandle::Android(handle)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for Window {}
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
|
||||
#![cfg(target_os = "ios")]
|
||||
|
||||
use raw_window_handle::{ios::IOSHandle, RawWindowHandle};
|
||||
use std::{fmt, mem, ptr};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::VecDeque;
|
||||
@@ -527,6 +528,15 @@ impl Window {
|
||||
pub fn id(&self) -> 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() {
|
||||
|
||||
@@ -7,6 +7,7 @@ use std::os::raw::*;
|
||||
use std::sync::Arc;
|
||||
|
||||
use parking_lot::Mutex;
|
||||
use raw_window_handle::RawWindowHandle;
|
||||
use sctk::reexports::client::ConnectError;
|
||||
|
||||
use {
|
||||
@@ -379,6 +380,13 @@ impl Window {
|
||||
&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(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use raw_window_handle::unix::WaylandHandle;
|
||||
use std::collections::VecDeque;
|
||||
use std::sync::{Arc, Mutex, Weak};
|
||||
|
||||
@@ -300,6 +301,14 @@ impl Window {
|
||||
pub fn get_primary_monitor(&self) -> MonitorId {
|
||||
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 {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use raw_window_handle::unix::XlibHandle;
|
||||
use std::{cmp, env, mem};
|
||||
use std::ffi::CString;
|
||||
use std::os::raw::*;
|
||||
@@ -1217,4 +1218,13 @@ impl UnownedWindow {
|
||||
|
||||
#[inline]
|
||||
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::cell::{Cell, RefCell};
|
||||
use std::f64;
|
||||
@@ -1266,6 +1267,16 @@ impl Window2 {
|
||||
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
|
||||
|
||||
@@ -35,6 +35,8 @@ use platform::platform::raw_input::register_all_mice_and_keyboards_for_raw_input
|
||||
use platform::platform::util;
|
||||
use platform::platform::window_state::{CursorFlags, SavedWindow, WindowFlags, WindowState};
|
||||
|
||||
use raw_window_handle::{windows::WindowsHandle, RawWindowHandle};
|
||||
|
||||
/// The Win32 implementation of the main `Window` object.
|
||||
pub struct Window {
|
||||
/// Main handle for the window.
|
||||
@@ -268,6 +270,15 @@ impl Window {
|
||||
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]
|
||||
pub fn set_cursor(&self, cursor: MouseCursor) {
|
||||
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.
|
||||
// Implementation note: we retrieve the list once, then serve each element by one by one.
|
||||
// This may change in the future.
|
||||
|
||||
Reference in New Issue
Block a user