diff options
author | 2022-04-30 13:37:57 +0200 | |
---|---|---|
committer | 2022-04-30 13:37:57 +0200 | |
commit | 93bfe2c75ec97ef78f993926c703f040dde4a5f3 (patch) | |
tree | 80582ee46dfd06cf5f69d92e3b6d66c0c766c28e | |
parent | 5eefa5d4ead9ebfac7dab1db9aebf9797d2dad38 (diff) | |
download | iced-93bfe2c75ec97ef78f993926c703f040dde4a5f3.tar.gz iced-93bfe2c75ec97ef78f993926c703f040dde4a5f3.tar.bz2 iced-93bfe2c75ec97ef78f993926c703f040dde4a5f3.zip |
Expose `system` module through feature flag
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | examples/system_information/Cargo.toml | 4 | ||||
-rw-r--r-- | glutin/Cargo.toml | 1 | ||||
-rw-r--r-- | glutin/src/lib.rs | 4 | ||||
-rw-r--r-- | src/lib.rs | 4 | ||||
-rw-r--r-- | winit/Cargo.toml | 6 | ||||
-rw-r--r-- | winit/src/application.rs | 19 | ||||
-rw-r--r-- | winit/src/lib.rs | 4 |
8 files changed, 30 insertions, 14 deletions
@@ -42,6 +42,8 @@ smol = ["iced_futures/smol"] palette = ["iced_core/palette"] # Enables pure, virtual widgets in the `pure` module pure = ["iced_pure", "iced_graphics/pure"] +# Enables querying system information +system = ["iced_winit/system"] [badges] maintenance = { status = "actively-developed" } diff --git a/examples/system_information/Cargo.toml b/examples/system_information/Cargo.toml index 13a59d5e..7d1e4b94 100644 --- a/examples/system_information/Cargo.toml +++ b/examples/system_information/Cargo.toml @@ -6,5 +6,5 @@ edition = "2021" publish = false [dependencies] -iced = { path = "../.." } -bytesize = { version = "1.1.0" }
\ No newline at end of file +iced = { path = "../..", features = ["system"] } +bytesize = { version = "1.1.0" } diff --git a/glutin/Cargo.toml b/glutin/Cargo.toml index cd5f2a7a..2d4625da 100644 --- a/glutin/Cargo.toml +++ b/glutin/Cargo.toml @@ -12,6 +12,7 @@ categories = ["gui"] [features] debug = ["iced_winit/debug"] +system = ["iced_winit/system"] [dependencies.log] version = "0.4" diff --git a/glutin/src/lib.rs b/glutin/src/lib.rs index 99486034..fb24b688 100644 --- a/glutin/src/lib.rs +++ b/glutin/src/lib.rs @@ -22,7 +22,6 @@ pub mod application; pub use iced_winit::clipboard; pub use iced_winit::conversion; pub use iced_winit::settings; -pub use iced_winit::system; pub use iced_winit::window; pub use iced_winit::{Error, Mode}; @@ -32,3 +31,6 @@ pub use application::Application; pub use clipboard::Clipboard; #[doc(no_inline)] pub use settings::Settings; + +#[cfg(feature = "system")] +pub use iced_winit::system; @@ -224,8 +224,10 @@ pub use settings::Settings; pub use runtime::alignment; pub use runtime::futures; -pub use runtime::system; pub use runtime::{ Alignment, Background, Color, Command, ContentFit, Font, Length, Point, Rectangle, Size, Subscription, Vector, }; + +#[cfg(feature = "system")] +pub use runtime::system; diff --git a/winit/Cargo.toml b/winit/Cargo.toml index f5478e73..7758899c 100644 --- a/winit/Cargo.toml +++ b/winit/Cargo.toml @@ -12,12 +12,12 @@ categories = ["gui"] [features] debug = ["iced_native/debug"] +system = ["sysinfo"] [dependencies] window_clipboard = "0.2" log = "0.4" thiserror = "1.0" -sysinfo = "0.23" [dependencies.winit] version = "0.26" @@ -42,3 +42,7 @@ version = "0.3.6" [target.'cfg(target_arch = "wasm32")'.dependencies.web-sys] version = "0.3" features = ["Document", "Window"] + +[dependencies.sysinfo] +version = "0.23" +optional = true diff --git a/winit/src/application.rs b/winit/src/application.rs index 04dd55f1..1b7a4c8d 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -542,7 +542,7 @@ pub fn run_command<Message: 'static + std::fmt::Debug + Send, E: Executor>( clipboard: &mut Clipboard, proxy: &mut winit::event_loop::EventLoopProxy<Message>, window: &winit::window::Window, - graphics_info: impl FnOnce() -> compositor::Information + Copy, + _graphics_info: impl FnOnce() -> compositor::Information + Copy, ) { use iced_native::command; use iced_native::system; @@ -580,15 +580,18 @@ pub fn run_command<Message: 'static + std::fmt::Debug + Send, E: Executor>( } }, command::Action::System(action) => match action { - system::Action::QueryInformation(tag) => { - let information = - crate::system::information(graphics_info()); + system::Action::QueryInformation(_tag) => { + #[cfg(feature = "sysinfo")] + { + let information = + crate::system::information(_graphics_info()); - let message = tag(information); + let message = _tag(information); - proxy - .send_event(message) - .expect("Send message to event loop"); + proxy + .send_event(message) + .expect("Send message to event loop"); + } } }, } diff --git a/winit/src/lib.rs b/winit/src/lib.rs index 2b5bb2ff..4e5cb637 100644 --- a/winit/src/lib.rs +++ b/winit/src/lib.rs @@ -31,9 +31,11 @@ pub mod application; pub mod clipboard; pub mod conversion; pub mod settings; -pub mod system; pub mod window; +#[cfg(feature = "system")] +pub mod system; + mod error; mod mode; mod position; |