From 900aab10f2c744f943d65942654c7e90fae28a34 Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Wed, 14 Aug 2024 22:43:58 -0400 Subject: [PATCH] renderer: don't update frame if renderer grid size != terminal size --- src/renderer/Metal.zig | 14 ++++++++------ src/renderer/OpenGL.zig | 13 +++++++++++++ src/renderer/Thread.zig | 2 ++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index 4f669d474..80ba787b2 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -908,12 +908,14 @@ pub fn updateFrame( } // If our terminal screen size doesn't match our expected renderer - // size then we skip a frame. This can happen if we get resized - // before the terminal gets resized. The terminal resize event also - // wakes up the renderer so we'll get another chance to update frame - // data. - if (self.cells.size.rows < state.terminal.rows or - self.cells.size.columns < state.terminal.cols) + // size then we skip a frame. This can happen if the terminal state + // is resized between when the renderer mailbox is drained and when + // the state mutex is acquired inside this function. + // + // For some reason this doesn't seem to cause any significant issues + // with flickering while resizing. '\_('-')_/' + if (self.cells.size.rows != state.terminal.rows or + self.cells.size.columns != state.terminal.cols) { return; } diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index a8d0198e2..498a1e967 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -739,6 +739,19 @@ pub fn updateFrame( self.foreground_color = bg; } + // If our terminal screen size doesn't match our expected renderer + // size then we skip a frame. This can happen if the terminal state + // is resized between when the renderer mailbox is drained and when + // the state mutex is acquired inside this function. + // + // For some reason this doesn't seem to cause any significant issues + // with flickering while resizing. '\_('-')_/' + if (self.grid_size.rows != state.terminal.rows or + self.grid_size.columns != state.terminal.cols) + { + return; + } + // Get the viewport pin so that we can compare it to the current. const viewport_pin = state.terminal.screen.pages.pin(.{ .viewport = .{} }).?; diff --git a/src/renderer/Thread.zig b/src/renderer/Thread.zig index 2725a2175..2521d18a4 100644 --- a/src/renderer/Thread.zig +++ b/src/renderer/Thread.zig @@ -522,6 +522,8 @@ fn renderCallback( t.flags.cursor_blink_visible, ) catch |err| log.warn("error rendering err={}", .{err}); + + // Draw t.drawFrame(false); return .disarm;