Remove the need for cfg_aliases in winit-core (#4271)
This commit is contained in:
parent
b0f26c79ff
commit
478427b0bd
7 changed files with 18 additions and 34 deletions
|
|
@ -23,11 +23,9 @@ rwh_06.workspace = true
|
|||
serde = { workspace = true, optional = true }
|
||||
smol_str.workspace = true
|
||||
|
||||
[target.'cfg(target_family = "wasm")'.dependencies]
|
||||
# `wasm32-unknown-unknown` and `wasm32-none`, but not `wasm32-wasi`.
|
||||
[target.'cfg(all(target_family = "wasm", any(target_os = "unknown", target_os = "none")))'.dependencies]
|
||||
web-time.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
cfg_aliases.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
winit.workspace = true
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
use cfg_aliases::cfg_aliases;
|
||||
|
||||
fn main() {
|
||||
// The script doesn't depend on our code.
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
|
||||
// Setup cfg aliases.
|
||||
cfg_aliases! {
|
||||
web_platform: { all(target_family = "wasm", target_os = "unknown") },
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,11 @@
|
|||
//! The event enums and assorted supporting types.
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{Mutex, Weak};
|
||||
#[cfg(not(web_platform))]
|
||||
use std::time::Instant;
|
||||
|
||||
use dpi::{PhysicalPosition, PhysicalSize};
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use smol_str::SmolStr;
|
||||
#[cfg(web_platform)]
|
||||
use web_time::Instant;
|
||||
|
||||
use crate::error::RequestError;
|
||||
use crate::event_loop::AsyncRequestSerial;
|
||||
|
|
@ -17,6 +13,7 @@ use crate::keyboard::{self, ModifiersKeyState, ModifiersKeys, ModifiersState};
|
|||
#[cfg(doc)]
|
||||
use crate::window::Window;
|
||||
use crate::window::{ActivationToken, Theme};
|
||||
use crate::Instant;
|
||||
|
||||
/// Describes the reason the event loop is resuming.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
|
|
|||
|
|
@ -4,18 +4,16 @@ pub mod run_on_demand;
|
|||
use std::fmt::{self, Debug};
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::Arc;
|
||||
#[cfg(not(web_platform))]
|
||||
use std::time::{Duration, Instant};
|
||||
use std::time::Duration;
|
||||
|
||||
use rwh_06::{DisplayHandle, HandleError, HasDisplayHandle};
|
||||
#[cfg(web_platform)]
|
||||
use web_time::{Duration, Instant};
|
||||
|
||||
use crate::as_any::AsAny;
|
||||
use crate::cursor::{CustomCursor, CustomCursorSource};
|
||||
use crate::error::RequestError;
|
||||
use crate::monitor::MonitorHandle;
|
||||
use crate::window::{Theme, Window, WindowAttributes};
|
||||
use crate::Instant;
|
||||
|
||||
pub trait ActiveEventLoop: AsAny + fmt::Debug {
|
||||
/// Creates an [`EventLoopProxy`] that can be used to dispatch user events
|
||||
|
|
|
|||
|
|
@ -32,13 +32,7 @@ pub trait EventLoopExtRunOnDemand {
|
|||
/// # Caveats
|
||||
/// - This extension isn't available on all platforms, since it's not always possible to return
|
||||
/// to the caller (specifically this is impossible on iOS and Web - though with the Web
|
||||
/// backend it is possible to use
|
||||
#[cfg_attr(
|
||||
web_platform,
|
||||
doc = " [`EventLoopExtWeb::spawn_app()`][crate::platform::web::EventLoopExtWeb::spawn_app()]"
|
||||
)]
|
||||
#[cfg_attr(not(web_platform), doc = " `EventLoopExtWeb::spawn_app()`")]
|
||||
/// [^1] more than once instead).
|
||||
/// backend it is possible to use `EventLoopExtWeb::spawn_app()`[^1] more than once instead).
|
||||
/// - No [`Window`] state can be carried between separate runs of the event loop.
|
||||
///
|
||||
/// You are strongly encouraged to use [`EventLoop::run_app()`] for portability, unless you
|
||||
|
|
|
|||
|
|
@ -1560,9 +1560,9 @@ impl NamedKey {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # #[cfg(web_platform)]
|
||||
/// # #[cfg(target_family = "wasm")]
|
||||
/// # wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
|
||||
/// # #[cfg_attr(web_platform, wasm_bindgen_test::wasm_bindgen_test)]
|
||||
/// # #[cfg_attr(target_family = "wasm", wasm_bindgen_test::wasm_bindgen_test)]
|
||||
/// # fn main() {
|
||||
/// use winit_core::keyboard::NamedKey;
|
||||
///
|
||||
|
|
@ -1587,9 +1587,9 @@ impl Key {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # #[cfg(web_platform)]
|
||||
/// # #[cfg(target_family = "wasm")]
|
||||
/// # wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
|
||||
/// # #[cfg_attr(web_platform, wasm_bindgen_test::wasm_bindgen_test)]
|
||||
/// # #[cfg_attr(target_family = "wasm", wasm_bindgen_test::wasm_bindgen_test)]
|
||||
/// # fn main() {
|
||||
/// use winit_core::keyboard::{Key, NamedKey};
|
||||
///
|
||||
|
|
|
|||
|
|
@ -19,3 +19,11 @@ pub mod icon;
|
|||
pub mod keyboard;
|
||||
pub mod monitor;
|
||||
pub mod window;
|
||||
|
||||
// `Instant` is not actually available on `wasm32-unknown-unknown`, the `std` implementation there
|
||||
// is a stub. And `wasm32-none` doesn't even have `std`. Instead, we use `web_time::Instant`.
|
||||
#[cfg(not(all(target_family = "wasm", any(target_os = "unknown", target_os = "none"))))]
|
||||
pub(crate) use std::time::Instant;
|
||||
|
||||
#[cfg(all(target_family = "wasm", any(target_os = "unknown", target_os = "none")))]
|
||||
pub(crate) use web_time::Instant;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue