winit-core: new crate + split out as_any
This commit is contained in:
parent
bf0bde8067
commit
3493a20173
8 changed files with 73 additions and 4 deletions
12
Cargo.toml
12
Cargo.toml
|
|
@ -56,7 +56,14 @@ android-game-activity = ["android-activity/game-activity"]
|
|||
android-native-activity = ["android-activity/native-activity"]
|
||||
default = ["x11", "wayland", "wayland-dlopen", "wayland-csd-adwaita"]
|
||||
mint = ["dpi/mint"]
|
||||
serde = ["dep:serde", "cursor-icon/serde", "smol_str/serde", "dpi/serde", "bitflags/serde"]
|
||||
serde = [
|
||||
"dep:serde",
|
||||
"cursor-icon/serde",
|
||||
"smol_str/serde",
|
||||
"dpi/serde",
|
||||
"bitflags/serde",
|
||||
"winit-core/serde",
|
||||
]
|
||||
wayland = [
|
||||
"wayland-client",
|
||||
"wayland-backend",
|
||||
|
|
@ -83,6 +90,7 @@ rwh_06 = { package = "raw-window-handle", version = "0.6", features = ["std"] }
|
|||
serde = { workspace = true, optional = true }
|
||||
smol_str = "0.3"
|
||||
tracing = { version = "0.1.40", default-features = false }
|
||||
winit-core = { version = "0.0.0", path = "winit-core" }
|
||||
|
||||
[dev-dependencies]
|
||||
image = { version = "0.25.0", default-features = false, features = ["png"] }
|
||||
|
|
@ -389,7 +397,7 @@ name = "window"
|
|||
name = "child_window"
|
||||
|
||||
[workspace]
|
||||
members = ["dpi"]
|
||||
members = ["dpi", "winit-core"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.package]
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ pub mod icon;
|
|||
pub mod keyboard;
|
||||
pub mod monitor;
|
||||
mod platform_impl;
|
||||
mod utils;
|
||||
use winit_core::as_any as utils;
|
||||
pub mod window;
|
||||
|
||||
pub mod platform;
|
||||
|
|
|
|||
30
winit-core/Cargo.toml
Normal file
30
winit-core/Cargo.toml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
[package]
|
||||
authors = ["The winit contributors", "Kirill Chibisov <contact@kchibisov.com>"]
|
||||
categories = ["gui"]
|
||||
description = "winit core API."
|
||||
documentation = "https://docs.rs/winit-core"
|
||||
edition.workspace = true
|
||||
keywords = ["windowing"]
|
||||
license.workspace = true
|
||||
name = "winit-core"
|
||||
readme = "README.md"
|
||||
repository.workspace = true
|
||||
rust-version.workspace = true
|
||||
version = "0.0.0"
|
||||
|
||||
[features]
|
||||
serde = ["dep:serde", "cursor-icon/serde", "smol_str/serde", "dpi/serde", "bitflags/serde"]
|
||||
|
||||
[dependencies]
|
||||
bitflags = "2"
|
||||
cursor-icon = "1.1.0"
|
||||
dpi = { version = "0.1.1", path = "../dpi" }
|
||||
rwh_06 = { package = "raw-window-handle", version = "0.6", features = ["std"] }
|
||||
serde = { workspace = true, optional = true }
|
||||
smol_str = "0.3"
|
||||
|
||||
[target.'cfg(target_family = "wasm")'.dependencies]
|
||||
web-time = "1"
|
||||
|
||||
[build-dependencies]
|
||||
cfg_aliases = "0.2.1"
|
||||
1
winit-core/LICENSE
Symbolic link
1
winit-core/LICENSE
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../LICENSE
|
||||
1
winit-core/README.md
Symbolic link
1
winit-core/README.md
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../README.md
|
||||
26
winit-core/build.rs
Normal file
26
winit-core/build.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
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! {
|
||||
// Systems.
|
||||
android_platform: { target_os = "android" },
|
||||
web_platform: { all(target_family = "wasm", target_os = "unknown") },
|
||||
macos_platform: { target_os = "macos" },
|
||||
ios_platform: { all(target_vendor = "apple", not(target_os = "macos")) },
|
||||
windows_platform: { target_os = "windows" },
|
||||
free_unix: { all(unix, not(target_vendor = "apple"), not(android_platform), not(target_os = "emscripten")) },
|
||||
redox: { target_os = "redox" },
|
||||
|
||||
// Native displays.
|
||||
x11_platform: { all(feature = "x11", free_unix, not(redox)) },
|
||||
wayland_platform: { all(feature = "wayland", free_unix, not(redox)) },
|
||||
orbital_platform: { redox },
|
||||
}
|
||||
|
||||
// Winit defined cfgs.
|
||||
println!("cargo:rustc-check-cfg=cfg(unreleased_changelogs)");
|
||||
}
|
||||
|
|
@ -31,6 +31,7 @@ impl<T: Any> AsAny for T {
|
|||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! impl_dyn_casting {
|
||||
($trait:ident) => {
|
||||
impl dyn $trait + '_ {
|
||||
|
|
@ -67,4 +68,4 @@ macro_rules! impl_dyn_casting {
|
|||
};
|
||||
}
|
||||
|
||||
pub(crate) use impl_dyn_casting;
|
||||
pub use impl_dyn_casting;
|
||||
2
winit-core/src/lib.rs
Normal file
2
winit-core/src/lib.rs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#[macro_use]
|
||||
pub mod as_any;
|
||||
Loading…
Add table
Add a link
Reference in a new issue