mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 06:41:31 +11:00
a70ac1531e
* X11: Fix window creation hangs when another application is fullscreen Previously, the X11 backend would block until a `VisibilityNotify` event is received when creating a Window that is visible or when calling `set_visible(true)` on a Window that is not currently visible. This could cause winit to hang in situations where the WM does not quickly send this event to the application, such as another window being fullscreen at the time. This behavior existed to prevent an X protocol error caused by setting fullscreen state on an invisible window. This fix instead stores desired fullscreen state when `set_fullscreen` is called (iff the window is not visible or not yet visible) and issues X commands to set fullscreen state when a `VisibilityNotify` event is received through the normal processing of events in the event loop. * Add window_debug example to facilitate testing * Add a CHANGELOG entry * Call `XUnmapWindow` if `VisibilityNotify` is received on an invisible window
38 lines
1 KiB
Rust
38 lines
1 KiB
Rust
use instant::Instant;
|
|
use std::time::Duration;
|
|
use winit::{
|
|
event::{Event, StartCause, WindowEvent},
|
|
event_loop::{ControlFlow, EventLoop},
|
|
window::WindowBuilder,
|
|
};
|
|
|
|
fn main() {
|
|
let event_loop = EventLoop::new();
|
|
|
|
let _window = WindowBuilder::new()
|
|
.with_title("A fantastic window!")
|
|
.build(&event_loop)
|
|
.unwrap();
|
|
|
|
let timer_length = Duration::new(1, 0);
|
|
|
|
event_loop.run(move |event, _, control_flow| {
|
|
println!("{:?}", event);
|
|
|
|
match event {
|
|
Event::NewEvents(StartCause::Init) => {
|
|
*control_flow = ControlFlow::WaitUntil(Instant::now() + timer_length)
|
|
}
|
|
Event::NewEvents(StartCause::ResumeTimeReached { .. }) => {
|
|
*control_flow = ControlFlow::WaitUntil(Instant::now() + timer_length);
|
|
println!("\nTimer\n");
|
|
}
|
|
Event::WindowEvent {
|
|
event: WindowEvent::CloseRequested,
|
|
..
|
|
} => *control_flow = ControlFlow::Exit,
|
|
_ => (),
|
|
}
|
|
});
|
|
}
|