From 3fbf0fecbb4daa3f31b06de5b361a83f1d5e1c9c Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 26 Dec 2024 21:57:41 +0100 Subject: [PATCH] graphics/console-draw: Fix resizing to a smaller display Without this commit ransid would generate move events with an underflowed height which take forever to process. --- graphics/console-draw/src/lib.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/graphics/console-draw/src/lib.rs b/graphics/console-draw/src/lib.rs index d52e46c57f..9c94ee934c 100644 --- a/graphics/console-draw/src/lib.rs +++ b/graphics/console-draw/src/lib.rs @@ -124,9 +124,13 @@ impl TextScreen { buf: &[u8], input: &mut VecDeque, ) -> Vec { - self.console.state.w = map.width / 8; - self.console.state.h = map.height / 16; - self.console.state.bottom_margin = (map.height / 16).saturating_sub(1); + self.console.resize(map.width / 8, map.height / 16); + if self.console.state.x > self.console.state.w { + self.console.state.x = self.console.state.w; + } + if self.console.state.y > self.console.state.h { + self.console.state.y = self.console.state.h; + } if self.console.state.cursor && self.console.state.x < self.console.state.w