window_decorations: add MACOS_FORCE_(EN|DIS)ABLE_SHADOW
Evidence: * https://github.com/wez/wezterm/issues/310#issuecomment-718288028 * https://github.com/wez/wezterm/issues/2669#issuecomment-1379829866 * https://github.com/wez/wezterm/issues/2669#issuecomment-1408144931 seems to suggest that window shadows hurt performance, so add a way to disable them independently from window opacity. You may use: ``` config.window_decorations = "TITLE|RESIZE|MACOS_FORCE_DISABLE_SHADOW" ``` for this. refs: https://github.com/wez/wezterm/issues/2669
This commit is contained in:
2 files changed
+27
-2
No files matched your search
@@ -1276,6 +1276,10 @@ bitflags! {
|
||||
const TITLE = 1;
|
||||
const RESIZE = 2;
|
||||
const NONE = 0;
|
||||
// Reserve two bits for this enable/disable shadow,
|
||||
// so that we effective have Option<bool>
|
||||
const MACOS_FORCE_DISABLE_SHADOW = 4;
|
||||
const MACOS_FORCE_ENABLE_SHADOW = 4|8;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1291,6 +1295,10 @@ impl TryFrom<String> for WindowDecorations {
|
||||
flags = Self::NONE;
|
||||
} else if ele == "RESIZE" {
|
||||
flags |= Self::RESIZE;
|
||||
} else if ele == "MACOS_FORCE_DISABLE_SHADOW" {
|
||||
flags |= Self::MACOS_FORCE_DISABLE_SHADOW;
|
||||
} else if ele == "MACOS_FORCE_ENABLE_SHADOW" {
|
||||
flags |= Self::MACOS_FORCE_ENABLE_SHADOW;
|
||||
} else {
|
||||
return Err(format!("invalid WindowDecoration name {} in {}", ele, s));
|
||||
}
|
||||
|
||||
@@ -986,8 +986,25 @@ impl WindowInner {
|
||||
// when transparent, also turn off the window shadow,
|
||||
// because having the shadow enabled seems to correlate
|
||||
// with ghostly remnants see:
|
||||
// https://github.com/wez/wezterm/issues/310
|
||||
self.window.setHasShadow_(is_opaque);
|
||||
// https://github.com/wez/wezterm/issues/310.
|
||||
// But allow overriding the shadows independent of opacity as well:
|
||||
// <https://github.com/wez/wezterm/issues/2669>
|
||||
let shadow = if self
|
||||
.config
|
||||
.window_decorations
|
||||
.contains(WindowDecorations::MACOS_FORCE_ENABLE_SHADOW)
|
||||
{
|
||||
YES
|
||||
} else if self
|
||||
.config
|
||||
.window_decorations
|
||||
.contains(WindowDecorations::MACOS_FORCE_DISABLE_SHADOW)
|
||||
{
|
||||
NO
|
||||
} else {
|
||||
is_opaque
|
||||
};
|
||||
self.window.setHasShadow_(shadow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user