2022-06-10 20:43:33 +10:00
|
|
|
#![allow(clippy::single_match)]
|
|
|
|
|
2020-09-10 11:58:30 +10:00
|
|
|
use simple_logger::SimpleLogger;
|
2023-01-30 22:17:41 +11:00
|
|
|
use winit::dpi::{PhysicalPosition, PhysicalSize};
|
|
|
|
use winit::monitor::MonitorHandle;
|
2019-06-22 01:33:15 +10:00
|
|
|
use winit::{event_loop::EventLoop, window::WindowBuilder};
|
2018-06-17 00:14:12 +10:00
|
|
|
|
|
|
|
fn main() {
|
2020-09-10 11:58:30 +10:00
|
|
|
SimpleLogger::new().init().unwrap();
|
2019-02-06 02:30:33 +11:00
|
|
|
let event_loop = EventLoop::new();
|
|
|
|
let window = WindowBuilder::new().build(&event_loop).unwrap();
|
2019-06-18 08:13:35 +10:00
|
|
|
|
2023-01-30 22:17:41 +11:00
|
|
|
if let Some(mon) = window.primary_monitor() {
|
|
|
|
print_info("Primary output", mon);
|
|
|
|
}
|
|
|
|
|
|
|
|
for mon in window.available_monitors() {
|
|
|
|
if Some(&mon) == window.primary_monitor().as_ref() {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
println!();
|
|
|
|
print_info("Output", mon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn print_info(intro: &str, monitor: MonitorHandle) {
|
|
|
|
if let Some(name) = monitor.name() {
|
|
|
|
println!("{intro}: {name}");
|
|
|
|
} else {
|
|
|
|
println!("{intro}: [no name]");
|
|
|
|
}
|
|
|
|
|
|
|
|
let PhysicalSize { width, height } = monitor.size();
|
|
|
|
print!(" Current mode: {width}x{height}");
|
|
|
|
if let Some(m_hz) = monitor.refresh_rate_millihertz() {
|
|
|
|
println!(" @ {}.{} Hz", m_hz / 1000, m_hz % 1000);
|
|
|
|
} else {
|
|
|
|
println!();
|
|
|
|
}
|
|
|
|
|
|
|
|
let PhysicalPosition { x, y } = monitor.position();
|
|
|
|
println!(" Position: {x},{y}");
|
|
|
|
|
|
|
|
println!(" Scale factor: {}", monitor.scale_factor());
|
|
|
|
|
|
|
|
println!(" Available modes (width x height x bit-depth):");
|
|
|
|
for mode in monitor.video_modes() {
|
|
|
|
let PhysicalSize { width, height } = mode.size();
|
|
|
|
let bits = mode.bit_depth();
|
|
|
|
let m_hz = mode.refresh_rate_millihertz();
|
|
|
|
println!(
|
|
|
|
" {width}x{height}x{bits} @ {}.{} Hz",
|
|
|
|
m_hz / 1000,
|
|
|
|
m_hz % 1000
|
|
|
|
);
|
|
|
|
}
|
2018-06-17 00:14:12 +10:00
|
|
|
}
|