mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
parent
77127fbb41
commit
9ff2838844
4 changed files with 35 additions and 41 deletions
|
@ -73,6 +73,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Crash when trying to start on X11 with a Wayland compositor running
|
||||
- Crash with a virtual display connected on X11
|
||||
- Use `\` instead of `\\` as path separators on Windows for logging config file location
|
||||
- Underline/strikeout drawn above visual bell
|
||||
- Terminal going transparent during visual bell
|
||||
|
||||
### Removed
|
||||
|
||||
|
|
|
@ -400,27 +400,33 @@ impl Display {
|
|||
|
||||
let mut rects = lines.into_rects(&metrics, &size_info);
|
||||
|
||||
// Push visual bell after underline/strikeout rects
|
||||
if visual_bell_intensity != 0. {
|
||||
let visual_bell_rect = RenderRect::new(
|
||||
0.,
|
||||
0.,
|
||||
size_info.width,
|
||||
size_info.height,
|
||||
config.visual_bell.color,
|
||||
visual_bell_intensity as f32,
|
||||
);
|
||||
rects.push(visual_bell_rect);
|
||||
}
|
||||
|
||||
if let Some(message) = message_buffer.message() {
|
||||
let text = message.text(&size_info);
|
||||
|
||||
// Create a new rectangle for the background
|
||||
let start_line = size_info.lines().0 - text.len();
|
||||
let y = size_info.padding_y + size_info.cell_height * start_line as f32;
|
||||
rects.push(RenderRect::new(
|
||||
0.,
|
||||
y,
|
||||
size_info.width,
|
||||
size_info.height - y,
|
||||
message.color(),
|
||||
));
|
||||
let message_bar_rect =
|
||||
RenderRect::new(0., y, size_info.width, size_info.height - y, message.color(), 1.);
|
||||
|
||||
// Draw rectangles including the new background
|
||||
self.renderer.draw_rects(
|
||||
&size_info,
|
||||
config.visual_bell.color,
|
||||
visual_bell_intensity,
|
||||
rects,
|
||||
);
|
||||
// Push message_bar in the end, so it'll be above all other content
|
||||
rects.push(message_bar_rect);
|
||||
|
||||
// Draw rectangles
|
||||
self.renderer.draw_rects(&size_info, rects);
|
||||
|
||||
// Relay messages to the user
|
||||
let mut offset = 1;
|
||||
|
@ -437,12 +443,7 @@ impl Display {
|
|||
}
|
||||
} else {
|
||||
// Draw rectangles
|
||||
self.renderer.draw_rects(
|
||||
&size_info,
|
||||
config.visual_bell.color,
|
||||
visual_bell_intensity,
|
||||
rects,
|
||||
);
|
||||
self.renderer.draw_rects(&size_info, rects);
|
||||
}
|
||||
|
||||
// Draw render timer
|
||||
|
|
|
@ -713,13 +713,7 @@ impl QuadRenderer {
|
|||
}
|
||||
|
||||
// Draw all rectangles simultaneously to prevent excessive program swaps
|
||||
pub fn draw_rects(
|
||||
&mut self,
|
||||
props: &term::SizeInfo,
|
||||
visual_bell_color: Rgb,
|
||||
visual_bell_intensity: f64,
|
||||
cell_line_rects: Vec<RenderRect>,
|
||||
) {
|
||||
pub fn draw_rects(&mut self, props: &term::SizeInfo, rects: Vec<RenderRect>) {
|
||||
// Swap to rectangle rendering program
|
||||
unsafe {
|
||||
// Swap program
|
||||
|
@ -729,7 +723,7 @@ impl QuadRenderer {
|
|||
gl::Viewport(0, 0, props.width as i32, props.height as i32);
|
||||
|
||||
// Change blending strategy
|
||||
gl::BlendFunc(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA);
|
||||
gl::BlendFuncSeparate(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA, gl::SRC_ALPHA, gl::ONE);
|
||||
|
||||
// Setup data and buffers
|
||||
gl::BindVertexArray(self.rect_vao);
|
||||
|
@ -747,13 +741,9 @@ impl QuadRenderer {
|
|||
gl::EnableVertexAttribArray(0);
|
||||
}
|
||||
|
||||
// Draw visual bell
|
||||
let rect = RenderRect::new(0., 0., props.width, props.height, visual_bell_color);
|
||||
self.render_rect(&rect, visual_bell_intensity as f32, props);
|
||||
|
||||
// Draw underlines and strikeouts
|
||||
for cell_line_rect in cell_line_rects {
|
||||
self.render_rect(&cell_line_rect, 255., props);
|
||||
// Draw all the rects
|
||||
for rect in rects {
|
||||
self.render_rect(&rect, props);
|
||||
}
|
||||
|
||||
// Deactivate rectangle program again
|
||||
|
@ -881,9 +871,9 @@ impl QuadRenderer {
|
|||
// Render a rectangle
|
||||
//
|
||||
// This requires the rectangle program to be activated
|
||||
fn render_rect(&mut self, rect: &RenderRect, alpha: f32, size: &term::SizeInfo) {
|
||||
fn render_rect(&mut self, rect: &RenderRect, size: &term::SizeInfo) {
|
||||
// Do nothing when alpha is fully transparent
|
||||
if alpha == 0. {
|
||||
if rect.alpha == 0. {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -908,7 +898,7 @@ impl QuadRenderer {
|
|||
);
|
||||
|
||||
// Color
|
||||
self.rect_program.set_color(rect.color, alpha);
|
||||
self.rect_program.set_color(rect.color, rect.alpha);
|
||||
|
||||
// Draw the rectangle
|
||||
gl::DrawElements(gl::TRIANGLES, 6, gl::UNSIGNED_INT, ptr::null());
|
||||
|
|
|
@ -27,11 +27,12 @@ pub struct RenderRect {
|
|||
pub width: f32,
|
||||
pub height: f32,
|
||||
pub color: Rgb,
|
||||
pub alpha: f32,
|
||||
}
|
||||
|
||||
impl RenderRect {
|
||||
pub fn new(x: f32, y: f32, width: f32, height: f32, color: Rgb) -> Self {
|
||||
RenderRect { x, y, width, height, color }
|
||||
pub fn new(x: f32, y: f32, width: f32, height: f32, color: Rgb, alpha: f32) -> Self {
|
||||
RenderRect { x, y, width, height, color, alpha }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +66,7 @@ impl RenderLine {
|
|||
y = max_y;
|
||||
}
|
||||
|
||||
RenderRect::new(start_x + size.padding_x, y + size.padding_y, width, height, self.color)
|
||||
RenderRect::new(start_x + size.padding_x, y + size.padding_y, width, height, self.color, 1.)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue