mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 23:00:04 -04:00
Simplify another function signature
This commit is contained in:
@@ -4,9 +4,7 @@ use winit::event_loop::EventLoopWindowTarget;
|
|||||||
|
|
||||||
use raw_window_handle::{HasRawDisplayHandle as _, HasRawWindowHandle as _};
|
use raw_window_handle::{HasRawDisplayHandle as _, HasRawWindowHandle as _};
|
||||||
|
|
||||||
use egui::{
|
use egui::{NumExt as _, ViewportBuilder, ViewportId, ViewportIdPair, ViewportRender};
|
||||||
mutex::RwLock, NumExt as _, ViewportBuilder, ViewportId, ViewportIdPair, ViewportRender,
|
|
||||||
};
|
|
||||||
#[cfg(feature = "accesskit")]
|
#[cfg(feature = "accesskit")]
|
||||||
use egui_winit::accesskit_winit;
|
use egui_winit::accesskit_winit;
|
||||||
use egui_winit::{native_pixels_per_point, EventResponse, WindowSettings};
|
use egui_winit::{native_pixels_per_point, EventResponse, WindowSettings};
|
||||||
@@ -563,21 +561,17 @@ impl EpiIntegration {
|
|||||||
pub fn maybe_autosave(
|
pub fn maybe_autosave(
|
||||||
&mut self,
|
&mut self,
|
||||||
app: &mut dyn epi::App,
|
app: &mut dyn epi::App,
|
||||||
window: Arc<RwLock<winit::window::Window>>,
|
window: Option<&winit::window::Window>,
|
||||||
) {
|
) {
|
||||||
let now = std::time::Instant::now();
|
let now = std::time::Instant::now();
|
||||||
if now - self.last_auto_save > app.auto_save_interval() {
|
if now - self.last_auto_save > app.auto_save_interval() {
|
||||||
self.save(app, Some(window));
|
self.save(app, window);
|
||||||
self.last_auto_save = now;
|
self.last_auto_save = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::unused_self)]
|
#[allow(clippy::unused_self)]
|
||||||
pub fn save(
|
pub fn save(&mut self, _app: &mut dyn epi::App, _window: Option<&winit::window::Window>) {
|
||||||
&mut self,
|
|
||||||
_app: &mut dyn epi::App,
|
|
||||||
_window: Option<Arc<RwLock<winit::window::Window>>>,
|
|
||||||
) {
|
|
||||||
#[cfg(feature = "persistence")]
|
#[cfg(feature = "persistence")]
|
||||||
if let Some(storage) = self.frame.storage_mut() {
|
if let Some(storage) = self.frame.storage_mut() {
|
||||||
crate::profile_function!();
|
crate::profile_function!();
|
||||||
@@ -588,7 +582,7 @@ impl EpiIntegration {
|
|||||||
epi::set_value(
|
epi::set_value(
|
||||||
storage,
|
storage,
|
||||||
STORAGE_WINDOW_KEY,
|
STORAGE_WINDOW_KEY,
|
||||||
&WindowSettings::from_display(&window.read()),
|
&WindowSettings::from_display(window),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1371,7 +1371,9 @@ mod glow_integration {
|
|||||||
.window(ViewportId::MAIN)
|
.window(ViewportId::MAIN)
|
||||||
.read()
|
.read()
|
||||||
.window
|
.window
|
||||||
.clone(),
|
.as_ref()
|
||||||
|
.map(|w| w.read())
|
||||||
|
.as_deref(),
|
||||||
);
|
);
|
||||||
running.app.write().on_exit(Some(&running.gl));
|
running.app.write().on_exit(Some(&running.gl));
|
||||||
running.painter.write().destroy();
|
running.painter.write().destroy();
|
||||||
@@ -1566,8 +1568,10 @@ mod glow_integration {
|
|||||||
EventResult::Wait
|
EventResult::Wait
|
||||||
};
|
};
|
||||||
|
|
||||||
integration
|
integration.maybe_autosave(
|
||||||
.maybe_autosave(app.write().as_mut(), win.read().window.clone().unwrap());
|
app.write().as_mut(),
|
||||||
|
win.read().window.as_ref().map(|w| w.read()).as_deref(),
|
||||||
|
);
|
||||||
|
|
||||||
if win.read().window.as_ref().unwrap().read().is_minimized() == Some(true) {
|
if win.read().window.as_ref().unwrap().read().is_minimized() == Some(true) {
|
||||||
// On Mac, a minimized Window uses up all CPU:
|
// On Mac, a minimized Window uses up all CPU:
|
||||||
@@ -2271,10 +2275,10 @@ mod wgpu_integration {
|
|||||||
crate::profile_function!();
|
crate::profile_function!();
|
||||||
if let Some(Window { window, .. }) = running.viewports.read().get(&ViewportId::MAIN)
|
if let Some(Window { window, .. }) = running.viewports.read().get(&ViewportId::MAIN)
|
||||||
{
|
{
|
||||||
running
|
running.integration.write().save(
|
||||||
.integration
|
running.app.as_mut(),
|
||||||
.write()
|
window.as_ref().map(|w| w.read()).as_deref(),
|
||||||
.save(running.app.as_mut(), window.clone());
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "glow")]
|
#[cfg(feature = "glow")]
|
||||||
@@ -2452,7 +2456,7 @@ mod wgpu_integration {
|
|||||||
) else{return EventResult::Wait};
|
) else{return EventResult::Wait};
|
||||||
integration
|
integration
|
||||||
.write()
|
.write()
|
||||||
.maybe_autosave(app.as_mut(), window.clone());
|
.maybe_autosave(app.as_mut(), Some(&*window.read()));
|
||||||
|
|
||||||
if window.read().is_minimized() == Some(true) {
|
if window.read().is_minimized() == Some(true) {
|
||||||
// On Mac, a minimized Window uses up all CPU:
|
// On Mac, a minimized Window uses up all CPU:
|
||||||
|
|||||||
Reference in New Issue
Block a user