Skip to content

Commit 171f781

Browse files
committed
add documentation comments to
1 parent 609b099 commit 171f781

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

crates/bevy_winit/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ use crate::web_resize::{CanvasParentResizeEventChannel, CanvasParentResizePlugin
4949
#[cfg(target_os = "android")]
5050
pub static ANDROID_APP: once_cell::sync::OnceCell<AndroidApp> = once_cell::sync::OnceCell::new();
5151

52+
/// A [`Plugin`] that utilizes [`winit`] for window creation and event loop management.
5253
#[derive(Default)]
5354
pub struct WinitPlugin;
5455

@@ -270,6 +271,7 @@ impl Default for WinitPersistentState {
270271
}
271272
}
272273

274+
/// The default [`App::runner`] for the [`WinitPlugin`] plugin.
273275
pub fn winit_runner(mut app: App) {
274276
// We remove this so that we have ownership over it.
275277
let mut event_loop = app

crates/bevy_winit/src/winit_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use bevy_ecs::system::Resource;
22
use bevy_utils::Duration;
33

4-
/// A resource for configuring usage of the `rust_winit` library.
4+
/// A resource for configuring usage of the [`winit`] library.
55
#[derive(Debug, Resource)]
66
pub struct WinitSettings {
77
/// Configures `winit` to return control to the caller after exiting the

crates/bevy_winit/src/winit_windows.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![warn(missing_docs)]
12
use std::sync::atomic::Ordering;
23

34
use accesskit_winit::Adapter;
@@ -20,18 +21,24 @@ use crate::{
2021
converters::convert_window_level,
2122
};
2223

24+
/// A reource which maps window entities to [`winit`] library windows.
2325
#[derive(Debug, Default)]
2426
pub struct WinitWindows {
27+
/// Stores [`winit`] windows by window identifier.
2528
pub windows: HashMap<winit::window::WindowId, winit::window::Window>,
29+
/// Maps entities to `winit` window identifiers.
2630
pub entity_to_winit: HashMap<Entity, winit::window::WindowId>,
31+
/// Maps `winit` window identifiers to entities.
2732
pub winit_to_entity: HashMap<winit::window::WindowId, Entity>,
33+
2834
// Some winit functions, such as `set_window_icon` can only be used from the main thread. If
2935
// they are used in another thread, the app will hang. This marker ensures `WinitWindows` is
3036
// only ever accessed with bevy's non-send functions and in NonSend systems.
3137
_not_send_sync: core::marker::PhantomData<*const ()>,
3238
}
3339

3440
impl WinitWindows {
41+
/// Creates a `winit` window and associates it with our entity.
3542
pub fn create_window(
3643
&mut self,
3744
event_loop: &winit::event_loop::EventLoopWindowTarget<()>,
@@ -227,6 +234,9 @@ impl WinitWindows {
227234
}
228235
}
229236

237+
/// Gets the "best" video mode which fits the given dimensions.
238+
///
239+
/// The heuristic for "best" prioritizes width, height, and refresh rate in that order.
230240
pub fn get_fitting_videomode(
231241
monitor: &winit::monitor::MonitorHandle,
232242
width: u32,
@@ -259,6 +269,9 @@ pub fn get_fitting_videomode(
259269
modes.first().unwrap().clone()
260270
}
261271

272+
/// Gets the "best" videomode from a monitor.
273+
///
274+
/// The heuristic for "best" prioritizes width, height, and refresh rate in that order.
262275
pub fn get_best_videomode(monitor: &winit::monitor::MonitorHandle) -> winit::monitor::VideoMode {
263276
let mut modes = monitor.video_modes().collect::<Vec<_>>();
264277
modes.sort_by(|a, b| {
@@ -300,6 +313,7 @@ pub(crate) fn attempt_grab(winit_window: &winit::window::Window, grab_mode: Curs
300313
}
301314
}
302315

316+
/// Compute the physical window position for a given [`WindowPosition`].
303317
// Ideally we could generify this across window backends, but we only really have winit atm
304318
// so whatever.
305319
pub fn winit_window_position(

0 commit comments

Comments
 (0)