Skip to content

Commit

Permalink
replicate changes of dynamic background made in ef00c52 on main
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed May 23, 2024
1 parent 959dbce commit 627e74e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontends/rioterm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ wa = { workspace = true }
[target.'cfg(windows)'.dependencies]
ahash = { version = "0.8.2", default-features = false, features = ["std"] }
tinyvec = { version = "1.6.0", features = ["alloc"] }
windows-sys = { version = "0.48", features = [
windows-sys = { version = "0.52", features = [
"Win32_System_Console",
"Win32_Foundation",
"Win32_Security",
Expand Down
15 changes: 3 additions & 12 deletions frontends/rioterm/src/app/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,6 @@ impl Route {
let ime = Ime::new();

let background_image = config.window.background_image.clone();
let background_color = wgpu::Color {
a: config.window.background_opacity as f64,
..config.colors.background.1
};

let power_preference = match config.renderer.performance {
RendererPerformance::High => wgpu::PowerPreference::HighPerformance,
Expand Down Expand Up @@ -217,7 +213,7 @@ impl Route {
config.keyboard,
);

sugarloaf.set_background_color(background_color);
sugarloaf.set_background_color(state.dynamic_background);
if let Some(image) = background_image {
sugarloaf.set_background_image(&image);
}
Expand Down Expand Up @@ -1129,13 +1125,8 @@ impl Route {
layout.update();
self.resize_all_contexts();

let mut bg_color = self.state.named_colors.background.1;

if config.window.background_opacity < 1. {
bg_color.a = config.window.background_opacity as f64;
}

self.sugarloaf.set_background_color(bg_color);
self.sugarloaf
.set_background_color(self.state.dynamic_background);
if let Some(image) = &config.window.background_image {
self.sugarloaf.set_background_image(image);
}
Expand Down
15 changes: 3 additions & 12 deletions frontends/rioterm/src/screen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,7 @@ impl Screen {
sugarloaf_errors,
)?;

let mut bg_color = state.named_colors.background.1;
if config.window.background_opacity < 1. {
bg_color.a = config.window.background_opacity as f64;
}
sugarloaf.set_background_color(bg_color);
sugarloaf.set_background_color(state.dynamic_background);
if let Some(image) = &config.window.background_image {
sugarloaf.set_background_image(image);
}
Expand Down Expand Up @@ -308,13 +304,8 @@ impl Screen {
self.mouse
.set_multiplier_and_divider(config.scroll.multiplier, config.scroll.divider);

let mut bg_color = self.state.named_colors.background.1;

if config.window.background_opacity < 1. {
bg_color.a = config.window.background_opacity as f64;
}

self.sugarloaf.set_background_color(bg_color);
self.sugarloaf
.set_background_color(state.dynamic_background);
if let Some(image) = &config.window.background_image {
self.sugarloaf.set_background_image(image);
}
Expand Down
11 changes: 5 additions & 6 deletions frontends/rioterm/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct State {
pub has_blinking_enabled: bool,
pub is_blinking: bool,
ignore_selection_fg_color: bool,
dynamic_background: ([f32; 4], wgpu::Color),
pub dynamic_background: wgpu::Color,
hyperlink_range: Option<SelectionRange>,
background_opacity: f32,
foreground_opacity: f32,
Expand Down Expand Up @@ -91,12 +91,11 @@ impl State {
}
}

let dynamic_background = if config.window.background_image.is_some()
let mut dynamic_background = named_colors.background.1;
if config.window.background_image.is_some()
|| config.window.background_opacity < 1.
{
([0., 0., 0., 0.], wgpu::Color::TRANSPARENT)
} else {
named_colors.background
dynamic_background = wgpu::Color::TRANSPARENT;
};

let mut color_automation: HashMap<String, HashMap<String, [f32; 4]>> =
Expand Down Expand Up @@ -382,7 +381,7 @@ impl State {
fn compute_bg_color(&self, square: &Square) -> ColorArray {
let mut color = match square.bg {
AnsiColor::Named(ansi_name) => match (ansi_name, square.flags) {
(NamedColor::Background, _) => self.dynamic_background.0,
(NamedColor::Background, _) => self.named_colors.background.0,
(NamedColor::Cursor, _) => self.named_colors.cursor,

(NamedColor::Black, Flags::DIM) => self.named_colors.dim_black,
Expand Down

0 comments on commit 627e74e

Please sign in to comment.