mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 06:11:30 +11:00
Implement the transition API
This commit is contained in:
parent
2c4db6b16e
commit
e7d43174e7
|
@ -21,13 +21,25 @@ macro_rules! gen_api_transition {
|
||||||
pub fn poll_events<F>(&self, mut callback: F)
|
pub fn poll_events<F>(&self, mut callback: F)
|
||||||
where F: FnMut(::Event)
|
where F: FnMut(::Event)
|
||||||
{
|
{
|
||||||
unimplemented!()
|
let mut windows = self.windows.lock().unwrap();
|
||||||
|
for window in windows.iter() {
|
||||||
|
for event in window.poll_events() {
|
||||||
|
callback(::Event::WindowEvent {
|
||||||
|
window_id: &**window as *const Window as usize,
|
||||||
|
event: event,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_forever<F>(&self, mut callback: F)
|
pub fn run_forever<F>(&self, mut callback: F)
|
||||||
where F: FnMut(::Event)
|
where F: FnMut(::Event)
|
||||||
{
|
{
|
||||||
unimplemented!()
|
// Yeah that's a very bad implementation.
|
||||||
|
loop {
|
||||||
|
self.poll_events(|e| callback(e));
|
||||||
|
::std::thread::sleep_ms(5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::path::PathBuf;
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
WindowEvent {
|
WindowEvent {
|
||||||
// window_id: ,
|
window_id: usize,
|
||||||
event: WindowEvent,
|
event: WindowEvent,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,6 +318,11 @@ impl Window {
|
||||||
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
||||||
self.window.set_cursor_state(state)
|
self.window.set_cursor_state(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn id(&self) -> usize {
|
||||||
|
self.window.id()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a thread safe subset of operations that can be called
|
/// Represents a thread safe subset of operations that can be called
|
||||||
|
|
Loading…
Reference in a new issue