mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 06:41:31 +11:00
Merge branch 'web' into merge-master-to-web
This commit is contained in:
commit
86bafdc104
|
@ -1,4 +1,5 @@
|
||||||
# Unreleased
|
# Unreleased
|
||||||
|
- Add web support via the 'stdweb' or 'web-sys' features
|
||||||
|
|
||||||
- On macOS, implement `run_return`.
|
- On macOS, implement `run_return`.
|
||||||
- On iOS, fix inverted parameter in `set_prefers_home_indicator_hidden`.
|
- On iOS, fix inverted parameter in `set_prefers_home_indicator_hidden`.
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
//! - **Wayland:** On Wayland, DPI factors are set per-screen by the server, and are always integers (most often 1 or 2).
|
//! - **Wayland:** On Wayland, DPI factors are set per-screen by the server, and are always integers (most often 1 or 2).
|
||||||
//! - **iOS:** DPI factors are both constant and device-specific on iOS.
|
//! - **iOS:** DPI factors are both constant and device-specific on iOS.
|
||||||
//! - **Android:** This feature isn't yet implemented on Android, so the DPI factor will always be returned as 1.0.
|
//! - **Android:** This feature isn't yet implemented on Android, so the DPI factor will always be returned as 1.0.
|
||||||
|
//! - **Web:** DPI factors are handled by the browser and will always be 1.0 for your application.
|
||||||
//!
|
//!
|
||||||
//! The window's logical size is conserved across DPI changes, resulting in the physical size changing instead. This
|
//! The window's logical size is conserved across DPI changes, resulting in the physical size changing instead. This
|
||||||
//! may be surprising on X11, but is quite standard elsewhere. Physical size changes always produce a
|
//! may be surprising on X11, but is quite standard elsewhere. Physical size changes always produce a
|
||||||
|
|
|
@ -145,12 +145,20 @@ impl MonitorHandle {
|
||||||
/// Returns a human-readable name of the monitor.
|
/// Returns a human-readable name of the monitor.
|
||||||
///
|
///
|
||||||
/// Returns `None` if the monitor doesn't exist anymore.
|
/// Returns `None` if the monitor doesn't exist anymore.
|
||||||
|
///
|
||||||
|
/// ## Platform-specific
|
||||||
|
///
|
||||||
|
/// - **Web:** Always returns None
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn name(&self) -> Option<String> {
|
pub fn name(&self) -> Option<String> {
|
||||||
self.inner.name()
|
self.inner.name()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the monitor's resolution.
|
/// Returns the monitor's resolution.
|
||||||
|
///
|
||||||
|
/// ## Platform-specific
|
||||||
|
///
|
||||||
|
/// - **Web:** Always returns (0,0)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize {
|
||||||
self.inner.size()
|
self.inner.size()
|
||||||
|
@ -158,6 +166,10 @@ impl MonitorHandle {
|
||||||
|
|
||||||
/// Returns the top-left corner position of the monitor relative to the larger full
|
/// Returns the top-left corner position of the monitor relative to the larger full
|
||||||
/// screen area.
|
/// screen area.
|
||||||
|
///
|
||||||
|
/// ## Platform-specific
|
||||||
|
///
|
||||||
|
/// - **Web:** Always returns (0,0)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn position(&self) -> PhysicalPosition {
|
pub fn position(&self) -> PhysicalPosition {
|
||||||
self.inner.position()
|
self.inner.position()
|
||||||
|
@ -171,12 +183,17 @@ impl MonitorHandle {
|
||||||
///
|
///
|
||||||
/// - **X11:** Can be overridden using the `WINIT_HIDPI_FACTOR` environment variable.
|
/// - **X11:** Can be overridden using the `WINIT_HIDPI_FACTOR` environment variable.
|
||||||
/// - **Android:** Always returns 1.0.
|
/// - **Android:** Always returns 1.0.
|
||||||
|
/// - **Web:** Always returns 1.0
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hidpi_factor(&self) -> f64 {
|
pub fn hidpi_factor(&self) -> f64 {
|
||||||
self.inner.hidpi_factor()
|
self.inner.hidpi_factor()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns all fullscreen video modes supported by this monitor.
|
/// Returns all fullscreen video modes supported by this monitor.
|
||||||
|
///
|
||||||
|
/// ## Platform-specific
|
||||||
|
///
|
||||||
|
/// - **Web:** Always returns an empty iterator
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn video_modes(&self) -> impl Iterator<Item = VideoMode> {
|
pub fn video_modes(&self) -> impl Iterator<Item = VideoMode> {
|
||||||
self.inner.video_modes()
|
self.inner.video_modes()
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
//! - `macos`
|
//! - `macos`
|
||||||
//! - `unix`
|
//! - `unix`
|
||||||
//! - `windows`
|
//! - `windows`
|
||||||
|
//! - `web`
|
||||||
//!
|
//!
|
||||||
//! And the following platform-specific module:
|
//! And the following platform-specific module:
|
||||||
//!
|
//!
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
#![cfg(target_arch = "wasm32")]
|
#![cfg(target_arch = "wasm32")]
|
||||||
|
|
||||||
|
//! The web target does not automatically insert the canvas element object into the web page, to
|
||||||
|
//! allow end users to determine how the page should be laid out. Use the `WindowExtStdweb` or
|
||||||
|
//! `WindowExtWebSys` traits (depending on your web backend) to retrieve the canvas from the
|
||||||
|
//! Window.
|
||||||
|
|
||||||
#[cfg(feature = "stdweb")]
|
#[cfg(feature = "stdweb")]
|
||||||
use stdweb::web::html_element::CanvasElement;
|
use stdweb::web::html_element::CanvasElement;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use super::runner;
|
||||||
use crate::event::Event;
|
use crate::event::Event;
|
||||||
use crate::event_loop::EventLoopClosed;
|
use crate::event_loop::EventLoopClosed;
|
||||||
|
|
||||||
pub struct Proxy<T: 'static>{
|
pub struct Proxy<T: 'static> {
|
||||||
runner: runner::Shared<T>,
|
runner: runner::Shared<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ impl<T: 'static> Proxy<T> {
|
||||||
impl<T: 'static> Clone for Proxy<T> {
|
impl<T: 'static> Clone for Proxy<T> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Proxy {
|
Proxy {
|
||||||
runner: self.runner.clone()
|
runner: self.runner.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,7 @@ pub use self::error::OsError;
|
||||||
pub use self::event_loop::{
|
pub use self::event_loop::{
|
||||||
EventLoop, Proxy as EventLoopProxy, WindowTarget as EventLoopWindowTarget,
|
EventLoop, Proxy as EventLoopProxy, WindowTarget as EventLoopWindowTarget,
|
||||||
};
|
};
|
||||||
pub use self::monitor::{
|
pub use self::monitor::{Handle as MonitorHandle, Mode as VideoMode};
|
||||||
Handle as MonitorHandle, Mode as VideoMode
|
|
||||||
};
|
|
||||||
pub use self::window::{
|
pub use self::window::{
|
||||||
Id as WindowId, PlatformSpecificBuilderAttributes as PlatformSpecificWindowBuilderAttributes,
|
Id as WindowId, PlatformSpecificBuilderAttributes as PlatformSpecificWindowBuilderAttributes,
|
||||||
Window,
|
Window,
|
||||||
|
|
|
@ -10,19 +10,21 @@ impl Handle {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn position(&self) -> PhysicalPosition {
|
pub fn position(&self) -> PhysicalPosition {
|
||||||
unimplemented!();
|
PhysicalPosition { x: 0.0, y: 0.0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn name(&self) -> Option<String> {
|
pub fn name(&self) -> Option<String> {
|
||||||
unimplemented!();
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn size(&self) -> PhysicalSize {
|
pub fn size(&self) -> PhysicalSize {
|
||||||
unimplemented!();
|
PhysicalSize {
|
||||||
|
width: 0.0,
|
||||||
|
height: 0.0,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn video_modes(&self) -> impl Iterator<Item = VideoMode> {
|
pub fn video_modes(&self) -> impl Iterator<Item = VideoMode> {
|
||||||
// TODO: is this possible ?
|
|
||||||
std::iter::empty()
|
std::iter::empty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,9 +47,6 @@ impl Mode {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn monitor(&self) -> MonitorHandle {
|
pub fn monitor(&self) -> MonitorHandle {
|
||||||
MonitorHandle {
|
MonitorHandle { inner: Handle }
|
||||||
inner: Handle
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::icon::Icon;
|
||||||
use crate::monitor::MonitorHandle as RootMH;
|
use crate::monitor::MonitorHandle as RootMH;
|
||||||
use crate::window::{CursorIcon, Fullscreen, WindowAttributes, WindowId as RootWI};
|
use crate::window::{CursorIcon, Fullscreen, WindowAttributes, WindowId as RootWI};
|
||||||
|
|
||||||
use raw_window_handle::{RawWindowHandle, web::WebHandle};
|
use raw_window_handle::web::WebHandle;
|
||||||
|
|
||||||
use super::{backend, monitor, EventLoopWindowTarget};
|
use super::{backend, monitor, EventLoopWindowTarget};
|
||||||
|
|
||||||
|
@ -179,13 +179,13 @@ impl Window {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_cursor_position(&self, _position: LogicalPosition) -> Result<(), ExternalError> {
|
pub fn set_cursor_position(&self, _position: LogicalPosition) -> Result<(), ExternalError> {
|
||||||
// TODO: pointer capture
|
// Intentionally a no-op, as the web does not support setting cursor positions
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_cursor_grab(&self, _grab: bool) -> Result<(), ExternalError> {
|
pub fn set_cursor_grab(&self, _grab: bool) -> Result<(), ExternalError> {
|
||||||
// TODO: pointer capture
|
// Intentionally a no-op, as the web does not (properly) support grabbing the cursor
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ impl Window {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_maximized(&self, _maximized: bool) {
|
pub fn set_maximized(&self, _maximized: bool) {
|
||||||
// TODO: should there be a maximization / fullscreen API?
|
// Intentionally a no-op, as canvases cannot be 'maximized'
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -232,7 +232,7 @@ impl Window {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_ime_position(&self, _position: LogicalPosition) {
|
pub fn set_ime_position(&self, _position: LogicalPosition) {
|
||||||
// TODO: what is this?
|
// Currently a no-op as it does not seem there is good support for this on web
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -303,6 +303,10 @@ impl WindowBuilder {
|
||||||
/// Builds the window.
|
/// Builds the window.
|
||||||
///
|
///
|
||||||
/// Possible causes of error include denied permission, incompatible system, and lack of memory.
|
/// Possible causes of error include denied permission, incompatible system, and lack of memory.
|
||||||
|
///
|
||||||
|
/// Platform-specific behavior:
|
||||||
|
/// - **Web**: The window is created but not inserted into the web page automatically. Please
|
||||||
|
/// see the web platform module for more information.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn build<T: 'static>(
|
pub fn build<T: 'static>(
|
||||||
self,
|
self,
|
||||||
|
@ -321,6 +325,10 @@ impl Window {
|
||||||
///
|
///
|
||||||
/// Error should be very rare and only occur in case of permission denied, incompatible system,
|
/// Error should be very rare and only occur in case of permission denied, incompatible system,
|
||||||
/// out of memory, etc.
|
/// out of memory, etc.
|
||||||
|
///
|
||||||
|
/// Platform-specific behavior:
|
||||||
|
/// - **Web**: The window is created but not inserted into the web page automatically. Please
|
||||||
|
/// see the web platform module for more information.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new<T: 'static>(event_loop: &EventLoopWindowTarget<T>) -> Result<Window, OsError> {
|
pub fn new<T: 'static>(event_loop: &EventLoopWindowTarget<T>) -> Result<Window, OsError> {
|
||||||
let builder = WindowBuilder::new();
|
let builder = WindowBuilder::new();
|
||||||
|
@ -476,6 +484,7 @@ impl Window {
|
||||||
/// ## Platform-specific
|
/// ## Platform-specific
|
||||||
///
|
///
|
||||||
/// - **iOS:** Has no effect.
|
/// - **iOS:** Has no effect.
|
||||||
|
/// - **Web:** Has no effect.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_min_inner_size(&self, dimensions: Option<LogicalSize>) {
|
pub fn set_min_inner_size(&self, dimensions: Option<LogicalSize>) {
|
||||||
self.window.set_min_inner_size(dimensions)
|
self.window.set_min_inner_size(dimensions)
|
||||||
|
@ -486,6 +495,7 @@ impl Window {
|
||||||
/// ## Platform-specific
|
/// ## Platform-specific
|
||||||
///
|
///
|
||||||
/// - **iOS:** Has no effect.
|
/// - **iOS:** Has no effect.
|
||||||
|
/// - **Web:** Has no effect.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_max_inner_size(&self, dimensions: Option<LogicalSize>) {
|
pub fn set_max_inner_size(&self, dimensions: Option<LogicalSize>) {
|
||||||
self.window.set_max_inner_size(dimensions)
|
self.window.set_max_inner_size(dimensions)
|
||||||
|
@ -511,6 +521,7 @@ impl Window {
|
||||||
///
|
///
|
||||||
/// - **Android:** Has no effect.
|
/// - **Android:** Has no effect.
|
||||||
/// - **iOS:** Can only be called on the main thread.
|
/// - **iOS:** Can only be called on the main thread.
|
||||||
|
/// - **Web:** Has no effect.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_visible(&self, visible: bool) {
|
pub fn set_visible(&self, visible: bool) {
|
||||||
self.window.set_visible(visible)
|
self.window.set_visible(visible)
|
||||||
|
@ -530,6 +541,7 @@ impl Window {
|
||||||
/// ## Platform-specific
|
/// ## Platform-specific
|
||||||
///
|
///
|
||||||
/// - **iOS:** Has no effect.
|
/// - **iOS:** Has no effect.
|
||||||
|
/// - **Web:** Has no effect.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_resizable(&self, resizable: bool) {
|
pub fn set_resizable(&self, resizable: bool) {
|
||||||
self.window.set_resizable(resizable)
|
self.window.set_resizable(resizable)
|
||||||
|
@ -540,6 +552,7 @@ impl Window {
|
||||||
/// ## Platform-specific
|
/// ## Platform-specific
|
||||||
///
|
///
|
||||||
/// - **iOS:** Has no effect.
|
/// - **iOS:** Has no effect.
|
||||||
|
/// - **Web:** Has no effect.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_maximized(&self, maximized: bool) {
|
pub fn set_maximized(&self, maximized: bool) {
|
||||||
self.window.set_maximized(maximized)
|
self.window.set_maximized(maximized)
|
||||||
|
@ -585,8 +598,11 @@ impl Window {
|
||||||
/// Turn window decorations on or off.
|
/// Turn window decorations on or off.
|
||||||
///
|
///
|
||||||
/// ## Platform-specific
|
/// ## Platform-specific
|
||||||
|
/// - **iOS:** Can only be called on the main thread. Controls whether the status bar is hidden
|
||||||
|
/// via [`setPrefersStatusBarHidden`].
|
||||||
|
/// - **Web:** Has no effect.
|
||||||
///
|
///
|
||||||
/// - **iOS:** Has no effect.
|
/// [`setPrefersStatusBarHidden`]: https://developer.apple.com/documentation/uikit/uiviewcontroller/1621440-prefersstatusbarhidden?language=objc
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_decorations(&self, decorations: bool) {
|
pub fn set_decorations(&self, decorations: bool) {
|
||||||
self.window.set_decorations(decorations)
|
self.window.set_decorations(decorations)
|
||||||
|
@ -597,6 +613,7 @@ impl Window {
|
||||||
/// ## Platform-specific
|
/// ## Platform-specific
|
||||||
///
|
///
|
||||||
/// - **iOS:** Has no effect.
|
/// - **iOS:** Has no effect.
|
||||||
|
/// - **Web:** Has no effect.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_always_on_top(&self, always_on_top: bool) {
|
pub fn set_always_on_top(&self, always_on_top: bool) {
|
||||||
self.window.set_always_on_top(always_on_top)
|
self.window.set_always_on_top(always_on_top)
|
||||||
|
@ -620,6 +637,7 @@ impl Window {
|
||||||
/// ## Platform-specific
|
/// ## Platform-specific
|
||||||
///
|
///
|
||||||
/// **iOS:** Has no effect.
|
/// **iOS:** Has no effect.
|
||||||
|
/// - **Web:** Has no effect.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_ime_position(&self, position: LogicalPosition) {
|
pub fn set_ime_position(&self, position: LogicalPosition) {
|
||||||
self.window.set_ime_position(position)
|
self.window.set_ime_position(position)
|
||||||
|
@ -644,6 +662,7 @@ impl Window {
|
||||||
/// ## Platform-specific
|
/// ## Platform-specific
|
||||||
///
|
///
|
||||||
/// - **iOS:** Always returns an `Err`.
|
/// - **iOS:** Always returns an `Err`.
|
||||||
|
/// - **Web:** Has no effect.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_cursor_position(&self, position: LogicalPosition) -> Result<(), ExternalError> {
|
pub fn set_cursor_position(&self, position: LogicalPosition) -> Result<(), ExternalError> {
|
||||||
self.window.set_cursor_position(position)
|
self.window.set_cursor_position(position)
|
||||||
|
@ -657,6 +676,7 @@ impl Window {
|
||||||
/// awkward.
|
/// awkward.
|
||||||
/// - **Android:** Has no effect.
|
/// - **Android:** Has no effect.
|
||||||
/// - **iOS:** Always returns an Err.
|
/// - **iOS:** Always returns an Err.
|
||||||
|
/// - **Web:** Has no effect.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_cursor_grab(&self, grab: bool) -> Result<(), ExternalError> {
|
pub fn set_cursor_grab(&self, grab: bool) -> Result<(), ExternalError> {
|
||||||
self.window.set_cursor_grab(grab)
|
self.window.set_cursor_grab(grab)
|
||||||
|
|
Loading…
Reference in a new issue