mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 13:31:29 +11:00
Fix examples
This commit is contained in:
parent
ac69a9c0dc
commit
7753bbba94
|
@ -50,6 +50,7 @@ fn main() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[allow(deprecated)]
|
||||||
WindowEvent::KeyboardInput {
|
WindowEvent::KeyboardInput {
|
||||||
input:
|
input:
|
||||||
KeyboardInput {
|
KeyboardInput {
|
||||||
|
|
|
@ -12,20 +12,18 @@ fn main() {
|
||||||
|
|
||||||
let window = WindowBuilder::new()
|
let window = WindowBuilder::new()
|
||||||
.with_title("A fantastic window!")
|
.with_title("A fantastic window!")
|
||||||
.with_inner_size(LogicalSize::from((100, 100)))
|
.with_inner_size(LogicalSize::new(100.0, 100.0))
|
||||||
.build(&event_loop)
|
.build(&event_loop)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
eprintln!("debugging keys:");
|
eprintln!("debugging keys:");
|
||||||
eprintln!(" (E) Enter exclusive fullscreen");
|
eprintln!(" (E) Enter exclusive fullscreen");
|
||||||
eprintln!(" (F) Toggle borderless fullscreen");
|
eprintln!(" (F) Toggle borderless fullscreen");
|
||||||
#[cfg(waiting_for_set_minimized)]
|
|
||||||
eprintln!(" (M) Toggle minimized");
|
eprintln!(" (M) Toggle minimized");
|
||||||
eprintln!(" (Q) Quit event loop");
|
eprintln!(" (Q) Quit event loop");
|
||||||
eprintln!(" (V) Toggle visibility");
|
eprintln!(" (V) Toggle visibility");
|
||||||
eprintln!(" (X) Toggle maximized");
|
eprintln!(" (X) Toggle maximized");
|
||||||
|
|
||||||
#[cfg(waiting_for_set_minimized)]
|
|
||||||
let mut minimized = false;
|
let mut minimized = false;
|
||||||
let mut maximized = false;
|
let mut maximized = false;
|
||||||
let mut visible = true;
|
let mut visible = true;
|
||||||
|
@ -43,7 +41,6 @@ fn main() {
|
||||||
}),
|
}),
|
||||||
..
|
..
|
||||||
} => match key {
|
} => match key {
|
||||||
#[cfg(waiting_for_set_minimized)]
|
|
||||||
VirtualKeyCode::M => {
|
VirtualKeyCode::M => {
|
||||||
if minimized {
|
if minimized {
|
||||||
minimized = !minimized;
|
minimized = !minimized;
|
||||||
|
@ -68,16 +65,15 @@ fn main() {
|
||||||
..
|
..
|
||||||
} => match key {
|
} => match key {
|
||||||
VirtualKeyCode::E => {
|
VirtualKeyCode::E => {
|
||||||
fn area(size: PhysicalSize) -> f64 {
|
fn area(size: PhysicalSize<u32>) -> u32 {
|
||||||
size.width * size.height
|
size.width * size.height
|
||||||
}
|
}
|
||||||
|
|
||||||
let monitor = window.current_monitor();
|
let monitor = window.current_monitor();
|
||||||
if let Some(mode) = monitor.video_modes().max_by(|a, b| {
|
if let Some(mode) = monitor
|
||||||
area(a.size())
|
.video_modes()
|
||||||
.partial_cmp(&area(b.size()))
|
.max_by(|a, b| area(a.size()).cmp(&area(b.size())))
|
||||||
.expect("NaN in video mode size")
|
{
|
||||||
}) {
|
|
||||||
window.set_fullscreen(Some(Fullscreen::Exclusive(mode)));
|
window.set_fullscreen(Some(Fullscreen::Exclusive(mode)));
|
||||||
} else {
|
} else {
|
||||||
eprintln!("no video modes available");
|
eprintln!("no video modes available");
|
||||||
|
@ -91,7 +87,6 @@ fn main() {
|
||||||
window.set_fullscreen(Some(Fullscreen::Borderless(monitor)));
|
window.set_fullscreen(Some(Fullscreen::Borderless(monitor)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(waiting_for_set_minimized)]
|
|
||||||
VirtualKeyCode::M => {
|
VirtualKeyCode::M => {
|
||||||
minimized = !minimized;
|
minimized = !minimized;
|
||||||
window.set_minimized(minimized);
|
window.set_minimized(minimized);
|
||||||
|
|
Loading…
Reference in a new issue