-
Notifications
You must be signed in to change notification settings - Fork 948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Awakened event doesn't always work #462
Comments
I could reproduce this issue and tried to look at older commits (up until the introduction of the EventsLoop::wakeup method), but could not find any with the expected behavior. Here is the code without the glutin dependency: extern crate winit;
fn main() {
let mut events_loop = winit::EventsLoop::new();
let events_proxy = events_loop.create_proxy();
let _window = winit::WindowBuilder::new()
.with_title("A fantastic window!")
.build(&events_loop)
.unwrap();
'outer: loop {
let mut events = vec![];
// Wait for events.
events_loop.run_forever(|event| {
println!("event: {:?}", event);
events.push(event);
winit::ControlFlow::Break
});
// Just poll events without waiting.
events_loop.poll_events(|event| {
println!("event: {:?}", event);
events.push(event);
});
for event in &events {
match *event {
winit::Event::WindowEvent {
event: winit::WindowEvent::MouseInput {
state: winit::ElementState::Pressed, ..
}, ..
} => {
println!("wakeup()");
events_proxy.wakeup().unwrap();
},
winit::Event::WindowEvent {
event: winit::WindowEvent::CloseRequested,
..
} => break 'outer,
_ => {},
}
}
}
} |
What's expected here? I must confess that I don't really understand what |
It is expected that each click pushes an Awakened event to the queue of unhandled events, but with run_forever (in this setup) the event gets lost somehow. There is a historical issue with some background information: #175 And there is also an example: |
Do not reset the pending_wakeup boolean at the start of run_forever so that each call to EventsLoopProxy::wakeup results in an Awakened event. Fixes rust-windowing#462
@b-r-u thanks! I think I understand now, particularly from #187 (comment). So, it enables this pattern, right?
|
@francesca64 Yes, exactly! |
* x11: Always receive Awakened event in run_forever Do not reset the pending_wakeup boolean at the start of run_forever so that each call to EventsLoopProxy::wakeup results in an Awakened event. Fixes #462 * Update CHANGELOG.md
Update lexical-core for nightly changes.
See the comment at the top of this code block:
When it works, it should print
wakeup()
thenevent: Awakened
to the console when the window is clicked. When it does not, it will only printwakeup()
.The text was updated successfully, but these errors were encountered: