-
Notifications
You must be signed in to change notification settings - Fork 903
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
winit::event::Event extensions and time enhancements. #1055
Comments
...Also a |
Ohh, I forgot. Sarcasticly, of course Real Time applications are going to need an estimate as to how long until the next Update, so if you could provide that as well, that would be great. The app will provide how long you can take in calculating the estimated next Update time, obviously. |
Are these two cases not covered by https://docs.rs/winit/0.20.0-alpha2/winit/event/enum.Event.html#variant.NewEvents ? I'm basically at loss to what you want. |
I was asked to open a new issue for this so you can ignore the implied want for anything. Ohhhhh "NewEvents"... but um don't call them that, what would you do the next time you go to add events. I mean sure there's still "NewerEvents" but you'll just have to trust me you'll soon run out of names with that scheme. |
I thought NewEvents was the event sent to indicate that there is a collection of events that are in the pipeline to be followed up with an EventsCleared. I was going to use EventsCleared as my Update event because that's typically what you want, get all your input events and then calculate an image then present it. Sleeping till there are new events is kinda the opposite of what app developers are after with ControlFlow::Poll. |
The problem here, if you'r sure that you want to go with NewEvents, is the documentation for Poll:
See the indication that it'll trigger when there are NOT new events. This stems from a wider issue #1054, the documentation for ControlFlow::Poll must indicate what event it will cause to be emitted. Also might I request that NewEvents indicate approximately how many events will be being emitted, this could assist in things like allocating vectors. |
I'm not entirely sure what you're suggesting here. This sounds like it's mostly a documentation issue, but you're also suggesting major changes to the About timers - the reason we designed |
Related question: when setting |
@dhardy What exactly do you mean by that? If you're asking whether or a |
Ah, so I can't set up a repeating timer which is incremented only when the corresponding |
@dhardy Wait, I didn't entirely understood what you originally meant there. You'll receive a EDIT: that'll always happen even if the requested time passes during the event loop iteration that's handling 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,
_ => (),
}
});
} |
Aha, thanks @Osspial! (I didn't test, assuming it may be platform specific.) |
#459 (comment)
winit::event::Event would logically have:
Consider redoing winit::event_loop::ControlFlow as a trait instance that has callbacks for
fn set_timer(&mut self, T, Instant) -> RunningTimerAPI;
,fn set_sleeping(&mut self);
,fn set_polling(&mut self);
, andfn set_exiting(self);
.#1018
The text was updated successfully, but these errors were encountered: