Retry requesting input focus until the window is focused at startup
This commit is contained in:
parent
edaa1ea8cd
commit
a287ce7281
1 changed files with 8 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
|
||||
use std::sync::mpsc::Receiver;
|
||||
use std::sync::{Arc, Condvar, Mutex};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use pyo3::prelude::*;
|
||||
|
|
@ -79,7 +80,14 @@ pub fn start(
|
|||
w.set_close_polling(true);
|
||||
w.set_key_polling(true);
|
||||
w.set_char_polling(true);
|
||||
w.set_focus_polling(true);
|
||||
w.focus();
|
||||
let focus_deadline = Instant::now() + Duration::from_secs(2);
|
||||
while Instant::now() < focus_deadline && !w.is_focused() {
|
||||
glfw_ctx.poll_events();
|
||||
w.focus();
|
||||
std::thread::sleep(Duration::from_millis(10));
|
||||
}
|
||||
let fb = w.get_framebuffer_size();
|
||||
fb_w = fb.0.max(1) as u32;
|
||||
fb_h = fb.1.max(1) as u32;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue