Enable damage tracking only on Wayland

Other platforms don't have such concepts in general or have them
via different interfaces not related to EGL.

This commit also resolves some minor clippy issues.

Fixes #6051.

Co-authored-by: Christian Duerr <contact@christianduerr.com>
This commit is contained in:
Kirill Chibisov 2022-05-20 22:23:55 +03:00 committed by GitHub
parent e319ca93a6
commit 9f8c5c4f56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View File

@ -471,7 +471,23 @@ impl Window {
self.windowed_context.swap_buffers_with_damage(damage).expect("swap buffes with damage");
}
#[cfg(any(target_os = "macos", windows))]
pub fn swap_buffers_with_damage_supported(&self) -> bool {
// Disable damage tracking on macOS/Windows since there's no observation of it working.
false
}
#[cfg(not(any(target_os = "macos", windows)))]
pub fn swap_buffers_with_damage_supported(&self) -> bool {
// On X11 damage tracking is behaving in unexpected ways on some NVIDIA systems. Since
// there's no compositor supporting it, damage tracking is disabled on X11.
//
// For more see https://github.com/alacritty/alacritty/issues/6051.
#[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))]
if self.window().xlib_window().is_some() {
return false;
}
self.windowed_context.swap_buffers_with_damage_supported()
}

View File

@ -1,6 +1,7 @@
//! ANSI Terminal Stream Parsing.
use std::convert::TryFrom;
use std::fmt::Write;
use std::time::{Duration, Instant};
use std::{iter, str};
@ -950,7 +951,7 @@ where
for items in params {
buf.push('[');
for item in *items {
buf.push_str(&format!("{:?},", *item as char));
let _ = write!(buf, "{:?}", *item as char);
}
buf.push_str("],");
}

View File

@ -175,7 +175,7 @@ impl<T> Storage<T> {
/// Rotate the grid, moving all lines up/down in history.
#[inline]
pub fn rotate(&mut self, count: isize) {
debug_assert!(count.abs() as usize <= self.inner.len());
debug_assert!(count.unsigned_abs() <= self.inner.len());
let len = self.inner.len();
self.zero = (self.zero as isize + count + len as isize) as usize % len;