X11: Fix multiple RedrawRequested events per event loop iteration (#1758)

* X11: Fix multiple RedrawRequested per event loop iteration

* Prevent infinite loop
This commit is contained in:
Murarth 2020-11-07 11:46:37 -07:00 committed by GitHub
parent 45e4fd6ec1
commit cbeb51b436
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,7 +24,7 @@ pub use self::{
use std::{ use std::{
cell::RefCell, cell::RefCell,
collections::HashMap, collections::{HashMap, HashSet},
ffi::CStr, ffi::CStr,
mem::{self, MaybeUninit}, mem::{self, MaybeUninit},
ops::Deref, ops::Deref,
@ -309,7 +309,13 @@ impl<T: 'static> EventLoop<T> {
} }
// Empty the redraw requests // Empty the redraw requests
{ {
let mut windows = HashSet::new();
while let Ok(window_id) = self.redraw_channel.try_recv() { while let Ok(window_id) = self.redraw_channel.try_recv() {
windows.insert(window_id);
}
for window_id in windows {
let window_id = crate::window::WindowId(super::WindowId::X(window_id)); let window_id = crate::window::WindowId(super::WindowId::X(window_id));
sticky_exit_callback( sticky_exit_callback(
Event::RedrawRequested(window_id), Event::RedrawRequested(window_id),