Skip to content

Commit

Permalink
Remove RefCell
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Nov 11, 2023
1 parent 40f0fc0 commit 3a87db2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions crates/eframe/src/native/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,7 @@ mod wgpu_integration {

/// 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.
focused_viewport: RefCell<Option<ViewportId>>,
focused_viewport: Option<ViewportId>,
}

impl WgpuWinitApp {
Expand All @@ -1908,7 +1908,7 @@ mod wgpu_integration {
native_options,
running: None,
app_creator: Some(app_creator),
focused_viewport: RefCell::new(Some(ViewportId::ROOT)),
focused_viewport: Some(ViewportId::ROOT),
}
}

Expand Down Expand Up @@ -2312,7 +2312,7 @@ mod wgpu_integration {
}

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)
.map_or(false, |i| i == focus)
} else {
Expand Down Expand Up @@ -2560,7 +2560,7 @@ mod wgpu_integration {
egui_winit::process_viewport_commands(
vec![command],
viewport_id,
*self.focused_viewport.borrow(),
self.focused_viewport,
&window.borrow(),
);
}
Expand Down Expand Up @@ -2672,8 +2672,7 @@ mod wgpu_integration {

match &event {
winit::event::WindowEvent::Focused(new_focused) => {
self.focused_viewport
.replace(new_focused.then(|| viewport_id).flatten());
self.focused_viewport = new_focused.then(|| viewport_id).flatten();
}
winit::event::WindowEvent::Resized(physical_size) => {
repaint_asap = true;
Expand Down

0 comments on commit 3a87db2

Please sign in to comment.