mirror of
https://github.com/wez/wezterm.git
synced 2024-11-23 15:04:36 +03:00
gui: fix cursor color invalidation issue
Things like compose cursor and dynamically changed cursor colors were not factored into our cache keys, making the cursor color "sticky" in the wrong ways. refs: https://github.com/wez/wezterm/issues/2708 Might possibly also help with https://github.com/wez/wezterm/issues/2635
This commit is contained in:
parent
274b1819a1
commit
1c8a20d577
@ -727,6 +727,20 @@ impl FromStr for SrgbaTuple {
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq)]
|
||||
pub struct LinearRgba(pub f32, pub f32, pub f32, pub f32);
|
||||
|
||||
impl Eq for LinearRgba {}
|
||||
|
||||
impl Hash for LinearRgba {
|
||||
fn hash<H>(&self, state: &mut H)
|
||||
where
|
||||
H: Hasher,
|
||||
{
|
||||
self.0.to_ne_bytes().hash(state);
|
||||
self.1.to_ne_bytes().hash(state);
|
||||
self.2.to_ne_bytes().hash(state);
|
||||
self.3.to_ne_bytes().hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
impl LinearRgba {
|
||||
/// Convert SRGBA u8 components to LinearRgba.
|
||||
/// Note that alpha in SRGBA colorspace is already linear,
|
||||
|
@ -107,6 +107,8 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
[#2112](https://github.com/wez/wezterm/issues/2112)
|
||||
* Horizontal wheel scrolling generated incorrect mouse events
|
||||
[#2649](https://github.com/wez/wezterm/issues/2649)
|
||||
* Cursor color changes did not always render
|
||||
[#2708](https://github.com/wez/wezterm/issues/2708)
|
||||
|
||||
|
||||
#### Changed
|
||||
|
@ -159,7 +159,6 @@ pub struct LineQuadCacheKey {
|
||||
pub shape_generation: usize,
|
||||
pub quad_generation: usize,
|
||||
/// Only set if cursor.y == stable_row
|
||||
/// Tuple is (cursor_x, compose-text)
|
||||
pub composing: Option<String>,
|
||||
pub selection: Range<usize>,
|
||||
pub shape_hash: [u8; 16],
|
||||
@ -170,7 +169,7 @@ pub struct LineQuadCacheKey {
|
||||
pub pane_is_active: bool,
|
||||
/// A cursor position with the y value fixed at 0.
|
||||
/// Only is_some() if the y value matches this row.
|
||||
pub cursor: Option<StableCursorPosition>,
|
||||
pub cursor: Option<CursorProperties>,
|
||||
pub reverse_video: bool,
|
||||
pub password_input: bool,
|
||||
}
|
||||
@ -277,12 +276,21 @@ pub struct RenderScreenLineOpenGLParams<'a> {
|
||||
pub password_input: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Hash, PartialEq, Eq, Clone)]
|
||||
pub struct CursorProperties {
|
||||
pub position: StableCursorPosition,
|
||||
pub dead_key_or_leader: bool,
|
||||
pub cursor_is_default_color: bool,
|
||||
pub cursor_fg: LinearRgba,
|
||||
pub cursor_bg: LinearRgba,
|
||||
pub cursor_border_color: LinearRgba,
|
||||
}
|
||||
|
||||
pub struct ComputeCellFgBgParams<'a> {
|
||||
pub selected: bool,
|
||||
pub cursor: Option<&'a StableCursorPosition>,
|
||||
pub fg_color: LinearRgba,
|
||||
pub bg_color: LinearRgba,
|
||||
pub palette: &'a ColorPalette,
|
||||
pub is_active_pane: bool,
|
||||
pub config: &'a ConfigHandle,
|
||||
pub selection_fg: LinearRgba,
|
||||
@ -1696,9 +1704,18 @@ impl super::TermWindow {
|
||||
|
||||
let (cursor, composing, password_input) = if self.cursor.y == stable_row {
|
||||
(
|
||||
Some(StableCursorPosition {
|
||||
y: 0,
|
||||
..*self.cursor
|
||||
Some(CursorProperties {
|
||||
position: StableCursorPosition {
|
||||
y: 0,
|
||||
..*self.cursor
|
||||
},
|
||||
dead_key_or_leader: self.term_window.dead_key_status
|
||||
!= DeadKeyStatus::None
|
||||
|| self.term_window.leader_is_active(),
|
||||
cursor_fg: self.cursor_fg,
|
||||
cursor_bg: self.cursor_bg,
|
||||
cursor_border_color: self.cursor_border_color,
|
||||
cursor_is_default_color: self.cursor_is_default_color,
|
||||
}),
|
||||
if let DeadKeyStatus::Composing(composing) =
|
||||
&self.term_window.dead_key_status
|
||||
@ -2705,7 +2722,6 @@ impl super::TermWindow {
|
||||
selected: false,
|
||||
fg_color,
|
||||
bg_color,
|
||||
palette: params.palette,
|
||||
is_active_pane: params.is_active,
|
||||
config: params.config,
|
||||
selection_fg: params.selection_fg,
|
||||
@ -2976,7 +2992,6 @@ impl super::TermWindow {
|
||||
selected,
|
||||
fg_color: item.fg_color,
|
||||
bg_color: item.bg_color,
|
||||
palette: params.palette,
|
||||
is_active_pane: params.is_active,
|
||||
config: params.config,
|
||||
selection_fg: params.selection_fg,
|
||||
|
Loading…
Reference in New Issue
Block a user