From c4a9f3f8a0b8a78410489f4bae032402d713c9a0 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Sun, 25 Sep 2022 14:24:55 -0500 Subject: [PATCH] terminal: prevent draw loop when unfocused If a :term is open and aerc is focused on another tab, it is possible for the :term to redraw itself to the screen. Only allow terminal to redraw itself when it is focused. Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- widgets/terminal.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/widgets/terminal.go b/widgets/terminal.go index 279c2a3..5c67e32 100644 --- a/widgets/terminal.go +++ b/widgets/terminal.go @@ -178,6 +178,9 @@ func (term *Terminal) HandleEvent(ev tcell.Event) bool { } switch ev := ev.(type) { case *views.EventWidgetContent: + if !term.focus { + return false + } // Draw here for performance improvement. We call draw again in // the main Draw, but tcell-term only draws dirty cells, so it // won't be too much extra CPU there. Drawing there is needed