aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-server/src/tab
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2023-07-12 20:30:41 +0200
committerGitHub <noreply@github.com>2023-07-12 20:30:41 +0200
commit0825cb65a79c03a473b87bfbab82ffdb2aef9fea (patch)
treeddaf7e817012f8f60941e42b4cf1f326316a1f37 /zellij-server/src/tab
parentdocs(changelog): status-bar supermode (diff)
downloadsl0ppij-0825cb65a79c03a473b87bfbab82ffdb2aef9fea.tar.gz
sl0ppij-0825cb65a79c03a473b87bfbab82ffdb2aef9fea.tar.xz
sl0ppij-0825cb65a79c03a473b87bfbab82ffdb2aef9fea.zip
fix(rendering): occasional glitches while resizing (#2621)
Diffstat (limited to 'zellij-server/src/tab')
-rw-r--r--zellij-server/src/tab/mod.rs59
-rw-r--r--zellij-server/src/tab/unit/tab_integration_tests.rs1
2 files changed, 34 insertions, 26 deletions
diff --git a/zellij-server/src/tab/mod.rs b/zellij-server/src/tab/mod.rs
index d3a26b40..ed82d617 100644
--- a/zellij-server/src/tab/mod.rs
+++ b/zellij-server/src/tab/mod.rs
@@ -59,13 +59,17 @@ use zellij_utils::{
macro_rules! resize_pty {
($pane:expr, $os_input:expr, $senders:expr) => {{
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,
- None,
- None,
- ),
+ PaneId::Terminal(ref pid) => {
+ $senders
+ .send_to_pty_writer(PtyWriteInstruction::ResizePty(
+ *pid,
+ $pane.get_content_columns() as u16,
+ $pane.get_content_rows() as u16,
+ None,
+ None,
+ ))
+ .with_context(err_context);
+ },
PaneId::Plugin(ref pid) => {
let err_context = || format!("failed to resize plugin {pid}");
$senders
@@ -93,13 +97,19 @@ macro_rules! resize_pty {
}
};
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::Terminal(ref pid) => {
+ use crate::PtyWriteInstruction;
+ let err_context = || format!("Failed to send resize pty instruction");
+ $senders
+ .send_to_pty_writer(PtyWriteInstruction::ResizePty(
+ *pid,
+ $pane.get_content_columns() as u16,
+ $pane.get_content_rows() as u16,
+ width_in_pixels,
+ height_in_pixels,
+ ))
+ .with_context(err_context)
+ },
PaneId::Plugin(ref pid) => {
let err_context = || format!("failed to resize plugin {pid}");
$senders
@@ -758,16 +768,15 @@ impl Tab {
Ok(())
}
pub fn previous_swap_layout(&mut self, client_id: Option<ClientId>) -> Result<()> {
- // warning, here we cache resizes rather than sending them to the pty, we do that in
- // apply_cached_resizes below - beware when bailing on this function early!
- self.os_api.cache_resizes();
let search_backwards = true;
if self.floating_panes.panes_are_visible() {
self.relayout_floating_panes(client_id, search_backwards, true)?;
} else {
self.relayout_tiled_panes(client_id, search_backwards, true, false)?;
}
- self.os_api.apply_cached_resizes();
+ self.senders
+ .send_to_pty_writer(PtyWriteInstruction::ApplyCachedResizes)
+ .with_context(|| format!("failed to update plugins with mode info"))?;
Ok(())
}
pub fn next_swap_layout(
@@ -775,16 +784,15 @@ impl Tab {
client_id: Option<ClientId>,
refocus_pane: bool,
) -> Result<()> {
- // warning, here we cache resizes rather than sending them to the pty, we do that in
- // apply_cached_resizes below - beware when bailing on this function early!
- self.os_api.cache_resizes();
let search_backwards = false;
if self.floating_panes.panes_are_visible() {
self.relayout_floating_panes(client_id, search_backwards, refocus_pane)?;
} else {
self.relayout_tiled_panes(client_id, search_backwards, refocus_pane, false)?;
}
- self.os_api.apply_cached_resizes();
+ self.senders
+ .send_to_pty_writer(PtyWriteInstruction::ApplyCachedResizes)
+ .with_context(|| format!("failed to update plugins with mode info"))?;
Ok(())
}
pub fn apply_buffered_instructions(&mut self) -> Result<()> {
@@ -1807,9 +1815,6 @@ impl Tab {
selectable_tiled_panes.count() > 0
}
pub fn resize_whole_tab(&mut self, new_screen_size: Size) -> Result<()> {
- // warning, here we cache resizes rather than sending them to the pty, we do that in
- // apply_cached_resizes below - beware when bailing on this function early!
- self.os_api.cache_resizes();
let err_context = || format!("failed to resize whole tab (index {})", self.index);
self.floating_panes.resize(new_screen_size);
// we need to do this explicitly because floating_panes.resize does not do this
@@ -1829,7 +1834,9 @@ impl Tab {
let _ = self.relayout_tiled_panes(None, false, false, true);
}
self.should_clear_display_before_rendering = true;
- let _ = self.os_api.apply_cached_resizes();
+ self.senders
+ .send_to_pty_writer(PtyWriteInstruction::ApplyCachedResizes)
+ .with_context(|| format!("failed to update plugins with mode info"))?;
Ok(())
}
pub fn resize(&mut self, client_id: ClientId, strategy: ResizeStrategy) -> Result<()> {
diff --git a/zellij-server/src/tab/unit/tab_integration_tests.rs b/zellij-server/src/tab/unit/tab_integration_tests.rs
index c870c3a0..5a04d9c1 100644
--- a/zellij-server/src/tab/unit/tab_integration_tests.rs
+++ b/zellij-server/src/tab/unit/tab_integration_tests.rs
@@ -175,6 +175,7 @@ impl MockPtyInstructionBus {
.unwrap()
.push(String::from_utf8_lossy(&msg).to_string()),
PtyWriteInstruction::Exit => break,
+ _ => {},
}
}
})