Fix busy rendering when the same warning persists

When the same warning is thrown on the each rendering iteration, it'll
force alacritty to always render.

Co-authored-by: Christian Duerr <contact@christianduerr.com>
This commit is contained in:
Kirill Chibisov 2023-03-02 21:49:42 +03:00 committed by GitHub
parent bf58748055
commit 66d742d059
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -1207,7 +1207,8 @@ impl input::Processor<EventProxy, ActionContext<'_, Notifier, EventProxy>> {
self.ctx.display.cursor_hidden = false;
*self.ctx.dirty = true;
},
EventType::Message(message) => {
// Add message only if it's not already queued.
EventType::Message(message) if !self.ctx.message_buffer.is_queued(&message) => {
self.ctx.message_buffer.push(message);
self.ctx.display.pending_update.dirty = true;
},
@ -1266,7 +1267,8 @@ impl input::Processor<EventProxy, ActionContext<'_, Notifier, EventProxy>> {
},
#[cfg(unix)]
EventType::IpcConfig(_) => (),
EventType::ConfigReload(_) | EventType::CreateWindow(_) => (),
EventType::ConfigReload(_) | EventType::CreateWindow(_) | EventType::Message(_) => {
},
},
WinitEvent::RedrawRequested(_) => *self.ctx.dirty = true,
WinitEvent::WindowEvent { event, .. } => {

View File

@ -181,6 +181,12 @@ impl MessageBuffer {
pub fn push(&mut self, message: Message) {
self.messages.push_back(message);
}
/// Check whether the message is already queued in the message bar.
#[inline]
pub fn is_queued(&self, message: &Message) -> bool {
self.messages.contains(message)
}
}
#[cfg(test)]