 efda7f3f9c
			
		
	
	
		efda7f3f9c
		
			
		
	
	
	
	
		
			
			Takes the first two commits from #15375 and adds suggestions from this comment: https://github.com/bevyengine/bevy/pull/15375#issuecomment-2366968300 See #15375 for more reasoning/motivation. ## Rebasing (rerunning) ```rust git switch simpler-lint-fixes git reset --hard main cargo fmt --all -- --unstable-features --config normalize_comments=true,imports_granularity=Crate cargo fmt --all git add --update git commit --message "rustfmt" cargo clippy --workspace --all-targets --all-features --fix cargo fmt --all -- --unstable-features --config normalize_comments=true,imports_granularity=Crate cargo fmt --all git add --update git commit --message "clippy" git cherry-pick e6c0b94f6795222310fb812fa5c4512661fc7887 ```
		
			
				
	
	
		
			69 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			69 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
| use bevy_ecs::{component::Component, prelude::ReflectComponent};
 | |
| use bevy_math::{IVec2, UVec2};
 | |
| use bevy_reflect::Reflect;
 | |
| 
 | |
| #[cfg(feature = "serialize")]
 | |
| use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
 | |
| 
 | |
| /// Represents an available monitor as reported by the user's operating system, which can be used
 | |
| /// to query information about the display, such as its size, position, and video modes.
 | |
| ///
 | |
| /// Each monitor corresponds to an entity and can be used to position a monitor using
 | |
| /// [`crate::window::MonitorSelection::Entity`].
 | |
| ///
 | |
| /// # Warning
 | |
| ///
 | |
| /// This component is synchronized with `winit` through `bevy_winit`, but is effectively
 | |
| /// read-only as `winit` does not support changing monitor properties.
 | |
| #[derive(Component, Debug, Clone, Reflect)]
 | |
| #[cfg_attr(
 | |
|     feature = "serialize",
 | |
|     derive(serde::Serialize, serde::Deserialize),
 | |
|     reflect(Serialize, Deserialize)
 | |
| )]
 | |
| #[reflect(Component, Debug)]
 | |
| pub struct Monitor {
 | |
|     /// The name of the monitor
 | |
|     pub name: Option<String>,
 | |
|     /// The height of the monitor in physical pixels
 | |
|     pub physical_height: u32,
 | |
|     /// The width of the monitor in physical pixels
 | |
|     pub physical_width: u32,
 | |
|     /// The position of the monitor in physical pixels
 | |
|     pub physical_position: IVec2,
 | |
|     /// The refresh rate of the monitor in millihertz
 | |
|     pub refresh_rate_millihertz: Option<u32>,
 | |
|     /// The scale factor of the monitor
 | |
|     pub scale_factor: f64,
 | |
|     /// The video modes that the monitor supports
 | |
|     pub video_modes: Vec<VideoMode>,
 | |
| }
 | |
| 
 | |
| /// A marker component for the primary monitor
 | |
| #[derive(Component, Debug, Clone, Reflect)]
 | |
| #[reflect(Component, Debug)]
 | |
| pub struct PrimaryMonitor;
 | |
| 
 | |
| impl Monitor {
 | |
|     /// Returns the physical size of the monitor in pixels
 | |
|     pub fn physical_size(&self) -> UVec2 {
 | |
|         UVec2::new(self.physical_width, self.physical_height)
 | |
|     }
 | |
| }
 | |
| 
 | |
| /// Represents a video mode that a monitor supports
 | |
| #[derive(Debug, Clone, Reflect)]
 | |
| #[cfg_attr(
 | |
|     feature = "serialize",
 | |
|     derive(serde::Serialize, serde::Deserialize),
 | |
|     reflect(Serialize, Deserialize)
 | |
| )]
 | |
| pub struct VideoMode {
 | |
|     /// The resolution of the video mode
 | |
|     pub physical_size: UVec2,
 | |
|     /// The bit depth of the video mode
 | |
|     pub bit_depth: u16,
 | |
|     /// The refresh rate in millihertz
 | |
|     pub refresh_rate_millihertz: u32,
 | |
| }
 |