Bump MSRV to 1.85 and edition to 2024
This commit is contained in:
parent
10f21090ce
commit
c333003514
110 changed files with 432 additions and 574 deletions
|
|
@ -2,8 +2,8 @@ use std::error::Error;
|
|||
use std::fmt::{self, Display, Formatter};
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
use pin_project::pin_project;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::future;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::mpsc::{self, RecvError, SendError, TryRecvError};
|
||||
use std::sync::Arc;
|
||||
use std::task::Poll;
|
||||
|
||||
use super::AtomicWaker;
|
||||
|
|
|
|||
|
|
@ -32,13 +32,10 @@ impl<T> ConcurrentQueue<T> {
|
|||
}
|
||||
|
||||
pub fn pop(&self) -> Result<T, PopError> {
|
||||
self.queue.borrow_mut().pop().ok_or_else(|| {
|
||||
if self.closed.get() {
|
||||
PopError::Closed
|
||||
} else {
|
||||
PopError::Empty
|
||||
}
|
||||
})
|
||||
self.queue
|
||||
.borrow_mut()
|
||||
.pop()
|
||||
.ok_or_else(|| if self.closed.get() { PopError::Closed } else { PopError::Empty })
|
||||
}
|
||||
|
||||
pub fn close(&self) -> bool {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::rc::Rc;
|
|||
use std::sync::{Arc, Condvar, Mutex};
|
||||
|
||||
use super::super::main_thread::MainThreadMarker;
|
||||
use super::{channel, Receiver, Sender, Wrapper};
|
||||
use super::{Receiver, Sender, Wrapper, channel};
|
||||
|
||||
pub struct Dispatcher<T: 'static>(Wrapper<T, Arc<Sender<Closure<T>>>, Closure<T>>);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ pub(crate) use atomic_waker::AtomicWaker;
|
|||
use concurrent_queue::{ConcurrentQueue, PushError};
|
||||
|
||||
pub use self::abortable::{AbortHandle, Abortable, DropAbortHandle};
|
||||
pub use self::channel::{channel, Receiver, Sender};
|
||||
pub use self::channel::{Receiver, Sender, channel};
|
||||
pub use self::dispatcher::{DispatchRunner, Dispatcher};
|
||||
pub use self::notifier::{Notified, Notifier};
|
||||
pub(crate) use self::wrapper::Wrapper;
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ use std::ops::{Deref, DerefMut};
|
|||
use std::pin::Pin;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use std::task::{ready, Context, Poll, Waker};
|
||||
use std::task::{Context, Poll, Waker, ready};
|
||||
use std::time::Duration;
|
||||
|
||||
use cursor_icon::CursorIcon;
|
||||
use js_sys::{Array, Object};
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen::closure::Closure;
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen_futures::JsFuture;
|
||||
use web_sys::{
|
||||
Blob, Document, DomException, HtmlCanvasElement, HtmlImageElement, ImageBitmap,
|
||||
|
|
@ -21,11 +21,11 @@ use web_sys::{
|
|||
};
|
||||
use winit_core::cursor::{Cursor, CursorImage, CustomCursorProvider, CustomCursorSource};
|
||||
|
||||
use crate::CustomCursorError;
|
||||
use crate::r#async::{AbortHandle, Abortable, DropAbortHandle, Notified, Notifier};
|
||||
use crate::backend::Style;
|
||||
use crate::event_loop::ActiveEventLoop;
|
||||
use crate::main_thread::{MainThreadMarker, MainThreadSafe};
|
||||
use crate::r#async::{AbortHandle, Abortable, DropAbortHandle, Notified, Notifier};
|
||||
use crate::CustomCursorError;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CustomCursor {
|
||||
|
|
@ -487,7 +487,7 @@ fn from_rgba(
|
|||
window: &Window,
|
||||
document: Document,
|
||||
image: &CursorImage,
|
||||
) -> impl Future<Output = Result<Image, CustomCursorError>> {
|
||||
) -> impl Future<Output = Result<Image, CustomCursorError>> + use<> {
|
||||
// 1. Create an `ImageData` from the RGBA data.
|
||||
// 2. Create an `ImageBitmap` from the `ImageData`.
|
||||
// 3. Draw `ImageBitmap` on an `HTMLCanvasElement`.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use winit_core::error::{EventLoopError, NotSupportedError};
|
|||
use winit_core::event_loop::ActiveEventLoop as RootActiveEventLoop;
|
||||
|
||||
use crate::{
|
||||
backend, HasMonitorPermissionFuture, MonitorPermissionFuture, PollStrategy, WaitUntilStrategy,
|
||||
HasMonitorPermissionFuture, MonitorPermissionFuture, PollStrategy, WaitUntilStrategy, backend,
|
||||
};
|
||||
|
||||
mod proxy;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
use std::future;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::task::Poll;
|
||||
|
||||
use winit_core::event_loop::EventLoopProxyProvider;
|
||||
|
||||
use super::super::main_thread::MainThreadMarker;
|
||||
use crate::event_loop::runner::WeakShared;
|
||||
use crate::r#async::{AtomicWaker, Wrapper};
|
||||
use crate::event_loop::runner::WeakShared;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct EventLoopProxy(Wrapper<WeakShared, Arc<State>, ()>);
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ use std::sync::Arc;
|
|||
use std::{fmt, iter};
|
||||
|
||||
use dpi::PhysicalSize;
|
||||
use wasm_bindgen::prelude::Closure;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen::prelude::Closure;
|
||||
use web_sys::{Document, KeyboardEvent, Navigator, PageTransitionEvent, PointerEvent, WheelEvent};
|
||||
use web_time::{Duration, Instant};
|
||||
use winit_core::application::ApplicationHandler;
|
||||
|
|
@ -19,14 +19,14 @@ use winit_core::window::WindowId;
|
|||
|
||||
use super::proxy::EventLoopProxy;
|
||||
use super::state::State;
|
||||
use crate::r#async::DispatchRunner;
|
||||
use crate::backend::{EventListenerHandle, SafeAreaHandle};
|
||||
use crate::event_loop::ActiveEventLoop;
|
||||
use crate::main_thread::MainThreadMarker;
|
||||
use crate::monitor::MonitorHandler;
|
||||
use crate::r#async::DispatchRunner;
|
||||
use crate::web_sys::event::ButtonsState;
|
||||
use crate::window::Inner;
|
||||
use crate::{backend, event, EventLoop, PollStrategy, WaitUntilStrategy};
|
||||
use crate::{EventLoop, PollStrategy, WaitUntilStrategy, backend, event};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Shared(Rc<Execution>);
|
||||
|
|
@ -802,11 +802,7 @@ impl Shared {
|
|||
DeviceEvents::Always => true,
|
||||
DeviceEvents::WhenFocused => {
|
||||
self.0.all_canvases.borrow().iter().any(|(_, canvas, _)| {
|
||||
if let Some(canvas) = canvas.upgrade() {
|
||||
canvas.has_focus.get()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
if let Some(canvas) = canvas.upgrade() { canvas.has_focus.get() } else { false }
|
||||
})
|
||||
},
|
||||
DeviceEvents::Never => false,
|
||||
|
|
|
|||
|
|
@ -522,13 +522,8 @@ impl RootActiveEventLoop for ActiveEventLoop {
|
|||
}
|
||||
|
||||
fn system_theme(&self) -> Option<Theme> {
|
||||
backend::is_dark_mode(self.runner.window()).map(|is_dark_mode| {
|
||||
if is_dark_mode {
|
||||
Theme::Dark
|
||||
} else {
|
||||
Theme::Light
|
||||
}
|
||||
})
|
||||
backend::is_dark_mode(self.runner.window())
|
||||
.map(|is_dark_mode| if is_dark_mode { Theme::Dark } else { Theme::Light })
|
||||
}
|
||||
|
||||
fn set_control_flow(&self, control_flow: ControlFlow) {
|
||||
|
|
|
|||
|
|
@ -61,9 +61,7 @@
|
|||
// compliant way.
|
||||
|
||||
macro_rules! os_error {
|
||||
($error:expr) => {{
|
||||
winit_core::error::OsError::new(line!(), file!(), $error)
|
||||
}};
|
||||
($error:expr) => {{ winit_core::error::OsError::new(line!(), file!(), $error) }};
|
||||
}
|
||||
|
||||
mod r#async;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use tracing::error;
|
|||
use wasm_bindgen::closure::Closure;
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
use wasm_bindgen::{JsCast, JsValue};
|
||||
use web_sys::{console, Document, DomException, Element, Navigator};
|
||||
use web_sys::{Document, DomException, Element, Navigator, console};
|
||||
|
||||
pub(crate) fn is_cursor_lock_raw(navigator: &Navigator, document: &Document) -> bool {
|
||||
thread_local! {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use std::ops::{Deref, DerefMut};
|
|||
use std::pin::Pin;
|
||||
use std::rc::{Rc, Weak};
|
||||
use std::sync::{Arc, OnceLock};
|
||||
use std::task::{ready, Context, Poll};
|
||||
use std::task::{Context, Poll, ready};
|
||||
|
||||
use dpi::{LogicalSize, PhysicalPosition, PhysicalSize};
|
||||
use js_sys::{Object, Promise};
|
||||
|
|
@ -19,14 +19,14 @@ use wasm_bindgen::prelude::wasm_bindgen;
|
|||
use wasm_bindgen::{JsCast, JsValue};
|
||||
use wasm_bindgen_futures::JsFuture;
|
||||
use web_sys::{
|
||||
console, DomException, Navigator, OrientationLockType, OrientationType, PermissionState,
|
||||
PermissionStatus, ScreenOrientation, Window,
|
||||
DomException, Navigator, OrientationLockType, OrientationType, PermissionState,
|
||||
PermissionStatus, ScreenOrientation, Window, console,
|
||||
};
|
||||
use winit_core::monitor::{MonitorHandle as CoreMonitorHandle, MonitorHandleProvider, VideoMode};
|
||||
|
||||
use super::r#async::{Dispatcher, Notified, Notifier};
|
||||
use super::event_loop::runner::WeakShared;
|
||||
use super::main_thread::MainThreadMarker;
|
||||
use super::r#async::{Dispatcher, Notified, Notifier};
|
||||
use super::web_sys::{Engine, EventListenerHandle};
|
||||
use crate::{
|
||||
MonitorPermissionError, Orientation, OrientationData, OrientationLock, OrientationLockError,
|
||||
|
|
@ -292,11 +292,7 @@ impl Inner {
|
|||
}
|
||||
|
||||
fn name(&self) -> Option<String> {
|
||||
if let Screen::Detailed { screen, .. } = &self.screen {
|
||||
Some(screen.label())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if let Screen::Detailed { screen, .. } = &self.screen { Some(screen.label()) } else { None }
|
||||
}
|
||||
|
||||
fn orientation_raw(&self) -> &ScreenOrientationExt {
|
||||
|
|
@ -438,11 +434,7 @@ impl Detailed {
|
|||
let internal_screen =
|
||||
internal_screen.upgrade().expect("dropped `MonitorHandle` without cleaning up");
|
||||
|
||||
if *internal_screen == screen {
|
||||
Some((*id, internal_screen))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if *internal_screen == screen { Some((*id, internal_screen)) } else { None }
|
||||
});
|
||||
let (id, screen) = if let Some((id, screen)) = found_screen {
|
||||
(id, screen)
|
||||
|
|
@ -664,7 +656,7 @@ impl MonitorHandler {
|
|||
State::Unsupported => {
|
||||
return MonitorPermissionFuture::Ready(Some(Err(
|
||||
MonitorPermissionError::Unsupported,
|
||||
)))
|
||||
)));
|
||||
},
|
||||
// If we are currently initializing, wait for initialization to finish before we do our
|
||||
// thing.
|
||||
|
|
@ -676,7 +668,7 @@ impl MonitorHandler {
|
|||
)
|
||||
.0,
|
||||
notified: notified.clone(),
|
||||
}
|
||||
};
|
||||
},
|
||||
// If we finished initialization we at least possess `PermissionStatus`.
|
||||
State::Permission { permission, .. } => permission,
|
||||
|
|
@ -688,7 +680,7 @@ impl MonitorHandler {
|
|||
match permission.state() {
|
||||
PermissionState::Granted | PermissionState::Prompt => (),
|
||||
PermissionState::Denied => {
|
||||
return MonitorPermissionFuture::Ready(Some(Err(MonitorPermissionError::Denied)))
|
||||
return MonitorPermissionFuture::Ready(Some(Err(MonitorPermissionError::Denied)));
|
||||
},
|
||||
_ => {
|
||||
error!("encountered unknown permission state: {}", permission.state_string());
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use wasm_bindgen::closure::Closure;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen::closure::Closure;
|
||||
|
||||
pub struct AnimationFrameHandler {
|
||||
window: web_sys::Window,
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ use std::sync::{Arc, Mutex};
|
|||
|
||||
use dpi::{LogicalPosition, PhysicalPosition, PhysicalSize};
|
||||
use smol_str::SmolStr;
|
||||
use wasm_bindgen::closure::Closure;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen::closure::Closure;
|
||||
use web_sys::{
|
||||
CssStyleDeclaration, Document, Event, FocusEvent, HtmlCanvasElement, KeyboardEvent, Navigator,
|
||||
PointerEvent, WheelEvent,
|
||||
|
|
@ -28,7 +28,7 @@ use super::event_handle::EventListenerHandle;
|
|||
use super::intersection_handle::IntersectionObserverHandle;
|
||||
use super::media_query_handle::MediaQueryListHandle;
|
||||
use super::pointer::PointerHandler;
|
||||
use super::{event, fullscreen, ResizeScaleHandle};
|
||||
use super::{ResizeScaleHandle, event, fullscreen};
|
||||
use crate::WindowAttributesWeb;
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
|
@ -502,8 +502,7 @@ impl Canvas {
|
|||
surface_size_writer: SurfaceSizeWriter::new(Arc::downgrade(&new_size)),
|
||||
});
|
||||
|
||||
let new_size = *new_size.lock().unwrap();
|
||||
new_size
|
||||
*new_size.lock().unwrap()
|
||||
};
|
||||
|
||||
if current_size != new_size {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use wasm_bindgen::prelude::Closure;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen::prelude::Closure;
|
||||
use web_sys::EventTarget;
|
||||
|
||||
pub struct EventListenerHandle<T: ?Sized> {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use tracing::error;
|
|||
use wasm_bindgen::closure::Closure;
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
use wasm_bindgen::{JsCast, JsValue};
|
||||
use web_sys::{console, Document, Element, HtmlCanvasElement, Window};
|
||||
use web_sys::{Document, Element, HtmlCanvasElement, Window, console};
|
||||
use winit_core::monitor::Fullscreen;
|
||||
|
||||
use crate::main_thread::MainThreadMarker;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use js_sys::Array;
|
||||
use wasm_bindgen::prelude::Closure;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen::prelude::Closure;
|
||||
use web_sys::{Element, IntersectionObserver, IntersectionObserverEntry};
|
||||
|
||||
pub(super) struct IntersectionObserverHandle {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use wasm_bindgen::prelude::Closure;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen::prelude::Closure;
|
||||
use web_sys::MediaQueryList;
|
||||
|
||||
pub(super) struct MediaQueryListHandle {
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ use std::cell::OnceCell;
|
|||
|
||||
use dpi::{LogicalPosition, LogicalSize};
|
||||
use js_sys::Array;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen::closure::Closure;
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
use wasm_bindgen::JsCast;
|
||||
use web_sys::{Document, HtmlCanvasElement, Navigator, PageTransitionEvent, VisibilityState};
|
||||
|
||||
pub use self::canvas::{Canvas, Style};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use std::rc::Rc;
|
|||
use dpi::{LogicalSize, PhysicalSize};
|
||||
use js_sys::{Array, Object};
|
||||
use tracing::warn;
|
||||
use wasm_bindgen::prelude::{wasm_bindgen, Closure};
|
||||
use wasm_bindgen::prelude::{Closure, wasm_bindgen};
|
||||
use wasm_bindgen::{JsCast, JsValue};
|
||||
use web_sys::{
|
||||
Document, HtmlCanvasElement, MediaQueryList, ResizeObserver, ResizeObserverBoxOptions,
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ use winit_core::window::{
|
|||
Window as RootWindow, WindowAttributes, WindowButtons, WindowId, WindowLevel,
|
||||
};
|
||||
|
||||
use crate::r#async::Dispatcher;
|
||||
use crate::event_loop::ActiveEventLoop;
|
||||
use crate::main_thread::MainThreadMarker;
|
||||
use crate::monitor::MonitorHandler;
|
||||
use crate::r#async::Dispatcher;
|
||||
use crate::{backend, lock};
|
||||
|
||||
pub struct Window {
|
||||
|
|
@ -284,11 +284,7 @@ impl RootWindow for Window {
|
|||
|
||||
fn fullscreen(&self) -> Option<Fullscreen> {
|
||||
self.inner.queue(|inner| {
|
||||
if inner.canvas.is_fullscreen() {
|
||||
Some(Fullscreen::Borderless(None))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if inner.canvas.is_fullscreen() { Some(Fullscreen::Borderless(None)) } else { None }
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -334,13 +330,8 @@ impl RootWindow for Window {
|
|||
|
||||
fn theme(&self) -> Option<Theme> {
|
||||
self.inner.queue(|inner| {
|
||||
backend::is_dark_mode(&inner.window).map(|is_dark_mode| {
|
||||
if is_dark_mode {
|
||||
Theme::Dark
|
||||
} else {
|
||||
Theme::Light
|
||||
}
|
||||
})
|
||||
backend::is_dark_mode(&inner.window)
|
||||
.map(|is_dark_mode| if is_dark_mode { Theme::Dark } else { Theme::Light })
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -368,7 +359,7 @@ impl RootWindow for Window {
|
|||
inner.canvas.raw(),
|
||||
),
|
||||
CursorGrabMode::Confined => {
|
||||
return Err(NotSupportedError::new("confined cursor mode is not supported"))
|
||||
return Err(NotSupportedError::new("confined cursor mode is not supported"));
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue