Clean up and refactor X11 refresh loop (alternative) (#8655)

Associates every window with its own refresh event. Removes the use of
X11 present.
Alternative to #8592.
Instead of doing the rendering on idle and then involving a hack for
polling X11 events, this PR just tries to do the rendering inside the
main loop. This guarantees that we continue to poll for events after the
draw, and not get screwed by the driver talking to X11 via the same file
descriptor.

Release Notes:
- N/A
This commit is contained in:
Dzmitry Malyshau 2024-03-01 16:43:24 -08:00 committed by GitHub
parent b7784d414a
commit 26103e8bb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 81 additions and 106 deletions

View file

@ -219,14 +219,6 @@ impl X11WindowState {
data: &[atoms.wm_del_window],
});
let fake_id = xcb_connection.generate_id();
xcb_connection.send_request(&xcb::present::SelectInput {
eid: fake_id,
window: x_window,
//Note: also consider `IDLE_NOTIFY`
event_mask: xcb::present::EventMask::COMPLETE_NOTIFY,
});
xcb_connection.send_request(&x::MapWindow { window: x_window });
xcb_connection.flush().unwrap();
@ -286,11 +278,8 @@ impl X11WindowState {
pub fn refresh(&self) {
let mut cb = self.callbacks.borrow_mut();
if let Some(mut fun) = cb.request_frame.take() {
drop(cb);
if let Some(ref mut fun) = cb.request_frame {
fun();
let mut cb = self.callbacks.borrow_mut();
cb.request_frame = Some(fun);
}
}
@ -325,16 +314,6 @@ impl X11WindowState {
}
}
pub fn request_refresh(&self) {
self.xcb_connection.send_request(&xcb::present::NotifyMsc {
window: self.x_window,
serial: 0,
target_msc: 0,
divisor: 1,
remainder: 0,
});
}
pub fn handle_input(&self, input: PlatformInput) {
if let Some(ref mut fun) = self.callbacks.borrow_mut().input {
if fun(input.clone()) {