chore(rustfmt): use nightly (#2325)
Stable rustfmt lacks a lot of features resulting in worse formatted code, thus use nightly formatter.
This commit is contained in:
parent
7006c7ceca
commit
7b0c7b6cb2
154 changed files with 3439 additions and 5891 deletions
|
|
@ -58,16 +58,19 @@
|
|||
//!
|
||||
//! ## Converting from `ndk-glue` to `android-activity`
|
||||
//!
|
||||
//! If your application is currently based on `NativeActivity` via the `ndk-glue` crate and building with `cargo apk`, then the minimal changes would be:
|
||||
//! If your application is currently based on `NativeActivity` via the `ndk-glue` crate and building
|
||||
//! with `cargo apk`, then the minimal changes would be:
|
||||
//! 1. Remove `ndk-glue` from your `Cargo.toml`
|
||||
//! 2. Enable the `"android-native-activity"` feature for Winit: `winit = { version = "0.29.15", features = [ "android-native-activity" ] }`
|
||||
//! 3. Add an `android_main` entrypoint (as above), instead of using the '`[ndk_glue::main]` proc macro from `ndk-macros` (optionally add a dependency on `android_logger` and initialize logging as above).
|
||||
//! 4. Pass a clone of the `AndroidApp` that your application receives to Winit when building your event loop (as shown above).
|
||||
//! 2. Enable the `"android-native-activity"` feature for Winit: `winit = { version = "0.29.15",
|
||||
//! features = [ "android-native-activity" ] }`
|
||||
//! 3. Add an `android_main` entrypoint (as above), instead of using the '`[ndk_glue::main]` proc
|
||||
//! macro from `ndk-macros` (optionally add a dependency on `android_logger` and initialize
|
||||
//! logging as above).
|
||||
//! 4. Pass a clone of the `AndroidApp` that your application receives to Winit when building your
|
||||
//! event loop (as shown above).
|
||||
|
||||
use crate::{
|
||||
event_loop::{ActiveEventLoop, EventLoop, EventLoopBuilder},
|
||||
window::{Window, WindowAttributes},
|
||||
};
|
||||
use crate::event_loop::{ActiveEventLoop, EventLoop, EventLoopBuilder};
|
||||
use crate::window::{Window, WindowAttributes};
|
||||
|
||||
use self::activity::{AndroidApp, ConfigurationRef, Rect};
|
||||
|
||||
|
|
@ -146,7 +149,7 @@ impl<T> EventLoopBuilderExtAndroid for EventLoopBuilder<T> {
|
|||
/// For compatibility applications should then import the `AndroidApp` type for
|
||||
/// their `android_main(app: AndroidApp)` function like:
|
||||
/// ```rust
|
||||
/// #[cfg(target_os="android")]
|
||||
/// #[cfg(target_os = "android")]
|
||||
/// use winit::platform::android::activity::AndroidApp;
|
||||
/// ```
|
||||
pub mod activity {
|
||||
|
|
|
|||
|
|
@ -66,11 +66,9 @@
|
|||
|
||||
use std::os::raw::c_void;
|
||||
|
||||
use crate::{
|
||||
event_loop::EventLoop,
|
||||
monitor::{MonitorHandle, VideoModeHandle},
|
||||
window::{Window, WindowAttributes},
|
||||
};
|
||||
use crate::event_loop::EventLoop;
|
||||
use crate::monitor::{MonitorHandle, VideoModeHandle};
|
||||
use crate::window::{Window, WindowAttributes};
|
||||
|
||||
/// Additional methods on [`EventLoop`] that are specific to iOS.
|
||||
pub trait EventLoopExtIOS {
|
||||
|
|
@ -171,20 +169,17 @@ pub trait WindowExtIOS {
|
|||
impl WindowExtIOS for Window {
|
||||
#[inline]
|
||||
fn set_scale_factor(&self, scale_factor: f64) {
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_scale_factor(scale_factor))
|
||||
self.window.maybe_queue_on_main(move |w| w.set_scale_factor(scale_factor))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_valid_orientations(&self, valid_orientations: ValidOrientations) {
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_valid_orientations(valid_orientations))
|
||||
self.window.maybe_queue_on_main(move |w| w.set_valid_orientations(valid_orientations))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_prefers_home_indicator_hidden(&self, hidden: bool) {
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_prefers_home_indicator_hidden(hidden))
|
||||
self.window.maybe_queue_on_main(move |w| w.set_prefers_home_indicator_hidden(hidden))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -196,32 +191,27 @@ impl WindowExtIOS for Window {
|
|||
|
||||
#[inline]
|
||||
fn set_prefers_status_bar_hidden(&self, hidden: bool) {
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_prefers_status_bar_hidden(hidden))
|
||||
self.window.maybe_queue_on_main(move |w| w.set_prefers_status_bar_hidden(hidden))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_preferred_status_bar_style(&self, status_bar_style: StatusBarStyle) {
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_preferred_status_bar_style(status_bar_style))
|
||||
self.window.maybe_queue_on_main(move |w| w.set_preferred_status_bar_style(status_bar_style))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn recognize_pinch_gesture(&self, should_recognize: bool) {
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.recognize_pinch_gesture(should_recognize));
|
||||
self.window.maybe_queue_on_main(move |w| w.recognize_pinch_gesture(should_recognize));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn recognize_doubletap_gesture(&self, should_recognize: bool) {
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.recognize_doubletap_gesture(should_recognize));
|
||||
self.window.maybe_queue_on_main(move |w| w.recognize_doubletap_gesture(should_recognize));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn recognize_rotation_gesture(&self, should_recognize: bool) {
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.recognize_rotation_gesture(should_recognize));
|
||||
self.window.maybe_queue_on_main(move |w| w.recognize_rotation_gesture(should_recognize));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -301,8 +291,7 @@ impl WindowAttributesExtIOS for WindowAttributes {
|
|||
|
||||
#[inline]
|
||||
fn with_preferred_screen_edges_deferring_system_gestures(mut self, edges: ScreenEdge) -> Self {
|
||||
self.platform_specific
|
||||
.preferred_screen_edges_deferring_system_gestures = edges;
|
||||
self.platform_specific.preferred_screen_edges_deferring_system_gestures = edges;
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -342,9 +331,7 @@ impl MonitorHandleExtIOS for MonitorHandle {
|
|||
|
||||
#[inline]
|
||||
fn preferred_video_mode(&self) -> VideoModeHandle {
|
||||
VideoModeHandle {
|
||||
video_mode: self.inner.preferred_video_mode(),
|
||||
}
|
||||
VideoModeHandle { video_mode: self.inner.preferred_video_mode() }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,11 +19,9 @@ use std::os::raw::c_void;
|
|||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
event_loop::{ActiveEventLoop, EventLoopBuilder},
|
||||
monitor::MonitorHandle,
|
||||
window::{Window, WindowAttributes},
|
||||
};
|
||||
use crate::event_loop::{ActiveEventLoop, EventLoopBuilder};
|
||||
use crate::monitor::MonitorHandle;
|
||||
use crate::window::{Window, WindowAttributes};
|
||||
|
||||
/// Additional methods on [`Window`] that are specific to MacOS.
|
||||
pub trait WindowExtMacOS {
|
||||
|
|
@ -106,8 +104,7 @@ impl WindowExtMacOS for Window {
|
|||
|
||||
#[inline]
|
||||
fn set_simple_fullscreen(&self, fullscreen: bool) -> bool {
|
||||
self.window
|
||||
.maybe_wait_on_main(move |w| w.set_simple_fullscreen(fullscreen))
|
||||
self.window.maybe_wait_on_main(move |w| w.set_simple_fullscreen(fullscreen))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -117,14 +114,12 @@ impl WindowExtMacOS for Window {
|
|||
|
||||
#[inline]
|
||||
fn set_has_shadow(&self, has_shadow: bool) {
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_has_shadow(has_shadow))
|
||||
self.window.maybe_queue_on_main(move |w| w.set_has_shadow(has_shadow))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_tabbing_identifier(&self, identifier: &str) {
|
||||
self.window
|
||||
.maybe_wait_on_main(|w| w.set_tabbing_identifier(identifier))
|
||||
self.window.maybe_wait_on_main(|w| w.set_tabbing_identifier(identifier))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -144,8 +139,7 @@ impl WindowExtMacOS for Window {
|
|||
|
||||
#[inline]
|
||||
fn select_tab_at_index(&self, index: usize) {
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.select_tab_at_index(index))
|
||||
self.window.maybe_queue_on_main(move |w| w.select_tab_at_index(index))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -160,14 +154,12 @@ impl WindowExtMacOS for Window {
|
|||
|
||||
#[inline]
|
||||
fn set_document_edited(&self, edited: bool) {
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_document_edited(edited))
|
||||
self.window.maybe_queue_on_main(move |w| w.set_document_edited(edited))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_option_as_alt(&self, option_as_alt: OptionAsAlt) {
|
||||
self.window
|
||||
.maybe_queue_on_main(move |w| w.set_option_as_alt(option_as_alt))
|
||||
self.window.maybe_queue_on_main(move |w| w.set_option_as_alt(option_as_alt))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -192,7 +184,8 @@ pub enum ActivationPolicy {
|
|||
|
||||
/// Additional methods on [`WindowAttributes`] that are specific to MacOS.
|
||||
///
|
||||
/// **Note:** Properties dealing with the titlebar will be overwritten by the [`WindowAttributes::with_decorations`] method:
|
||||
/// **Note:** Properties dealing with the titlebar will be overwritten by the
|
||||
/// [`WindowAttributes::with_decorations`] method:
|
||||
/// - `with_titlebar_transparent`
|
||||
/// - `with_title_hidden`
|
||||
/// - `with_titlebar_hidden`
|
||||
|
|
@ -282,9 +275,7 @@ impl WindowAttributesExtMacOS for WindowAttributes {
|
|||
|
||||
#[inline]
|
||||
fn with_tabbing_identifier(mut self, tabbing_identifier: &str) -> Self {
|
||||
self.platform_specific
|
||||
.tabbing_identifier
|
||||
.replace(tabbing_identifier.to_string());
|
||||
self.platform_specific.tabbing_identifier.replace(tabbing_identifier.to_string());
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -307,7 +298,7 @@ pub trait EventLoopBuilderExtMacOS {
|
|||
/// ```
|
||||
/// use winit::event_loop::EventLoopBuilder;
|
||||
/// #[cfg(target_os = "macos")]
|
||||
/// use winit::platform::macos::{EventLoopBuilderExtMacOS, ActivationPolicy};
|
||||
/// use winit::platform::macos::{ActivationPolicy, EventLoopBuilderExtMacOS};
|
||||
///
|
||||
/// let mut builder = EventLoopBuilder::new();
|
||||
/// #[cfg(target_os = "macos")]
|
||||
|
|
@ -384,17 +375,17 @@ impl MonitorHandleExtMacOS for MonitorHandle {
|
|||
fn ns_screen(&self) -> Option<*mut c_void> {
|
||||
// SAFETY: We only use the marker to get a pointer
|
||||
let mtm = unsafe { objc2_foundation::MainThreadMarker::new_unchecked() };
|
||||
self.inner
|
||||
.ns_screen(mtm)
|
||||
.map(|s| objc2::rc::Id::as_ptr(&s) as _)
|
||||
self.inner.ns_screen(mtm).map(|s| objc2::rc::Id::as_ptr(&s) as _)
|
||||
}
|
||||
}
|
||||
|
||||
/// Additional methods on [`ActiveEventLoop`] that are specific to macOS.
|
||||
pub trait ActiveEventLoopExtMacOS {
|
||||
/// Hide the entire application. In most applications this is typically triggered with Command-H.
|
||||
/// Hide the entire application. In most applications this is typically triggered with
|
||||
/// Command-H.
|
||||
fn hide_application(&self);
|
||||
/// Hide the other applications. In most applications this is typically triggered with Command+Option-H.
|
||||
/// Hide the other applications. In most applications this is typically triggered with
|
||||
/// Command+Option-H.
|
||||
fn hide_other_applications(&self);
|
||||
/// Set whether the system can automatically organize windows into tabs.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -51,11 +51,5 @@ pub mod pump_events;
|
|||
))]
|
||||
pub mod modifier_supplement;
|
||||
|
||||
#[cfg(any(
|
||||
windows_platform,
|
||||
macos_platform,
|
||||
x11_platform,
|
||||
wayland_platform,
|
||||
docsrs
|
||||
))]
|
||||
#[cfg(any(windows_platform, macos_platform, x11_platform, wayland_platform, docsrs))]
|
||||
pub mod scancode;
|
||||
|
|
|
|||
|
|
@ -25,10 +25,7 @@ pub trait KeyEventExtModifierSupplement {
|
|||
impl KeyEventExtModifierSupplement for KeyEvent {
|
||||
#[inline]
|
||||
fn text_with_all_modifiers(&self) -> Option<&str> {
|
||||
self.platform_specific
|
||||
.text_with_all_modifiers
|
||||
.as_ref()
|
||||
.map(|s| s.as_str())
|
||||
self.platform_specific.text_with_all_modifiers.as_ref().map(|s| s.as_str())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
|||
|
|
@ -84,12 +84,11 @@ pub trait EventLoopExtPumpEvents {
|
|||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **Windows**: The implementation will use `PeekMessage` when checking for
|
||||
/// window messages to avoid blocking your external event loop.
|
||||
/// - **Windows**: The implementation will use `PeekMessage` when checking for window messages
|
||||
/// to avoid blocking your external event loop.
|
||||
///
|
||||
/// - **MacOS**: The implementation works in terms of stopping the global application
|
||||
/// whenever the application `RunLoop` indicates that it is preparing to block
|
||||
/// and wait for new events.
|
||||
/// - **MacOS**: The implementation works in terms of stopping the global application whenever
|
||||
/// the application `RunLoop` indicates that it is preparing to block and wait for new events.
|
||||
///
|
||||
/// This is very different to the polling APIs that are available on other
|
||||
/// platforms (the lower level polling primitives on MacOS are private
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ pub trait EventLoopExtRunOnDemand {
|
|||
|
||||
/// Run the application with the event loop on the calling thread.
|
||||
///
|
||||
/// Unlike [`EventLoop::run_app`], this function accepts non-`'static` (i.e. non-`move`) closures
|
||||
/// and it is possible to return control back to the caller without
|
||||
/// Unlike [`EventLoop::run_app`], this function accepts non-`'static` (i.e. non-`move`)
|
||||
/// closures and it is possible to return control back to the caller without
|
||||
/// consuming the `EventLoop` (by using [`exit()`]) and
|
||||
/// so the event loop can be re-run after it has exit.
|
||||
///
|
||||
|
|
@ -55,17 +55,13 @@ pub trait EventLoopExtRunOnDemand {
|
|||
/// - Android
|
||||
///
|
||||
/// # Unsupported Platforms
|
||||
/// - **Web:** This API is fundamentally incompatible with the event-based way in which
|
||||
/// Web browsers work because it's not possible to have a long-running external
|
||||
/// loop that would block the browser and there is nothing that can be
|
||||
/// polled to ask for new events. Events are delivered via callbacks based
|
||||
/// on an event loop that is internal to the browser itself.
|
||||
/// - **Web:** This API is fundamentally incompatible with the event-based way in which Web
|
||||
/// browsers work because it's not possible to have a long-running external loop that would
|
||||
/// block the browser and there is nothing that can be polled to ask for new events. Events
|
||||
/// are delivered via callbacks based on an event loop that is internal to the browser itself.
|
||||
/// - **iOS:** It's not possible to stop and start an `UIApplication` repeatedly on iOS.
|
||||
///
|
||||
#[cfg_attr(
|
||||
not(web_platform),
|
||||
doc = "[^1]: `spawn()` is only available on `wasm` platforms."
|
||||
)]
|
||||
#[cfg_attr(not(web_platform), doc = "[^1]: `spawn()` is only available on `wasm` platforms.")]
|
||||
#[rustfmt::skip]
|
||||
///
|
||||
/// [`exit()`]: ActiveEventLoop::exit()
|
||||
/// [`set_control_flow()`]: ActiveEventLoop::set_control_flow()
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ use crate::keyboard::{KeyCode, PhysicalKey};
|
|||
|
||||
// TODO: Describe what this value contains for each platform
|
||||
|
||||
/// Additional methods for the [`PhysicalKey`] type that allow the user to access the platform-specific
|
||||
/// scancode.
|
||||
/// Additional methods for the [`PhysicalKey`] type that allow the user to access the
|
||||
/// platform-specific scancode.
|
||||
///
|
||||
/// [`PhysicalKey`]: crate::keyboard::PhysicalKey
|
||||
pub trait PhysicalKeyExtScancode {
|
||||
|
|
@ -23,7 +23,7 @@ pub trait PhysicalKeyExtScancode {
|
|||
///
|
||||
/// ## Platform-specific
|
||||
/// - **Wayland/X11**: A 32-bit linux scancode. When building from X11/Wayland keycode subtract
|
||||
/// `8` to get the value you wanted.
|
||||
/// `8` to get the value you wanted.
|
||||
fn from_scancode(scancode: u32) -> PhysicalKey;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,11 +13,9 @@
|
|||
//! * `wayland-csd-adwaita` (default).
|
||||
//! * `wayland-csd-adwaita-crossfont`.
|
||||
//! * `wayland-csd-adwaita-notitle`.
|
||||
use crate::{
|
||||
event_loop::{ActiveEventLoop, EventLoopBuilder},
|
||||
monitor::MonitorHandle,
|
||||
window::{Window, WindowAttributes},
|
||||
};
|
||||
use crate::event_loop::{ActiveEventLoop, EventLoopBuilder};
|
||||
use crate::monitor::MonitorHandle;
|
||||
use crate::window::{Window, WindowAttributes};
|
||||
|
||||
pub use crate::window::Theme;
|
||||
|
||||
|
|
@ -80,10 +78,8 @@ pub trait WindowAttributesExtWayland {
|
|||
impl WindowAttributesExtWayland for WindowAttributes {
|
||||
#[inline]
|
||||
fn with_name(mut self, general: impl Into<String>, instance: impl Into<String>) -> Self {
|
||||
self.platform_specific.name = Some(crate::platform_impl::ApplicationName::new(
|
||||
general.into(),
|
||||
instance.into(),
|
||||
));
|
||||
self.platform_specific.name =
|
||||
Some(crate::platform_impl::ApplicationName::new(general.into(), instance.into()));
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@
|
|||
//! The following APIs can't take them into account and will therefore provide inaccurate results:
|
||||
//! - [`WindowEvent::Resized`] and [`Window::(set_)inner_size()`]
|
||||
//! - [`WindowEvent::Occluded`]
|
||||
//! - [`WindowEvent::CursorMoved`], [`WindowEvent::CursorEntered`], [`WindowEvent::CursorLeft`],
|
||||
//! and [`WindowEvent::Touch`].
|
||||
//! - [`WindowEvent::CursorMoved`], [`WindowEvent::CursorEntered`], [`WindowEvent::CursorLeft`], and
|
||||
//! [`WindowEvent::Touch`].
|
||||
//! - [`Window::set_outer_position()`]
|
||||
//!
|
||||
//! [`WindowEvent::Resized`]: crate::event::WindowEvent::Resized
|
||||
|
|
@ -109,11 +109,7 @@ pub trait WindowAttributesExtWebSys {
|
|||
/// In any case, the canvas won't be automatically inserted into the web page.
|
||||
///
|
||||
/// [`None`] by default.
|
||||
#[cfg_attr(
|
||||
not(web_platform),
|
||||
doc = "",
|
||||
doc = "[`HtmlCanvasElement`]: #only-available-on-wasm"
|
||||
)]
|
||||
#[cfg_attr(not(web_platform), doc = "", doc = "[`HtmlCanvasElement`]: #only-available-on-wasm")]
|
||||
fn with_canvas(self, canvas: Option<HtmlCanvasElement>) -> Self;
|
||||
|
||||
/// Sets whether `event.preventDefault()` should be called on events on the
|
||||
|
|
@ -166,10 +162,7 @@ pub trait EventLoopExtWebSys {
|
|||
/// Initializes the winit event loop.
|
||||
///
|
||||
/// Unlike
|
||||
#[cfg_attr(
|
||||
all(web_platform, target_feature = "exception-handling"),
|
||||
doc = "`run_app()`"
|
||||
)]
|
||||
#[cfg_attr(all(web_platform, target_feature = "exception-handling"), doc = "`run_app()`")]
|
||||
#[cfg_attr(
|
||||
not(all(web_platform, target_feature = "exception-handling")),
|
||||
doc = "[`run_app()`]"
|
||||
|
|
@ -181,6 +174,7 @@ pub trait EventLoopExtWebSys {
|
|||
/// by calling this function again. This can be useful if you want to recreate the event loop
|
||||
/// while the WebAssembly module is still loaded. For example, this can be used to recreate the
|
||||
/// event loop when switching between tabs on a single page application.
|
||||
#[rustfmt::skip]
|
||||
///
|
||||
#[cfg_attr(
|
||||
not(all(web_platform, target_feature = "exception-handling")),
|
||||
|
|
@ -303,13 +297,7 @@ impl CustomCursorExtWebSys for CustomCursor {
|
|||
}
|
||||
|
||||
fn from_url(url: String, hotspot_x: u16, hotspot_y: u16) -> CustomCursorSource {
|
||||
CustomCursorSource {
|
||||
inner: PlatformCustomCursorSource::Url {
|
||||
url,
|
||||
hotspot_x,
|
||||
hotspot_y,
|
||||
},
|
||||
}
|
||||
CustomCursorSource { inner: PlatformCustomCursorSource::Url { url, hotspot_x, hotspot_y } }
|
||||
}
|
||||
|
||||
fn from_animation(
|
||||
|
|
@ -360,9 +348,7 @@ impl Future for CustomCursorFuture {
|
|||
type Output = Result<CustomCursor, CustomCursorError>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
Pin::new(&mut self.0)
|
||||
.poll(cx)
|
||||
.map_ok(|cursor| CustomCursor { inner: cursor })
|
||||
Pin::new(&mut self.0).poll(cx).map_ok(|cursor| CustomCursor { inner: cursor })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -378,10 +364,9 @@ impl Display for CustomCursorError {
|
|||
match self {
|
||||
Self::Blob => write!(f, "failed to create `Blob`"),
|
||||
Self::Decode(error) => write!(f, "failed to decode image: {error}"),
|
||||
Self::Animation => write!(
|
||||
f,
|
||||
"found `CustomCursor` that is an animation when building an animation"
|
||||
),
|
||||
Self::Animation => {
|
||||
write!(f, "found `CustomCursor` that is an animation when building an animation")
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,15 +2,14 @@
|
|||
//!
|
||||
//! The supported OS version is Windows 7 or higher, though Windows 10 is
|
||||
//! tested regularly.
|
||||
use std::{ffi::c_void, path::Path};
|
||||
use std::ffi::c_void;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::{
|
||||
dpi::PhysicalSize,
|
||||
event::DeviceId,
|
||||
event_loop::EventLoopBuilder,
|
||||
monitor::MonitorHandle,
|
||||
window::{BadIcon, Icon, Window, WindowAttributes},
|
||||
};
|
||||
use crate::dpi::PhysicalSize;
|
||||
use crate::event::DeviceId;
|
||||
use crate::event_loop::EventLoopBuilder;
|
||||
use crate::monitor::MonitorHandle;
|
||||
use crate::window::{BadIcon, Icon, Window, WindowAttributes};
|
||||
|
||||
/// Window Handle type used by Win32 API
|
||||
pub type HWND = isize;
|
||||
|
|
@ -57,11 +56,11 @@ pub enum BackdropType {
|
|||
pub struct Color(u32);
|
||||
|
||||
impl Color {
|
||||
// Special constant only valid for the window border and therefore modeled using Option<Color>
|
||||
// for user facing code
|
||||
const NONE: Color = Color(0xfffffffe);
|
||||
/// Use the system's default color
|
||||
pub const SYSTEM_DEFAULT: Color = Color(0xFFFFFFFF);
|
||||
|
||||
//Special constant only valid for the window border and therefore modeled using Option<Color> for user facing code
|
||||
const NONE: Color = Color(0xFFFFFFFE);
|
||||
pub const SYSTEM_DEFAULT: Color = Color(0xffffffff);
|
||||
|
||||
/// Create a new color from the given RGB values
|
||||
pub const fn from_rgb(r: u8, g: u8, b: u8) -> Self {
|
||||
|
|
@ -202,8 +201,8 @@ pub trait WindowExtWindows {
|
|||
///
|
||||
/// A window must be enabled before it can be activated.
|
||||
/// If an application has create a modal dialog box by disabling its owner window
|
||||
/// (as described in [`WindowAttributesExtWindows::with_owner_window`]), the application must enable
|
||||
/// the owner window before destroying the dialog box.
|
||||
/// (as described in [`WindowAttributesExtWindows::with_owner_window`]), the application must
|
||||
/// enable the owner window before destroying the dialog box.
|
||||
/// Otherwise, another window will receive the keyboard focus and be activated.
|
||||
///
|
||||
/// If a child window is disabled, it is ignored when the system tries to determine which
|
||||
|
|
@ -283,10 +282,10 @@ impl WindowExtWindows for Window {
|
|||
|
||||
#[inline]
|
||||
fn set_title_background_color(&self, color: Option<Color>) {
|
||||
// The windows docs don't mention NONE as a valid options but it works in practice and is useful
|
||||
// to circumvent the Windows option "Show accent color on title bars and window borders"
|
||||
self.window
|
||||
.set_title_background_color(color.unwrap_or(Color::NONE))
|
||||
// The windows docs don't mention NONE as a valid options but it works in practice and is
|
||||
// useful to circumvent the Windows option "Show accent color on title bars and
|
||||
// window borders"
|
||||
self.window.set_title_background_color(color.unwrap_or(Color::NONE))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -305,8 +304,9 @@ impl WindowExtWindows for Window {
|
|||
pub trait WindowAttributesExtWindows {
|
||||
/// Set an owner to the window to be created. Can be used to create a dialog box, for example.
|
||||
/// This only works when [`WindowAttributes::with_parent_window`] isn't called or set to `None`.
|
||||
/// Can be used in combination with [`WindowExtWindows::set_enable(false)`][WindowExtWindows::set_enable]
|
||||
/// on the owner window to create a modal dialog box.
|
||||
/// Can be used in combination with
|
||||
/// [`WindowExtWindows::set_enable(false)`][WindowExtWindows::set_enable] on the owner
|
||||
/// window to create a modal dialog box.
|
||||
///
|
||||
/// From MSDN:
|
||||
/// - An owned window is always above its owner in the z-order.
|
||||
|
|
@ -322,17 +322,14 @@ pub trait WindowAttributesExtWindows {
|
|||
///
|
||||
/// The menu must have been manually created beforehand with [`CreateMenu`] or similar.
|
||||
///
|
||||
/// Note: Dark mode cannot be supported for win32 menus, it's simply not possible to change how the menus look.
|
||||
/// If you use this, it is recommended that you combine it with `with_theme(Some(Theme::Light))` to avoid a jarring effect.
|
||||
///
|
||||
/// Note: Dark mode cannot be supported for win32 menus, it's simply not possible to change how
|
||||
/// the menus look. If you use this, it is recommended that you combine it with
|
||||
/// `with_theme(Some(Theme::Light))` to avoid a jarring effect.
|
||||
#[cfg_attr(
|
||||
platform_windows,
|
||||
doc = "[`CreateMenu`]: windows_sys::Win32::UI::WindowsAndMessaging::CreateMenu"
|
||||
)]
|
||||
#[cfg_attr(
|
||||
not(platform_windows),
|
||||
doc = "[`CreateMenu`]: #only-available-on-windows"
|
||||
)]
|
||||
#[cfg_attr(not(platform_windows), doc = "[`CreateMenu`]: #only-available-on-windows")]
|
||||
fn with_menu(self, menu: HMENU) -> Self;
|
||||
|
||||
/// This sets `ICON_BIG`. A good ceiling here is 256x256.
|
||||
|
|
@ -341,12 +338,12 @@ pub trait WindowAttributesExtWindows {
|
|||
/// This sets `WS_EX_NOREDIRECTIONBITMAP`.
|
||||
fn with_no_redirection_bitmap(self, flag: bool) -> Self;
|
||||
|
||||
/// Enables or disables drag and drop support (enabled by default). Will interfere with other crates
|
||||
/// that use multi-threaded COM API (`CoInitializeEx` with `COINIT_MULTITHREADED` instead of
|
||||
/// `COINIT_APARTMENTTHREADED`) on the same thread. Note that winit may still attempt to initialize
|
||||
/// COM API regardless of this option. Currently only fullscreen mode does that, but there may be more in the future.
|
||||
/// If you need COM API with `COINIT_MULTITHREADED` you must initialize it before calling any winit functions.
|
||||
/// See <https://docs.microsoft.com/en-us/windows/win32/api/objbase/nf-objbase-coinitialize#remarks> for more information.
|
||||
/// Enables or disables drag and drop support (enabled by default). Will interfere with other
|
||||
/// crates that use multi-threaded COM API (`CoInitializeEx` with `COINIT_MULTITHREADED`
|
||||
/// instead of `COINIT_APARTMENTTHREADED`) on the same thread. Note that winit may still
|
||||
/// attempt to initialize COM API regardless of this option. Currently only fullscreen mode
|
||||
/// does that, but there may be more in the future. If you need COM API with
|
||||
/// `COINIT_MULTITHREADED` you must initialize it before calling any winit functions. See <https://docs.microsoft.com/en-us/windows/win32/api/objbase/nf-objbase-coinitialize#remarks> for more information.
|
||||
fn with_drag_and_drop(self, flag: bool) -> Self;
|
||||
|
||||
/// Whether show or hide the window icon in the taskbar.
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@
|
|||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
event_loop::{ActiveEventLoop, EventLoopBuilder},
|
||||
monitor::MonitorHandle,
|
||||
window::{Window, WindowAttributes},
|
||||
};
|
||||
use crate::event_loop::{ActiveEventLoop, EventLoopBuilder};
|
||||
use crate::monitor::MonitorHandle;
|
||||
use crate::window::{Window, WindowAttributes};
|
||||
|
||||
use crate::dpi::Size;
|
||||
|
||||
|
|
@ -15,11 +13,12 @@ use crate::dpi::Size;
|
|||
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub enum WindowType {
|
||||
/// A desktop feature. This can include a single window containing desktop icons with the same dimensions as the
|
||||
/// screen, allowing the desktop environment to have full control of the desktop, without the need for proxying
|
||||
/// root window clicks.
|
||||
/// A desktop feature. This can include a single window containing desktop icons with the same
|
||||
/// dimensions as the screen, allowing the desktop environment to have full control of the
|
||||
/// desktop, without the need for proxying root window clicks.
|
||||
Desktop,
|
||||
/// A dock or panel feature. Typically a Window Manager would keep such windows on top of all other windows.
|
||||
/// A dock or panel feature. Typically a Window Manager would keep such windows on top of all
|
||||
/// other windows.
|
||||
Dock,
|
||||
/// Toolbar windows. "Torn off" from the main application.
|
||||
Toolbar,
|
||||
|
|
@ -37,8 +36,8 @@ pub enum WindowType {
|
|||
/// A popup menu that usually appears when the user right clicks on an object.
|
||||
/// This property is typically used on override-redirect windows.
|
||||
PopupMenu,
|
||||
/// A tooltip window. Usually used to show additional information when hovering over an object with the cursor.
|
||||
/// This property is typically used on override-redirect windows.
|
||||
/// A tooltip window. Usually used to show additional information when hovering over an object
|
||||
/// with the cursor. This property is typically used on override-redirect windows.
|
||||
Tooltip,
|
||||
/// The window is a notification.
|
||||
/// This property is typically used on override-redirect windows.
|
||||
|
|
@ -83,10 +82,7 @@ pub type XWindow = u32;
|
|||
pub fn register_xlib_error_hook(hook: XlibErrorHook) {
|
||||
// Append new hook.
|
||||
unsafe {
|
||||
crate::platform_impl::XLIB_ERROR_HOOKS
|
||||
.lock()
|
||||
.unwrap()
|
||||
.push(hook);
|
||||
crate::platform_impl::XLIB_ERROR_HOOKS.lock().unwrap().push(hook);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +140,8 @@ pub trait WindowAttributesExtX11 {
|
|||
/// Build window with the given `general` and `instance` names.
|
||||
///
|
||||
/// The `general` sets general class of `WM_CLASS(STRING)`, while `instance` set the
|
||||
/// instance part of it. The resulted property looks like `WM_CLASS(STRING) = "instance", "general"`.
|
||||
/// instance part of it. The resulted property looks like `WM_CLASS(STRING) = "instance",
|
||||
/// "general"`.
|
||||
///
|
||||
/// For details about application ID conventions, see the
|
||||
/// [Desktop Entry Spec](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#desktop-file-id)
|
||||
|
|
@ -202,10 +199,8 @@ impl WindowAttributesExtX11 for WindowAttributes {
|
|||
|
||||
#[inline]
|
||||
fn with_name(mut self, general: impl Into<String>, instance: impl Into<String>) -> Self {
|
||||
self.platform_specific.name = Some(crate::platform_impl::ApplicationName::new(
|
||||
general.into(),
|
||||
instance.into(),
|
||||
));
|
||||
self.platform_specific.name =
|
||||
Some(crate::platform_impl::ApplicationName::new(general.into(), instance.into()));
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue