Slightly refactor resolution check

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion 2024-08-05 18:33:22 +02:00
parent 5e85618730
commit 4e40e32f59
No known key found for this signature in database
GPG Key ID: 3E85EB44F610AD7F
1 changed files with 4 additions and 10 deletions

View File

@ -347,18 +347,11 @@ pub fn main() !void {
const width: usize = @intCast(termbox.tb_width());
const height: usize = @intCast(termbox.tb_height());
if (width != buffer.width) {
if (width != buffer.width or height != buffer.height) {
// If it did change, then update the cell buffer, reallocate the current animation's buffers, and force a draw update
buffer.width = width;
resolution_changed = true;
}
if (height != buffer.height) {
buffer.height = height;
resolution_changed = true;
}
// If it did change, then update the cell buffer, reallocate the current animation's buffers, and force a draw update
if (resolution_changed) {
buffer.buffer = termbox.tb_cell_buffer();
switch (config.animation) {
@ -372,6 +365,7 @@ pub fn main() !void {
}
update = true;
resolution_changed = true;
}
}