diff options
author | Aram Drevekenin <aram@poor.dev> | 2023-03-01 12:25:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-01 12:25:44 +0100 |
commit | a8b5bce9d9e6c080f3c57735ef689a74eb2124e5 (patch) | |
tree | 0157bf5faf052d8860ce9010b1ab6a80fd3adc2b /zellij-server/src/tab | |
parent | d670c29649307ba575c71e267104f033f8600906 (diff) |
fix(sixel): report pixel size in winsize change ioctl (#2212)
* fix(sixel): report pixel size in winsize change ioctl
* style(fmt): rustfmt
Diffstat (limited to 'zellij-server/src/tab')
-rw-r--r-- | zellij-server/src/tab/layout_applier.rs | 20 | ||||
-rw-r--r-- | zellij-server/src/tab/mod.rs | 77 | ||||
-rw-r--r-- | zellij-server/src/tab/unit/tab_integration_tests.rs | 9 | ||||
-rw-r--r-- | zellij-server/src/tab/unit/tab_tests.rs | 9 |
4 files changed, 101 insertions, 14 deletions
diff --git a/zellij-server/src/tab/layout_applier.rs b/zellij-server/src/tab/layout_applier.rs index b2c3817bf..7964b6989 100644 --- a/zellij-server/src/tab/layout_applier.rs +++ b/zellij-server/src/tab/layout_applier.rs @@ -132,7 +132,7 @@ impl<'a> LayoutApplier<'a> { Some(position_and_size), ); pane_focuser.set_pane_id_in_focused_location(layout.focus, &pane); - resize_pty!(pane, self.os_api, self.senders)?; + resize_pty!(pane, self.os_api, self.senders, self.character_cell_size)?; self.tiled_panes .add_pane_with_existing_geom(pane.pid(), pane); } @@ -305,7 +305,12 @@ impl<'a> LayoutApplier<'a> { ); new_pane.set_borderless(false); new_pane.set_content_offset(Offset::frame(1)); - resize_pty!(new_pane, self.os_api, self.senders)?; + resize_pty!( + new_pane, + self.os_api, + self.senders, + self.character_cell_size + )?; self.floating_panes .add_pane(PaneId::Plugin(pid), Box::new(new_pane)); if floating_pane_layout.focus.unwrap_or(false) { @@ -340,7 +345,12 @@ impl<'a> LayoutApplier<'a> { if let Some(held_command) = hold_for_command { new_pane.hold(None, true, held_command.clone()); } - resize_pty!(new_pane, self.os_api, self.senders)?; + resize_pty!( + new_pane, + self.os_api, + self.senders, + self.character_cell_size + )?; self.floating_panes .add_pane(PaneId::Terminal(*pid), Box::new(new_pane)); if floating_pane_layout.focus.unwrap_or(false) { @@ -398,7 +408,7 @@ impl<'a> LayoutApplier<'a> { .focus .or(Some(!layout_has_focused_pane)); pane_focuser.set_pane_id_in_focused_location(pane_is_focused, &pane); - resize_pty!(pane, self.os_api, self.senders)?; + resize_pty!(pane, self.os_api, self.senders, self.character_cell_size)?; self.floating_panes.add_pane(pane.pid(), pane); } } @@ -415,7 +425,7 @@ impl<'a> LayoutApplier<'a> { ); pane_focuser .set_pane_id_in_focused_location(Some(!layout_has_focused_pane), &pane); - resize_pty!(pane, self.os_api, self.senders)?; + resize_pty!(pane, self.os_api, self.senders, self.character_cell_size)?; self.floating_panes.add_pane(pane.pid(), pane); } }, diff --git a/zellij-server/src/tab/mod.rs b/zellij-server/src/tab/mod.rs index bcd549ccc..7cdef9619 100644 --- a/zellij-server/src/tab/mod.rs +++ b/zellij-server/src/tab/mod.rs @@ -63,6 +63,42 @@ macro_rules! resize_pty { *pid, $pane.get_content_columns() as u16, $pane.get_content_rows() as u16, + None, + None, + ), + PaneId::Plugin(ref pid) => { + let err_context = || format!("failed to resize plugin {pid}"); + $senders + .send_to_plugin(PluginInstruction::Resize( + *pid, + $pane.get_content_columns(), + $pane.get_content_rows(), + )) + .with_context(err_context) + }, + } + }}; + ($pane:expr, $os_input:expr, $senders:expr, $character_cell_size:expr) => {{ + let (width_in_pixels, height_in_pixels) = { + let character_cell_size = $character_cell_size.borrow(); + match *character_cell_size { + Some(size_in_pixels) => { + let width_in_pixels = + (size_in_pixels.width * $pane.get_content_columns()) as u16; + let height_in_pixels = + (size_in_pixels.height * $pane.get_content_rows()) as u16; + (Some(width_in_pixels), Some(height_in_pixels)) + }, + None => (None, None), + } + }; + match $pane.pid() { + PaneId::Terminal(ref pid) => $os_input.set_terminal_size_using_terminal_id( + *pid, + $pane.get_content_columns() as u16, + $pane.get_content_rows() as u16, + width_in_pixels, + height_in_pixels, ), PaneId::Plugin(ref pid) => { let err_context = || format!("failed to resize plugin {pid}"); @@ -490,6 +526,7 @@ impl Tab { connected_clients.clone(), connected_clients_in_app, mode_info.clone(), + character_cell_size.clone(), session_is_mirrored, default_mode_info.clone(), style, @@ -900,8 +937,13 @@ impl Tab { embedded_pane_to_float.set_content_offset(Offset::frame(1)); } embedded_pane_to_float.set_geom(new_pane_geom); - resize_pty!(embedded_pane_to_float, self.os_api, self.senders) - .with_context(err_context)?; + resize_pty!( + embedded_pane_to_float, + self.os_api, + self.senders, + self.character_cell_size + ) + .with_context(err_context)?; embedded_pane_to_float.set_active_at(Instant::now()); self.floating_panes .add_pane(focused_pane_id, embedded_pane_to_float); @@ -1001,7 +1043,13 @@ impl Tab { ); new_pane.set_active_at(Instant::now()); new_pane.set_content_offset(Offset::frame(1)); // floating panes always have a frame - resize_pty!(new_pane, self.os_api, self.senders).with_context(err_context)?; + resize_pty!( + new_pane, + self.os_api, + self.senders, + self.character_cell_size + ) + .with_context(err_context)?; self.floating_panes.add_pane(pid, Box::new(new_pane)); self.floating_panes.focus_pane_for_all_clients(pid); } @@ -1101,7 +1149,12 @@ impl Tab { self.get_active_pane(client_id) .with_context(|| format!("no active pane found for client {client_id}")) .and_then(|current_active_pane| { - resize_pty!(current_active_pane, self.os_api, self.senders) + resize_pty!( + current_active_pane, + self.os_api, + self.senders, + self.character_cell_size + ) }) .with_context(err_context)?; }, @@ -1375,8 +1428,13 @@ impl Tab { }) { if self.pids_waiting_resize.remove(&pid) { - resize_pty!(terminal_output, self.os_api, self.senders) - .with_context(err_context)?; + resize_pty!( + terminal_output, + self.os_api, + self.senders, + self.character_cell_size + ) + .with_context(err_context)?; } terminal_output.handle_pty_bytes(bytes); let messages_to_pty = terminal_output.drain_messages_to_pty(); @@ -2212,7 +2270,12 @@ impl Tab { // the pane there we replaced. Now, we need to update its pty about its new size. // We couldn't do that before, and we can't use the original moved item now - so we // need to refetch it - resize_pty!(suppressed_pane, self.os_api, self.senders)?; + resize_pty!( + suppressed_pane, + self.os_api, + self.senders, + self.character_cell_size + )?; } Ok(replaced_pane) }) diff --git a/zellij-server/src/tab/unit/tab_integration_tests.rs b/zellij-server/src/tab/unit/tab_integration_tests.rs index 11de1c298..1652eb5ae 100644 --- a/zellij-server/src/tab/unit/tab_integration_tests.rs +++ b/zellij-server/src/tab/unit/tab_integration_tests.rs @@ -48,7 +48,14 @@ struct FakeInputOutput { } impl ServerOsApi for FakeInputOutput { - fn set_terminal_size_using_terminal_id(&self, _id: u32, _cols: u16, _rows: u16) -> Result<()> { + fn set_terminal_size_using_terminal_id( + &self, + _id: u32, + _cols: u16, + _rows: u16, + _width_in_pixels: Option<u16>, + _height_in_pixels: Option<u16>, + ) -> Result<()> { // noop Ok(()) } diff --git a/zellij-server/src/tab/unit/tab_tests.rs b/zellij-server/src/tab/unit/tab_tests.rs index 8fbf66492..cb3d8f787 100644 --- a/zellij-server/src/tab/unit/tab_tests.rs +++ b/zellij-server/src/tab/unit/tab_tests.rs @@ -30,7 +30,14 @@ use zellij_utils::{ struct FakeInputOutput {} impl ServerOsApi for FakeInputOutput { - fn set_terminal_size_using_terminal_id(&self, _id: u32, _cols: u16, _rows: u16) -> Result<()> { + fn set_terminal_size_using_terminal_id( + &self, + _id: u32, + _cols: u16, + _rows: u16, + _width_in_pixels: Option<u16>, + _height_in_pixels: Option<u16>, + ) -> Result<()> { // noop Ok(()) } |