Use closure internally to fetch graphics_info
This commit is contained in:
parent
8643fbef90
commit
6e167675d6
3 changed files with 11 additions and 14 deletions
|
|
@ -130,7 +130,7 @@ where
|
|||
&mut clipboard,
|
||||
&mut proxy,
|
||||
context.window(),
|
||||
&compositor.fetch_information(),
|
||||
|| compositor.fetch_information(),
|
||||
);
|
||||
runtime.track(subscription);
|
||||
|
||||
|
|
@ -209,7 +209,6 @@ async fn run_instance<A, E, C>(
|
|||
|
||||
let mut state = application::State::new(&application, context.window());
|
||||
let mut viewport_version = state.viewport_version();
|
||||
let graphics_info = compositor.fetch_information();
|
||||
let mut user_interface =
|
||||
ManuallyDrop::new(application::build_user_interface(
|
||||
&mut application,
|
||||
|
|
@ -266,7 +265,7 @@ async fn run_instance<A, E, C>(
|
|||
&mut debug,
|
||||
&mut messages,
|
||||
context.window(),
|
||||
&graphics_info,
|
||||
|| compositor.fetch_information(),
|
||||
);
|
||||
|
||||
// Update window
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ where
|
|||
&mut clipboard,
|
||||
&mut proxy,
|
||||
&window,
|
||||
&compositor.fetch_information(),
|
||||
|| compositor.fetch_information(),
|
||||
);
|
||||
runtime.track(subscription);
|
||||
|
||||
|
|
@ -264,8 +264,6 @@ async fn run_instance<A, E, C>(
|
|||
physical_size.height,
|
||||
);
|
||||
|
||||
let graphics_info = compositor.fetch_information();
|
||||
|
||||
let mut user_interface = ManuallyDrop::new(build_user_interface(
|
||||
&mut application,
|
||||
user_interface::Cache::default(),
|
||||
|
|
@ -321,7 +319,7 @@ async fn run_instance<A, E, C>(
|
|||
&mut debug,
|
||||
&mut messages,
|
||||
&window,
|
||||
&graphics_info,
|
||||
|| compositor.fetch_information(),
|
||||
);
|
||||
|
||||
// Update window
|
||||
|
|
@ -521,7 +519,7 @@ pub fn update<A: Application, E: Executor>(
|
|||
debug: &mut Debug,
|
||||
messages: &mut Vec<A::Message>,
|
||||
window: &winit::window::Window,
|
||||
graphics_info: &compositor::Information,
|
||||
graphics_info: impl FnOnce() -> compositor::Information + Copy,
|
||||
) {
|
||||
for message in messages.drain(..) {
|
||||
debug.log_message(&message);
|
||||
|
|
@ -544,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: &compositor::Information,
|
||||
graphics_info: impl FnOnce() -> compositor::Information + Copy,
|
||||
) {
|
||||
use iced_native::command;
|
||||
use iced_native::system;
|
||||
|
|
@ -584,7 +582,7 @@ 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::get_information(graphics_info);
|
||||
crate::system::get_information(graphics_info());
|
||||
|
||||
let message = tag(information);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ pub fn fetch_information<Message>(
|
|||
|
||||
#[cfg(feature = "sysinfo")]
|
||||
pub(crate) fn get_information(
|
||||
graphics_info: &compositor::Information,
|
||||
graphics_info: compositor::Information,
|
||||
) -> Option<Information> {
|
||||
use sysinfo::{ProcessExt, ProcessorExt, System, SystemExt};
|
||||
let mut system = System::new_all();
|
||||
|
|
@ -38,8 +38,8 @@ pub(crate) fn get_information(
|
|||
cpu_cores: system.physical_core_count(),
|
||||
memory_total: system.total_memory(),
|
||||
memory_used,
|
||||
graphics_adapter: graphics_info.adapter.clone(),
|
||||
graphics_backend: graphics_info.backend.clone(),
|
||||
graphics_adapter: graphics_info.adapter,
|
||||
graphics_backend: graphics_info.backend,
|
||||
};
|
||||
|
||||
Some(information)
|
||||
|
|
@ -47,7 +47,7 @@ pub(crate) fn get_information(
|
|||
|
||||
#[cfg(not(feature = "sysinfo"))]
|
||||
pub(crate) fn get_information(
|
||||
_graphics_info: &compositor::Information,
|
||||
_graphics_info: compositor::Information,
|
||||
) -> Option<Information> {
|
||||
None
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue