Fix selection when using window background as terminal background
This commit is contained in:
parent
c0d7fed185
commit
d043f45b0f
2 changed files with 20 additions and 5 deletions
16
src/main.rs
16
src/main.rs
|
|
@ -14,7 +14,7 @@ use cosmic::{
|
|||
futures::SinkExt,
|
||||
keyboard::{Event as KeyEvent, KeyCode, Modifiers},
|
||||
subscription::{self, Subscription},
|
||||
window, Alignment, Event, Length, Limits, Padding, Point,
|
||||
window, Alignment, Color, Event, Length, Limits, Padding, Point,
|
||||
},
|
||||
style,
|
||||
widget::{self, button, container, pane_grid, segmented_button, PaneGrid},
|
||||
|
|
@ -25,7 +25,7 @@ use std::{
|
|||
any::TypeId,
|
||||
collections::{BTreeMap, BTreeSet, HashMap},
|
||||
env, process,
|
||||
sync::Mutex,
|
||||
sync::{atomic::Ordering, Mutex},
|
||||
time::Duration,
|
||||
};
|
||||
use tokio::sync::mpsc;
|
||||
|
|
@ -1413,7 +1413,17 @@ impl Application for App {
|
|||
|
||||
/// Creates a view after each update.
|
||||
fn view(&self) -> Element<Self::Message> {
|
||||
let cosmic_theme::Spacing { space_xxs, .. } = self.core().system_theme().cosmic().spacing;
|
||||
let cosmic_theme = self.core().system_theme().cosmic();
|
||||
let cosmic_theme::Spacing { space_xxs, .. } = cosmic_theme.spacing;
|
||||
{
|
||||
let color = Color::from(cosmic_theme.bg_color());
|
||||
let bytes = color.into_rgba8();
|
||||
let data = (bytes[0] as u32)
|
||||
| ((bytes[1] as u32) << 8)
|
||||
| ((bytes[2] as u32) << 16)
|
||||
| 0xFF000000;
|
||||
terminal::WINDOW_BG_COLOR.store(data, Ordering::SeqCst);
|
||||
}
|
||||
let pane_grid = PaneGrid::new(&self.pane_model.panes, |pane, tab_model, _is_maximized| {
|
||||
let mut tab_column = widget::column::with_capacity(1);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,10 @@ use std::{
|
|||
borrow::Cow,
|
||||
collections::HashMap,
|
||||
mem,
|
||||
sync::{Arc, Weak},
|
||||
sync::{
|
||||
atomic::{AtomicU32, Ordering},
|
||||
Arc, Weak,
|
||||
},
|
||||
time::Instant,
|
||||
};
|
||||
use tokio::sync::mpsc;
|
||||
|
|
@ -98,6 +101,8 @@ fn as_dim(mut color: Color) -> Color {
|
|||
color
|
||||
}
|
||||
|
||||
pub static WINDOW_BG_COLOR: AtomicU32 = AtomicU32::new(0xFF000000);
|
||||
|
||||
fn convert_color(colors: &Colors, color: Color) -> cosmic_text::Color {
|
||||
let rgb = match color {
|
||||
Color::Named(named_color) => match colors[named_color] {
|
||||
|
|
@ -105,7 +110,7 @@ fn convert_color(colors: &Colors, color: Color) -> cosmic_text::Color {
|
|||
None => match named_color {
|
||||
NamedColor::Background => {
|
||||
// Allow using an unset background
|
||||
return cosmic_text::Color(0);
|
||||
return cosmic_text::Color(WINDOW_BG_COLOR.load(Ordering::SeqCst));
|
||||
}
|
||||
_ => {
|
||||
log::warn!("missing named color {:?}", named_color);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue