aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/window.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2020-12-22 04:25:43 +0000
committerGitHub <noreply@github.com>2020-12-22 04:25:43 +0000
commitf19cbca9b4c98a33b786bd971e3abae66bd16e26 (patch)
tree7fe9ebce9cc2354029eb5458fe4517a194fd94da /alacritty/src/window.rs
parent8982000f01d5f476a995385253139b3555e2a5d0 (diff)
downloadr-alacritty-f19cbca9b4c98a33b786bd971e3abae66bd16e26.tar.gz
r-alacritty-f19cbca9b4c98a33b786bd971e3abae66bd16e26.tar.bz2
r-alacritty-f19cbca9b4c98a33b786bd971e3abae66bd16e26.zip
Disable shadows for transparent windows on macOS
Commit 5725f58 introduced a performance regression on macOS due to excessive calls to the `invalidateShadow` function, however calling this function only on redraw after a resize was performed does not fix the underlying problem. As a solution, window shadows are now disabled completely for all transparent windows. This makes sure there is no performance impact, while still solving the problem with text artifacts on resize. Fixes #4604.
Diffstat (limited to 'alacritty/src/window.rs')
-rw-r--r--alacritty/src/window.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/alacritty/src/window.rs b/alacritty/src/window.rs
index 1b874d15..418994ed 100644
--- a/alacritty/src/window.rs
+++ b/alacritty/src/window.rs
@@ -32,7 +32,7 @@ use {
use std::fmt::{self, Display, Formatter};
#[cfg(target_os = "macos")]
-use cocoa::base::id;
+use cocoa::base::{id, NO, YES};
use glutin::dpi::{PhysicalPosition, PhysicalSize};
use glutin::event_loop::EventLoop;
#[cfg(target_os = "macos")]
@@ -441,16 +441,19 @@ impl Window {
self.windowed_context.resize(size);
}
- /// Force macOS to clear shadow of transparent windows.
+ /// Disable macOS window shadows.
+ ///
+ /// This prevents rendering artifacts from showing up when the window is transparent.
#[cfg(target_os = "macos")]
- pub fn invalidate_shadow(&self) {
+ pub fn set_has_shadow(&self, has_shadows: bool) {
let raw_window = match self.window().raw_window_handle() {
RawWindowHandle::MacOS(handle) => handle.ns_window as id,
_ => return,
};
+ let value = if has_shadows { YES } else { NO };
unsafe {
- let _: () = msg_send![raw_window, invalidateShadow];
+ let _: () = msg_send![raw_window, setHasShadow: value];
}
}