From cbeb51b43674c477ea03e97178694838ea26d8b2 Mon Sep 17 00:00:00 2001 From: Murarth Date: Sat, 7 Nov 2020 11:46:37 -0700 Subject: [PATCH] X11: Fix multiple RedrawRequested events per event loop iteration (#1758) * X11: Fix multiple RedrawRequested per event loop iteration * Prevent infinite loop --- src/platform_impl/linux/x11/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/platform_impl/linux/x11/mod.rs b/src/platform_impl/linux/x11/mod.rs index ffb9fc6e..d06936c5 100644 --- a/src/platform_impl/linux/x11/mod.rs +++ b/src/platform_impl/linux/x11/mod.rs @@ -24,7 +24,7 @@ pub use self::{ use std::{ cell::RefCell, - collections::HashMap, + collections::{HashMap, HashSet}, ffi::CStr, mem::{self, MaybeUninit}, ops::Deref, @@ -309,7 +309,13 @@ impl EventLoop { } // Empty the redraw requests { + let mut windows = HashSet::new(); + 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)); sticky_exit_callback( Event::RedrawRequested(window_id),