Skip to content

Commit 2e5af00

Browse files
committed
Add logging for testing purposes
1 parent 5a9bdf8 commit 2e5af00

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

crates/bevy_render/src/camera.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,16 @@ pub fn camera_system(
363363

364364
let mut changed_window_ids = EntityHashSet::default();
365365
changed_window_ids.extend(window_created_reader.read().map(|event| event.window));
366-
changed_window_ids.extend(window_resized_reader.read().map(|event| event.window));
366+
changed_window_ids.extend(window_resized_reader.read().map(|event| {
367+
warn!("Camera system got Bevy's WindowResized message.");
368+
event.window
369+
}));
367370
let scale_factor_changed_window_ids: EntityHashSet = window_scale_factor_changed_reader
368371
.read()
369-
.map(|event| event.window)
372+
.map(|event| {
373+
warn!("Camera system got Bevy's WindowScaleFactorChanged message.");
374+
event.window
375+
})
370376
.collect();
371377
changed_window_ids.extend(scale_factor_changed_window_ids.clone());
372378

crates/bevy_winit/src/state.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,13 @@ impl ApplicationHandler<WinitUserEvent> for WinitAppRunnerState {
245245
}
246246

247247
match event {
248-
WindowEvent::Resized(size) => self
249-
.bevy_window_events
250-
.send(react_to_resize(window, &mut win, size)),
248+
WindowEvent::Resized(size) => {
249+
warn!("Handling Winit's WindowEvent::Resized and sending Bevy's WindowEvent::WindowResized");
250+
self.bevy_window_events
251+
.send(react_to_resize(window, &mut win, size))
252+
}
251253
WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
254+
warn!("Handling Winit's WindowEvent::ScaleFactorChanged. Current WindowResolution :{:?}", win.resolution);
252255
let (window_backend_scale_factor_changed, window_scale_factor_changed) =
253256
react_to_scale_factor_change(window, &mut win, scale_factor);
254257

@@ -829,9 +832,11 @@ impl WinitAppRunnerState {
829832
world.write_message(e);
830833
}
831834
BevyWindowEvent::WindowResized(e) => {
835+
warn!("Forwarding WindowEvent::WindowResized as WindowResized.");
832836
world.write_message(e);
833837
}
834838
BevyWindowEvent::WindowScaleFactorChanged(e) => {
839+
warn!("Forwarding WindowEvent::WindowScaleFactorChanged as WindowScaleFactorChanged.");
835840
world.write_message(e);
836841
}
837842
BevyWindowEvent::WindowThemeChanged(e) => {

crates/bevy_winit/src/system.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ pub(crate) struct CachedCursorOptions(CursorOptions);
302302
/// - [`Window::transparent`] cannot be changed after the window is created.
303303
/// - [`Window::canvas`] cannot be changed after the window is created.
304304
/// - [`Window::focused`] cannot be manually changed to `false` after the window is created.
305+
#[tracing::instrument(skip_all)]
305306
pub(crate) fn changed_windows(
306307
mut commands: Commands,
307308
mut changed_windows: Query<
@@ -377,6 +378,7 @@ pub(crate) fn changed_windows(
377378
}
378379

379380
if window.resolution != cache.resolution {
381+
warn!("WindowResolution has changed.");
380382

381383
let cache_physical_size = PhysicalSize::new(
382384
cache.resolution.physical_width(),
@@ -390,6 +392,7 @@ pub(crate) fn changed_windows(
390392
if cache_physical_size != requested_physical_size {
391393
// In `None` case, the request will be handled by winit::event::WindowEvent::Resized
392394
if let Some(new_physical_size) = winit_window.request_inner_size(requested_physical_size) {
395+
warn!("Winit resize request handled instantly: changing the resolution. Sending WindowResized events.");
393396
let event = react_to_resize(entity, &mut window, new_physical_size);
394397
// Need to send two very similar events because different systems rely on those.
395398
window_resized.write(event.clone());
@@ -402,6 +405,7 @@ pub(crate) fn changed_windows(
402405

403406
if cache_scale_factor != requested_scale_factor {
404407
// If the scale factor has changed we don't query anything from winit, but send events for camera system to handle.
408+
warn!("Scale factor has changed. Sending ScaleFactor Message.");
405409
let event = WindowScaleFactorChanged { scale_factor: requested_scale_factor as f64, window: entity};
406410
// Need to send two very similar events because different systems rely on those.
407411
window_rescaled.write(event.clone());

0 commit comments

Comments
 (0)