1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-24 07:46:59 +03:00

gui: fixup tab bar height issue

In https://github.com/wez/wezterm/pull/1779#issuecomment-1082058134 we
discuss a weird case where the tab bar height is computed as 0 and then
gets stuck at 0.

What's happening is that the initial `TabBarState::default()` value has
no items yet, and `build_fancy_tab` generates an area that occupies 0
pixels.  This computed element is cached, and then the height from that
is cached.

When `invalidate_fancy_tab` is called, it didn't invalidate the cached
height and the resultant metrics were wonky.

One possible fix for this was to also invalidate the cached height,
but since that height is already stored in the built fancy tab,
we can remove that derived-cached value in favor of just passing
down the value.

refs: https://github.com/wez/wezterm/pull/1779
This commit is contained in:
Wez Furlong 2022-03-30 07:03:14 -07:00
parent ff88fec880
commit 808d7df8d4
2 changed files with 6 additions and 8 deletions

View File

@ -305,7 +305,6 @@ pub struct TermWindow {
show_scroll_bar: bool,
tab_bar: TabBarState,
fancy_tab_bar: Option<box_model::ComputedElement>,
fancy_tab_bar_height: Option<f32>,
pub right_status: String,
last_ui_item: Option<UIItem>,
/// Tracks whether the current mouse-down event is part of click-focus.
@ -641,7 +640,7 @@ impl TermWindow {
// for the tab bar state.
let show_tab_bar = config.enable_tab_bar && !config.hide_tab_bar_if_only_one_tab;
let tab_bar_height = if show_tab_bar {
Self::tab_bar_pixel_height_impl(&config, &fontconfig, &render_metrics, &None)? as usize
Self::tab_bar_pixel_height_impl(&config, &fontconfig, &render_metrics, None)? as usize
} else {
0
};
@ -729,7 +728,6 @@ impl TermWindow {
show_scroll_bar: config.enable_scroll_bar,
tab_bar: TabBarState::default(),
fancy_tab_bar: None,
fancy_tab_bar_height: None,
right_status: String::new(),
last_mouse_coords: (0, -1),
window_drag_position: None,

View File

@ -442,11 +442,11 @@ impl super::TermWindow {
config: &ConfigHandle,
fontconfig: &wezterm_font::FontConfiguration,
render_metrics: &RenderMetrics,
fancy_tab_bar_height: &Option<f32>,
fancy_tab_bar_height: Option<f32>,
) -> anyhow::Result<f32> {
if config.use_fancy_tab_bar {
if let Some(tab_bar_height) = fancy_tab_bar_height {
Ok(*tab_bar_height)
Ok(tab_bar_height)
} else {
let font = fontconfig.title_font()?;
Ok((font.metrics().cell_height.get() as f32 * 1.75).ceil())
@ -461,7 +461,9 @@ impl super::TermWindow {
&self.config,
&self.fonts,
&self.render_metrics,
&self.fancy_tab_bar_height,
self.fancy_tab_bar
.as_ref()
.map(|elem| elem.content_rect.size.height),
)
}
@ -854,8 +856,6 @@ impl super::TermWindow {
if self.fancy_tab_bar.is_none() {
let palette = self.palette().clone();
let tab_bar = self.build_fancy_tab_bar(&palette)?;
self.fancy_tab_bar_height
.replace(tab_bar.content_rect.size.height);
self.fancy_tab_bar.replace(tab_bar);
}