1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 06:40:06 -04:00

Remove RefCell

This commit is contained in:
Emil Ernerfeldt
2023-11-11 20:02:43 +01:00
parent 40f0fc0b53
commit 3a87db2dc3

View File

@@ -1885,7 +1885,7 @@ mod wgpu_integration {
/// Window surface state that's initialized when the app starts running via a Resumed event /// Window surface state that's initialized when the app starts running via a Resumed event
/// and on Android will also be destroyed if the application is paused. /// and on Android will also be destroyed if the application is paused.
focused_viewport: RefCell<Option<ViewportId>>, focused_viewport: Option<ViewportId>,
} }
impl WgpuWinitApp { impl WgpuWinitApp {
@@ -1908,7 +1908,7 @@ mod wgpu_integration {
native_options, native_options,
running: None, running: None,
app_creator: Some(app_creator), app_creator: Some(app_creator),
focused_viewport: RefCell::new(Some(ViewportId::ROOT)), focused_viewport: Some(ViewportId::ROOT),
} }
} }
@@ -2312,7 +2312,7 @@ mod wgpu_integration {
} }
fn is_focused(&self, window_id: winit::window::WindowId) -> bool { fn is_focused(&self, window_id: winit::window::WindowId) -> bool {
if let Some(focus) = *self.focused_viewport.borrow() { if let Some(focus) = self.focused_viewport {
self.viewport_id_from_window_id(&window_id) self.viewport_id_from_window_id(&window_id)
.map_or(false, |i| i == focus) .map_or(false, |i| i == focus)
} else { } else {
@@ -2560,7 +2560,7 @@ mod wgpu_integration {
egui_winit::process_viewport_commands( egui_winit::process_viewport_commands(
vec![command], vec![command],
viewport_id, viewport_id,
*self.focused_viewport.borrow(), self.focused_viewport,
&window.borrow(), &window.borrow(),
); );
} }
@@ -2672,8 +2672,7 @@ mod wgpu_integration {
match &event { match &event {
winit::event::WindowEvent::Focused(new_focused) => { winit::event::WindowEvent::Focused(new_focused) => {
self.focused_viewport self.focused_viewport = new_focused.then(|| viewport_id).flatten();
.replace(new_focused.then(|| viewport_id).flatten());
} }
winit::event::WindowEvent::Resized(physical_size) => { winit::event::WindowEvent::Resized(physical_size) => {
repaint_asap = true; repaint_asap = true;