Skip to content

Commit

Permalink
Removed pane_id where not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
e82eric committed Jun 23, 2024
1 parent 86c9efd commit 9bd3c95
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 53 deletions.
13 changes: 2 additions & 11 deletions mux/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub trait Domain: Downcast + Send + Sync {
async fn add_float_pane(
&self,
tab: TabId,
pane_id: PaneId,
_pane_id: PaneId,
command_builder: Option<CommandBuilder>,
command_dir: Option<String>
) -> anyhow::Result<Arc<dyn Pane>> {
Expand All @@ -84,18 +84,9 @@ pub trait Domain: Downcast + Send + Sync {
None => anyhow::bail!("Invalid tab id {}", tab),
};

let pane_index = match tab
.iter_panes_ignoring_zoom()
.iter()
.find(|p| p.pane.pane_id() == pane_id)
{
Some(p) => p.index,
None => anyhow::bail!("invalid pane id {}", pane_id),
};

let float_pos = tab.get_float_pos();
let pane = self.spawn_pane(float_pos.size, command_builder, command_dir) .await?;
tab.insert_float(pane_index, float_pos.size, Arc::clone(&pane))?;
tab.insert_float(float_pos.size, Arc::clone(&pane))?;
Ok(pane)
}

Expand Down
11 changes: 4 additions & 7 deletions mux/src/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,13 +777,12 @@ impl Tab {

pub fn insert_float(
&self,
pane_index: usize,
float_size: TerminalSize,
pane: Arc<dyn Pane>,
) -> anyhow::Result<usize> {
) -> anyhow::Result<()> {
self.inner
.lock()
.add_float_pane(pane_index, float_size, pane)
.add_float_pane(float_size, pane)
}

pub fn get_zoomed_pane(&self) -> Option<Arc<dyn Pane>> {
Expand Down Expand Up @@ -2077,10 +2076,9 @@ impl TabInner {

fn add_float_pane(
&mut self,
pane_index: usize,
float_size: TerminalSize,
pane: Arc<dyn Pane>,
) -> anyhow::Result<usize> {
) -> anyhow::Result<()> {
if self.zoomed.is_some() {
anyhow::bail!("cannot add float while zoomed");
}
Expand All @@ -2092,10 +2090,9 @@ impl TabInner {
self.float_pane = Some(Arc::clone(&pane));
{
pane.resize(float_size)?;
self.set_active_idx(0);
}

Ok(pane_index + 1)
Ok(())
}

fn split_and_insert(
Expand Down
27 changes: 0 additions & 27 deletions wezterm-gui/src/termwindow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3353,33 +3353,6 @@ impl TermWindow {
}
}

fn get_float_pane(&mut self) -> Option<Arc<dyn Pane>> {
let mux = Mux::get();
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
Some(tab) => tab,
None => return None,
};

let tab_id = tab.tab_id();

if self.tab_state(tab_id).overlay.is_some() {
None
} else {
self.get_float_pane()
}
}

fn get_float_pos(&mut self) -> Option<PositionedFloat> {
let mux = Mux::get();
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
Some(tab) => tab,
None => return None,
};

let float_pos = tab.get_float_pos();
Some(float_pos)
}

fn pos_pane_to_pane_info(pos: &PositionedPane) -> PaneInformation {
PaneInformation {
pane_id: pos.pane.pane_id(),
Expand Down
7 changes: 3 additions & 4 deletions wezterm-gui/src/termwindow/render/paint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ impl crate::TermWindow {
let float_layer = gl_state
.layer_for_zindex(2)
.context("layer_for_zindex(2)")?;
let mut float_layers = float_layer.quad_allocator();

log::trace!("quad map elapsed {:?}", start.elapsed());
metrics::histogram!("quad.map").record(start.elapsed());
Expand Down Expand Up @@ -264,10 +263,10 @@ impl crate::TermWindow {
}

if let Some(float_pane) = self.get_float_pane_to_render() {
float_pane.pane.advise_focus();
let mut float_layers = float_layer.quad_allocator();

self.paint_pane(&float_pane, &mut float_layers).context("paint_pane")?;
let float = self.get_float_pos();
self.paint_float_border(float.unwrap(), &mut layers).context("paint_float")?;
self.paint_float_border(float_pane, &mut float_layers).context("paint_float_border")?;
}

if let Some(pane) = self.get_active_pane_or_overlay() {
Expand Down
8 changes: 4 additions & 4 deletions wezterm-gui/src/termwindow/render/split.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::termwindow::render::TripleLayerQuadAllocator;
use crate::termwindow::{UIItem, UIItemType};
use mux::pane::Pane;
use mux::tab::{PositionedFloat, PositionedSplit, SplitDirection};
use mux::tab::{PositionedFloat, PositionedPane, PositionedSplit, SplitDirection};
use std::sync::Arc;

impl crate::TermWindow {
Expand Down Expand Up @@ -81,7 +81,7 @@ impl crate::TermWindow {

pub fn paint_float_border(
&mut self,
pos: PositionedFloat,
pos: PositionedPane,
layers: &mut TripleLayerQuadAllocator,
) -> anyhow::Result<()> {
let (padding_left, padding_top) = self.padding_left_top();
Expand All @@ -93,8 +93,8 @@ impl crate::TermWindow {
let half_cell_width = cell_width as f32 / 2.0;
let pos_y = (pos.top as f32 * self.render_metrics.cell_size.height as f32) - self.render_metrics.underline_height as f32 - half_cell_height + padding_top;
let pos_x = (pos.left as f32 * self.render_metrics.cell_size.width as f32) - self.render_metrics.underline_height as f32 - half_cell_width + padding_left;
let pixel_height = (pos.size.rows as f32 * cell_height as f32) + self.render_metrics.underline_height as f32 + cell_height as f32;
let pixel_width = (pos.size.cols as f32 * cell_width as f32) + self.render_metrics.underline_height as f32 + cell_width as f32;
let pixel_height = pos.pixel_height as f32 + self.render_metrics.underline_height as f32 + cell_height as f32;
let pixel_width = pos.pixel_width as f32 + self.render_metrics.underline_height as f32 + cell_width as f32;

self.filled_rectangle(
layers,
Expand Down

0 comments on commit 9bd3c95

Please sign in to comment.