Skip to content

Commit c64f4c1

Browse files
committed
Address review comments
1 parent 1c34167 commit c64f4c1

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

desktop/src/app.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use winit::event::StartCause;
1212
use winit::event::WindowEvent;
1313
use winit::event_loop::ActiveEventLoop;
1414
use winit::event_loop::ControlFlow;
15-
use winit::event_loop::EventLoopProxy;
1615
use winit::window::Window;
1716
use winit::window::WindowId;
1817

@@ -26,12 +25,11 @@ pub(crate) struct WinitApp {
2625
window_size_sender: Sender<WindowSize>,
2726
_viewport_frame_buffer: Option<wgpu::Texture>,
2827
graphics_state: Option<GraphicsState>,
29-
event_loop_proxy: EventLoopProxy<CustomEvent>,
3028
wgpu_context: WgpuContext,
3129
}
3230

3331
impl WinitApp {
34-
pub(crate) fn new(cef_context: cef::Context<cef::Initialized>, window_size_sender: Sender<WindowSize>, event_loop_proxy: EventLoopProxy<CustomEvent>, wgpu_context: WgpuContext) -> Self {
32+
pub(crate) fn new(cef_context: cef::Context<cef::Initialized>, window_size_sender: Sender<WindowSize>, wgpu_context: WgpuContext) -> Self {
3533
Self {
3634
cef_context,
3735
window: None,
@@ -40,7 +38,6 @@ impl WinitApp {
4038
_ui_frame_buffer: None,
4139
graphics_state: None,
4240
window_size_sender,
43-
event_loop_proxy,
4441
wgpu_context,
4542
}
4643
}
@@ -84,21 +81,21 @@ impl ApplicationHandler<CustomEvent> for WinitApp {
8481

8582
fn user_event(&mut self, _: &ActiveEventLoop, event: CustomEvent) {
8683
match event {
87-
CustomEvent::UiUpdate((texture, width, height)) => {
84+
CustomEvent::UiUpdate(texture) => {
8885
if let Some(graphics_state) = self.graphics_state.as_mut() {
8986
graphics_state.bind_texture(&texture);
90-
graphics_state.resize(width, height);
87+
graphics_state.resize(texture.width(), texture.height());
9188
}
9289
if let Some(window) = &self.window {
9390
window.request_redraw();
9491
}
9592
}
9693
CustomEvent::ScheduleBrowserWork(instant) => {
97-
if instant < Instant::now() {
94+
if instant <= Instant::now() {
9895
self.cef_context.work();
99-
let _ = self.event_loop_proxy.send_event(CustomEvent::ScheduleBrowserWork(Instant::now() + Duration::from_millis(10)));
96+
} else {
97+
self.cef_schedule = Some(instant);
10098
}
101-
self.cef_schedule = Some(instant);
10299
}
103100
}
104101
}

desktop/src/cef.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl CefEventHandler for CefHandler {
110110
},
111111
);
112112

113-
let _ = self.event_loop_proxy.send_event(CustomEvent::UiUpdate((texture, width, height)));
113+
let _ = self.event_loop_proxy.send_event(CustomEvent::UiUpdate(texture));
114114
}
115115

116116
fn schedule_cef_message_loop_work(&self, scheduled_time: std::time::Instant) {

desktop/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mod dirs;
1818

1919
#[derive(Debug)]
2020
pub(crate) enum CustomEvent {
21-
UiUpdate((wgpu::Texture, u32, u32)),
21+
UiUpdate(wgpu::Texture),
2222
ScheduleBrowserWork(Instant),
2323
}
2424

@@ -49,7 +49,7 @@ fn main() {
4949

5050
tracing::info!("Cef initialized successfully");
5151

52-
let mut winit_app = WinitApp::new(cef_context, window_size_sender, event_loop.create_proxy(), wgpu_context);
52+
let mut winit_app = WinitApp::new(cef_context, window_size_sender, wgpu_context);
5353

5454
event_loop.run_app(&mut winit_app).unwrap();
5555
}

0 commit comments

Comments
 (0)