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,
|
futures::SinkExt,
|
||||||
keyboard::{Event as KeyEvent, KeyCode, Modifiers},
|
keyboard::{Event as KeyEvent, KeyCode, Modifiers},
|
||||||
subscription::{self, Subscription},
|
subscription::{self, Subscription},
|
||||||
window, Alignment, Event, Length, Limits, Padding, Point,
|
window, Alignment, Color, Event, Length, Limits, Padding, Point,
|
||||||
},
|
},
|
||||||
style,
|
style,
|
||||||
widget::{self, button, container, pane_grid, segmented_button, PaneGrid},
|
widget::{self, button, container, pane_grid, segmented_button, PaneGrid},
|
||||||
|
|
@ -25,7 +25,7 @@ use std::{
|
||||||
any::TypeId,
|
any::TypeId,
|
||||||
collections::{BTreeMap, BTreeSet, HashMap},
|
collections::{BTreeMap, BTreeSet, HashMap},
|
||||||
env, process,
|
env, process,
|
||||||
sync::Mutex,
|
sync::{atomic::Ordering, Mutex},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
@ -1413,7 +1413,17 @@ impl Application for App {
|
||||||
|
|
||||||
/// Creates a view after each update.
|
/// Creates a view after each update.
|
||||||
fn view(&self) -> Element<Self::Message> {
|
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 pane_grid = PaneGrid::new(&self.pane_model.panes, |pane, tab_model, _is_maximized| {
|
||||||
let mut tab_column = widget::column::with_capacity(1);
|
let mut tab_column = widget::column::with_capacity(1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,10 @@ use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
mem,
|
mem,
|
||||||
sync::{Arc, Weak},
|
sync::{
|
||||||
|
atomic::{AtomicU32, Ordering},
|
||||||
|
Arc, Weak,
|
||||||
|
},
|
||||||
time::Instant,
|
time::Instant,
|
||||||
};
|
};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
@ -98,6 +101,8 @@ fn as_dim(mut color: Color) -> Color {
|
||||||
color
|
color
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub static WINDOW_BG_COLOR: AtomicU32 = AtomicU32::new(0xFF000000);
|
||||||
|
|
||||||
fn convert_color(colors: &Colors, color: Color) -> cosmic_text::Color {
|
fn convert_color(colors: &Colors, color: Color) -> cosmic_text::Color {
|
||||||
let rgb = match color {
|
let rgb = match color {
|
||||||
Color::Named(named_color) => match colors[named_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 {
|
None => match named_color {
|
||||||
NamedColor::Background => {
|
NamedColor::Background => {
|
||||||
// Allow using an unset 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);
|
log::warn!("missing named color {:?}", named_color);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue