summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md5
-rw-r--r--alacritty.yml19
-rw-r--r--alacritty/res/text.f.glsl2
-rw-r--r--alacritty/res/text.v.glsl2
-rw-r--r--alacritty/src/config/color.rs1
-rw-r--r--alacritty/src/config/ui_config.rs9
-rw-r--r--alacritty/src/config/window.rs8
-rw-r--r--alacritty/src/display/content.rs6
-rw-r--r--alacritty/src/display/mod.rs2
-rw-r--r--alacritty/src/event.rs2
-rw-r--r--alacritty/src/renderer/mod.rs2
11 files changed, 39 insertions, 19 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7d311129..b5fe851b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,9 +7,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## 0.10.0-dev
+### Added
+
+- Option `colors.transparent_background_colors` to allow applying opacity to all background colors
+
### Changed
- `ExpandSelection` is now a configurable mouse binding action
+- Config option `background_opacity`, you should use `window.opacity` instead
## 0.9.0
diff --git a/alacritty.yml b/alacritty.yml
index e93f3f74..04654e56 100644
--- a/alacritty.yml
+++ b/alacritty.yml
@@ -63,6 +63,12 @@
# - buttonless: Title bar, transparent background and no title bar buttons
#decorations: full
+ # Background opacity
+ #
+ # Window opacity as a floating point number from `0.0` to `1.0`.
+ # The value `0.0` is completely transparent and `1.0` is opaque.
+ #opacity: 1.0
+
# Startup Mode (changes require restart)
#
# Values for `startup_mode`:
@@ -312,6 +318,13 @@
#
#indexed_colors: []
+ # Transparent cell backgrounds
+ #
+ # Whether or not `window.opacity` applies to all cell backgrounds or only to
+ # the default background. When set to `true` all cells will be transparent
+ # regardless of their background color.
+ #transparent_background_colors: false
+
# Bell
#
# The bell is rung every time the BEL control character is received.
@@ -353,12 +366,6 @@
#
#command: None
-# Background opacity
-#
-# Window opacity as a floating point number from `0.0` to `1.0`.
-# The value `0.0` is completely transparent and `1.0` is opaque.
-#background_opacity: 1.0
-
#selection:
# This string contains all characters that are used as separators for
# "semantic words" in Alacritty.
diff --git a/alacritty/res/text.f.glsl b/alacritty/res/text.f.glsl
index d5e26881..5b4e3da6 100644
--- a/alacritty/res/text.f.glsl
+++ b/alacritty/res/text.f.glsl
@@ -18,7 +18,7 @@ void main() {
}
alphaMask = vec4(1.0);
- color = vec4(bg.rgb, 1.0);
+ color = vec4(bg.rgb, bg.a);
} else if ((int(fg.a) & COLORED) != 0) {
// Color glyphs, like emojis.
vec4 glyphColor = texture(mask, TexCoords);
diff --git a/alacritty/res/text.v.glsl b/alacritty/res/text.v.glsl
index 31e6f934..a4a31382 100644
--- a/alacritty/res/text.v.glsl
+++ b/alacritty/res/text.v.glsl
@@ -65,6 +65,6 @@ void main() {
TexCoords = uvOffset + position * uvSize;
}
- bg = vec4(backgroundColor.rgb / 255.0, backgroundColor.a);
+ bg = backgroundColor / 255.0;
fg = vec4(textColor.rgb / 255.0, textColor.a);
}
diff --git a/alacritty/src/config/color.rs b/alacritty/src/config/color.rs
index ddb1da29..c0076edb 100644
--- a/alacritty/src/config/color.rs
+++ b/alacritty/src/config/color.rs
@@ -17,6 +17,7 @@ pub struct Colors {
pub search: SearchColors,
pub line_indicator: LineIndicatorColors,
pub hints: HintColors,
+ pub transparent_background_colors: bool,
}
impl Colors {
diff --git a/alacritty/src/config/ui_config.rs b/alacritty/src/config/ui_config.rs
index cf0f9298..f0917cf5 100644
--- a/alacritty/src/config/ui_config.rs
+++ b/alacritty/src/config/ui_config.rs
@@ -69,7 +69,8 @@ pub struct UiConfig {
mouse_bindings: MouseBindings,
/// Background opacity from 0.0 to 1.0.
- background_opacity: Percentage,
+ #[config(deprecated = "use window.opacity instead")]
+ window_opacity: Option<Percentage>,
}
impl Default for UiConfig {
@@ -84,7 +85,7 @@ impl Default for UiConfig {
config_paths: Default::default(),
key_bindings: Default::default(),
mouse_bindings: Default::default(),
- background_opacity: Default::default(),
+ window_opacity: Default::default(),
bell: Default::default(),
colors: Default::default(),
draw_bold_text_with_bright_colors: Default::default(),
@@ -115,8 +116,8 @@ impl UiConfig {
}
#[inline]
- pub fn background_opacity(&self) -> f32 {
- self.background_opacity.as_f32()
+ pub fn window_opacity(&self) -> f32 {
+ self.window_opacity.unwrap_or(self.window.opacity).as_f32()
}
#[inline]
diff --git a/alacritty/src/config/window.rs b/alacritty/src/config/window.rs
index d74390d8..f7a7511c 100644
--- a/alacritty/src/config/window.rs
+++ b/alacritty/src/config/window.rs
@@ -7,7 +7,7 @@ use serde::de::{self, MapAccess, Visitor};
use serde::{Deserialize, Deserializer};
use alacritty_config_derive::ConfigDeserialize;
-use alacritty_terminal::config::LOG_TARGET_CONFIG;
+use alacritty_terminal::config::{Percentage, LOG_TARGET_CONFIG};
use alacritty_terminal::index::Column;
use crate::config::ui_config::Delta;
@@ -15,7 +15,7 @@ use crate::config::ui_config::Delta;
/// Default Alacritty name, used for window title and class.
pub const DEFAULT_NAME: &str = "Alacritty";
-#[derive(ConfigDeserialize, Debug, Clone, PartialEq, Eq)]
+#[derive(ConfigDeserialize, Debug, Clone, PartialEq)]
pub struct WindowConfig {
/// Initial position.
pub position: Option<Delta<i32>>,
@@ -45,6 +45,9 @@ pub struct WindowConfig {
/// Window class.
pub class: Class,
+ /// Background opacity from 0.0 to 1.0.
+ pub opacity: Percentage,
+
/// Pixel padding.
padding: Delta<u8>,
@@ -64,6 +67,7 @@ impl Default for WindowConfig {
gtk_theme_variant: Default::default(),
dynamic_padding: Default::default(),
class: Default::default(),
+ opacity: Default::default(),
padding: Default::default(),
dimensions: Default::default(),
}
diff --git a/alacritty/src/display/content.rs b/alacritty/src/display/content.rs
index 05bd0438..2deb3d3e 100644
--- a/alacritty/src/display/content.rs
+++ b/alacritty/src/display/content.rs
@@ -203,7 +203,7 @@ impl RenderableCell {
mem::swap(&mut fg, &mut bg);
1.0
} else {
- Self::compute_bg_alpha(cell.bg)
+ Self::compute_bg_alpha(&content.config.ui_config, cell.bg)
};
let is_selected = content.terminal_content.selection.map_or(false, |selection| {
@@ -350,9 +350,11 @@ impl RenderableCell {
/// using the named input color, rather than checking the RGB of the background after its color
/// is computed.
#[inline]
- fn compute_bg_alpha(bg: Color) -> f32 {
+ fn compute_bg_alpha(config: &UiConfig, bg: Color) -> f32 {
if bg == Color::Named(NamedColor::Background) {
0.
+ } else if config.colors.transparent_background_colors {
+ config.window_opacity()
} else {
1.
}
diff --git a/alacritty/src/display/mod.rs b/alacritty/src/display/mod.rs
index cce3c8bd..d4c5c274 100644
--- a/alacritty/src/display/mod.rs
+++ b/alacritty/src/display/mod.rs
@@ -299,7 +299,7 @@ impl Display {
// Disable shadows for transparent windows on macOS.
#[cfg(target_os = "macos")]
- window.set_has_shadow(config.ui_config.background_opacity() >= 1.0);
+ window.set_has_shadow(config.ui_config.window_opacity() >= 1.0);
// On Wayland we can safely ignore this call, since the window isn't visible until you
// actually draw something into it and commit those changes.
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs
index bc9c305a..cc817f6e 100644
--- a/alacritty/src/event.rs
+++ b/alacritty/src/event.rs
@@ -1436,7 +1436,7 @@ impl<N: Notify + OnResize> Processor<N> {
// Disable shadows for transparent windows on macOS.
#[cfg(target_os = "macos")]
- processor.ctx.window().set_has_shadow(config.ui_config.background_opacity() >= 1.0);
+ processor.ctx.window().set_has_shadow(config.ui_config.window_opacity() >= 1.0);
// Update hint keys.
processor.ctx.display.hint_state.update_alphabet(config.ui_config.hints.alphabet());
diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs
index 5f71ddf5..11ccfc63 100644
--- a/alacritty/src/renderer/mod.rs
+++ b/alacritty/src/renderer/mod.rs
@@ -767,7 +767,7 @@ impl Drop for QuadRenderer {
impl<'a> RenderApi<'a> {
pub fn clear(&self, color: Rgb) {
unsafe {
- let alpha = self.config.background_opacity();
+ let alpha = self.config.window_opacity();
gl::ClearColor(
(f32::from(color.r) / 255.0).min(1.0) * alpha,
(f32::from(color.g) / 255.0).min(1.0) * alpha,