mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 23:01:30 +11:00
Merge pull request #706 from ecoal95/xinputfocus-error
x11: Poll the window until it is really visible
This commit is contained in:
commit
3e0f6adec4
|
@ -9,6 +9,8 @@ use std::sync::atomic::AtomicBool;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::os::raw::c_long;
|
use std::os::raw::c_long;
|
||||||
|
use std::thread;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use Api;
|
use Api;
|
||||||
use ContextError;
|
use ContextError;
|
||||||
|
@ -642,15 +644,26 @@ impl Window {
|
||||||
let ref x_window: &XWindow = window.x.borrow();
|
let ref x_window: &XWindow = window.x.borrow();
|
||||||
|
|
||||||
// XSetInputFocus generates an error if the window is not visible,
|
// XSetInputFocus generates an error if the window is not visible,
|
||||||
// therefore we call XSync before to make sure it's the case
|
// therefore we wait until it's the case.
|
||||||
(display.xlib.XSync)(display.display, 0);
|
loop {
|
||||||
(display.xlib.XSetInputFocus)(
|
let mut window_attributes = mem::uninitialized();
|
||||||
display.display,
|
(display.xlib.XGetWindowAttributes)(display.display, x_window.window, &mut window_attributes);
|
||||||
x_window.window,
|
display.check_errors().expect("Failed to call XGetWindowAttributes");
|
||||||
ffi::RevertToParent,
|
|
||||||
ffi::CurrentTime
|
if window_attributes.map_state == ffi::IsViewable {
|
||||||
);
|
(display.xlib.XSetInputFocus)(
|
||||||
display.check_errors().expect("Failed to call XSetInputFocus");
|
display.display,
|
||||||
|
x_window.window,
|
||||||
|
ffi::RevertToParent,
|
||||||
|
ffi::CurrentTime
|
||||||
|
);
|
||||||
|
display.check_errors().expect("Failed to call XSetInputFocus");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait about a frame to avoid too-busy waiting
|
||||||
|
thread::sleep(Duration::from_millis(16));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue