Skip to content

Commit

Permalink
Remove Rc<RefCell<…>>
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Nov 11, 2023
1 parent 3a87db2 commit 7e96001
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions crates/eframe/src/native/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,8 @@ mod glow_integration {
// re-initializing the `GlowWinitRunning` state on Android if the application
// suspends and resumes.
app_creator: Option<epi::AppCreator>,
focused_viewport: Rc<RefCell<Option<ViewportId>>>,

focused_viewport: Option<ViewportId>,
}

impl GlowWinitApp {
Expand All @@ -902,7 +903,7 @@ mod glow_integration {
native_options,
running: None,
app_creator: Some(app_creator),
focused_viewport: Rc::new(RefCell::new(Some(ViewportId::ROOT))),
focused_viewport: Some(ViewportId::ROOT),
}
}

Expand Down Expand Up @@ -1342,12 +1343,12 @@ mod glow_integration {
}

fn is_focused(&self, window_id: winit::window::WindowId) -> bool {
if let Some(is_focused) = self.focused_viewport.borrow().as_ref() {
if let Some(focused_viewport) = self.focused_viewport {
if let Some(running) = self.running.as_ref() {
if let Some(window_id) =
running.glutin_ctx.borrow().viewport_maps.get(&window_id)
{
return *is_focused == *window_id;
return focused_viewport == *window_id;
}
}
}
Expand Down Expand Up @@ -1606,7 +1607,7 @@ mod glow_integration {
egui_winit::process_viewport_commands(
vec![command],
viewport_id,
*self.focused_viewport.borrow(),
self.focused_viewport,
&window.borrow(),
);
}
Expand Down Expand Up @@ -1690,18 +1691,16 @@ mod glow_integration {

match &event {
winit::event::WindowEvent::Focused(new_focused) => {
self.focused_viewport.replace(
new_focused
.then(|| {
running
.glutin_ctx
.borrow_mut()
.viewport_maps
.get(window_id)
.copied()
})
.flatten(),
);
self.focused_viewport = new_focused
.then(|| {
running
.glutin_ctx
.borrow_mut()
.viewport_maps
.get(window_id)
.copied()
})
.flatten();
}
winit::event::WindowEvent::Resized(physical_size) => {
repaint_asap = true;
Expand Down

0 comments on commit 7e96001

Please sign in to comment.