From c44fa7659f0deed4fd80ba655882f74729ccb0df Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 30 May 2020 12:29:04 -0700 Subject: [PATCH] wezterm: avoid repaint for blinking cursor when not focused This takes CPU usage down to 0 when the window isn't focused. refs: https://github.com/wez/wezterm/issues/200 --- src/frontend/gui/termwindow.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontend/gui/termwindow.rs b/src/frontend/gui/termwindow.rs index b4fdc2e9e..2a11e9cc6 100644 --- a/src/frontend/gui/termwindow.rs +++ b/src/frontend/gui/termwindow.rs @@ -616,12 +616,12 @@ impl TermWindow { // If blinking is permitted, and the cursor shape is set // to a blinking variant, and it's been longer than the - // blink rate interval, then invalid the lines in the terminal + // blink rate interval, then invalidate and redraw // so that we will re-evaluate the cursor visibility. // This is pretty heavyweight: it would be nice to only invalidate // the line on which the cursor resides, and then only if the cursor // is within the viewport. - if config.cursor_blink_rate != 0 { + if config.cursor_blink_rate != 0 && myself.focused.is_some() { let shape = config .default_cursor_style .effective_shape(render.get_cursor_position().shape);