From 3808cf3f58cb78f795c45d27bb37cb33da877448 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 27 Oct 2020 22:09:03 -0700 Subject: [PATCH] wezterm: fixup overall background color When padding was set, it was being overwritten by black whitespace unconditionally. This fixes that. refs: #309 --- wezterm-gui/src/gui/fragment.glsl | 7 ++++--- wezterm-gui/src/gui/quad.rs | 10 +++++++++- wezterm-gui/src/gui/termwindow.rs | 18 +++++++----------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/wezterm-gui/src/gui/fragment.glsl b/wezterm-gui/src/gui/fragment.glsl index 5a36580ce..7889e6664 100644 --- a/wezterm-gui/src/gui/fragment.glsl +++ b/wezterm-gui/src/gui/fragment.glsl @@ -68,13 +68,14 @@ void main() { color = texture(atlas_linear_sampler, o_tex); // Apply window_background_image_opacity to the background image color.a = o_bg_color.a; + } else if (o_has_color == 3.0) { + color = o_bg_color; } else { // Nothing else should render on the background layer - // color = vec4(0,0,0,0); discard; } } else if (bg_and_line_layer) { - if (o_has_color == 2.0) { + if (o_has_color >= 2.0) { // Don't render the background image on anything other than // the window_bg_layer. discard; @@ -104,7 +105,7 @@ void main() { color = o_cursor_color; } } else { - if (o_has_color == 2.0) { + if (o_has_color >= 2.0) { // Don't render the background image on anything other than // the window_bg_layer. discard; diff --git a/wezterm-gui/src/gui/quad.rs b/wezterm-gui/src/gui/quad.rs index 44465b70d..9c7ce1f48 100644 --- a/wezterm-gui/src/gui/quad.rs +++ b/wezterm-gui/src/gui/quad.rs @@ -35,12 +35,14 @@ pub struct Vertex { // bool or integer values to work: // "bool can't be an in in the vertex shader" // - // has_color is effectively an enum with three + // has_color is effectively an enum with these // possible values: // 0.0 -> a regular monochrome text glyph // 1.0 -> a color emoji glyph // 2.0 -> a full color texture attached as the // background image of the window + // 3.0 -> like 2.0, except that instead of an + // image, we use the solid bg color pub has_color: f32, } ::window::glium::implement_vertex!( @@ -156,6 +158,12 @@ impl<'a> Quad<'a> { } } + pub fn set_is_background(&mut self) { + for v in self.vert.iter_mut() { + v.has_color = 3.0; + } + } + pub fn set_fg_color(&mut self, color: Color) { let color = color.to_tuple_rgba(); for v in self.vert.iter_mut() { diff --git a/wezterm-gui/src/gui/termwindow.rs b/wezterm-gui/src/gui/termwindow.rs index 9aa3d20ee..f3c2a45ea 100644 --- a/wezterm-gui/src/gui/termwindow.rs +++ b/wezterm-gui/src/gui/termwindow.rs @@ -737,7 +737,7 @@ impl WindowCallbacks for TermWindow { } for pass in 0.. { - match self.paint_opengl_pass(frame) { + match self.paint_opengl_pass() { Ok(_) => break, Err(err) => { if let Some(&OutOfTextureSpace { size: Some(size) }) = @@ -2357,12 +2357,8 @@ impl TermWindow { Ok(()) } - fn paint_opengl_pass(&mut self, frame: &mut glium::Frame) -> anyhow::Result<()> { + fn paint_opengl_pass(&mut self) -> anyhow::Result<()> { let panes = self.get_panes_to_render(); - if panes.is_empty() { - frame.clear_color_srgb(0., 0., 0., 1.); - return Ok(()); - } if let Some(pane) = self.get_active_pane_or_overlay() { let splits = self.get_splits(); @@ -2493,23 +2489,23 @@ impl TermWindow { let white_space = gl_state.util_sprites.white_space.texture_coords(); quad.set_underline(white_space); quad.set_cursor(white_space); - quad.set_has_color(false); let background_image_alpha = (config.window_background_opacity * 255.0) as u8; - let color = Color::rgba(0, 0, 0, background_image_alpha); - quad.set_texture_adjust(0., 0., 0., 0.); + let color = rgbcolor_alpha_to_window_color(palette.background, background_image_alpha); - quad.set_texture(white_space); if let Some(im) = self.window_background.as_ref() { let sprite = gl_state.glyph_cache.borrow_mut().cached_image(im, None)?; quad.set_texture(sprite.texture_coords()); quad.set_is_background_image(); + } else { + quad.set_texture(white_space); + quad.set_is_background(); } + quad.set_texture_adjust(0., 0., 0., 0.); quad.set_hsv(config.window_background_image_hsb); quad.set_cursor_color(color); quad.set_fg_color(color); quad.set_bg_color(color); - quad.set_cursor_color(color); } let selrange = self.selection(pos.pane.pane_id()).range.clone();