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 <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Tim Culverhouse 2022-09-25 14:24:55 -05:00 committed by Robin Jarry
parent da10dae86e
commit c4a9f3f8a0
1 changed files with 3 additions and 0 deletions

View File

@ -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