From 0bc0972f753c995174c78bd25bcbf765c036e252 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Sat, 28 Dec 2019 22:52:30 -0800 Subject: [PATCH] Track focus state and disable cursor blinking when not focused Issue https://github.com/wez/wezterm/issues/93 --- src/frontend/gui/termwindow.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/frontend/gui/termwindow.rs b/src/frontend/gui/termwindow.rs index e4dd3b077..a62e7bc12 100644 --- a/src/frontend/gui/termwindow.rs +++ b/src/frontend/gui/termwindow.rs @@ -95,6 +95,7 @@ impl PrevCursorPos { pub struct TermWindow { window: Option, + focused: bool, fonts: Rc, /// Window dimensions and dpi dimensions: Dimensions, @@ -179,6 +180,11 @@ impl WindowCallbacks for TermWindow { self } + fn focus_change(&mut self, focused: bool) { + log::debug!("Setting focus to {:?}", focused); + self.focused = focused; + } + fn mouse_event(&mut self, event: &MouseEvent, context: &dyn WindowOps) { use ::term::input::MouseButton as TMB; use ::term::input::MouseEventKind as TMEK; @@ -612,6 +618,7 @@ impl TermWindow { dimensions.pixel_height, Box::new(Self { window: None, + focused: false, mux_window_id, fonts: Rc::clone(fontconfig), render_metrics, @@ -2111,7 +2118,7 @@ impl TermWindow { // depending on the current time. let config = configuration(); let shape = config.default_cursor_style.effective_shape(cursor.shape); - if shape.is_blinking() { + if shape.is_blinking() && self.focused { if config.cursor_blink_rate == 0 { // The user disabled blinking for their cursor shape