Track focus state and disable cursor blinking when not focused

Issue https://github.com/wez/wezterm/issues/93
This commit is contained in:
Jeremy Fitzhardinge authored and Wez Furlong committed 2019-12-29 16:58:15 -08:00
1 parent 71acd7d2a9
commit 0bc0972f75
1 file changed
+8 -1
+8 -1
View File
@@ -95,6 +95,7 @@ impl PrevCursorPos {
pub struct TermWindow {
window: Option<Window>,
focused: bool,
fonts: Rc<FontConfiguration>,
/// 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