From 627e74ed7e0ac4cdf5c620e045dca09f667a0b8f Mon Sep 17 00:00:00 2001 From: Raphael Amorim Date: Thu, 23 May 2024 16:41:24 +0200 Subject: [PATCH] replicate changes of dynamic background made in ef00c52b5ad611e48484ca5667be9b6fc16d48b7 on main --- Cargo.lock | 2 +- frontends/rioterm/Cargo.toml | 2 +- frontends/rioterm/src/app/route.rs | 15 +++------------ frontends/rioterm/src/screen/mod.rs | 15 +++------------ frontends/rioterm/src/state/mod.rs | 11 +++++------ 5 files changed, 13 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3697e490f5..211af23d95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2458,7 +2458,7 @@ dependencies = [ "url", "wa", "wgpu", - "windows-sys 0.48.0", + "windows-sys 0.52.0", "winit", ] diff --git a/frontends/rioterm/Cargo.toml b/frontends/rioterm/Cargo.toml index d611c03680..ba78b8dfea 100644 --- a/frontends/rioterm/Cargo.toml +++ b/frontends/rioterm/Cargo.toml @@ -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", diff --git a/frontends/rioterm/src/app/route.rs b/frontends/rioterm/src/app/route.rs index 23870f647b..eb92f25fee 100644 --- a/frontends/rioterm/src/app/route.rs +++ b/frontends/rioterm/src/app/route.rs @@ -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, @@ -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); } @@ -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); } diff --git a/frontends/rioterm/src/screen/mod.rs b/frontends/rioterm/src/screen/mod.rs index 096184c457..6cab5eea45 100644 --- a/frontends/rioterm/src/screen/mod.rs +++ b/frontends/rioterm/src/screen/mod.rs @@ -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); } @@ -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); } diff --git a/frontends/rioterm/src/state/mod.rs b/frontends/rioterm/src/state/mod.rs index c480428f99..910cfc0bb5 100644 --- a/frontends/rioterm/src/state/mod.rs +++ b/frontends/rioterm/src/state/mod.rs @@ -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, background_opacity: f32, foreground_opacity: f32, @@ -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> = @@ -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,