diff --git a/docs/changelog.rst b/docs/changelog.rst index 86cd7f574..1539602cd 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -87,6 +87,8 @@ Detailed list of changes - broadcast kitten: Allow pressing a key to stop echoing of input into the broadcast window itself (:disc:`5868`) +- When reporting unused activity in a window, ignore activity that occurs soon after a window resize (:iss:`5881`) + 0.26.5 [2022-11-07] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/screen.c b/kitty/screen.c index 97d140faf..922b8df64 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -658,9 +658,13 @@ draw_combining_char(Screen *self, char_type ch) { static void draw_codepoint(Screen *self, char_type och, bool from_input_stream) { if (is_ignored_char(och)) return; - if (!self->has_activity_since_last_focus && !self->has_focus) { - self->has_activity_since_last_focus = true; - CALLBACK("on_activity_since_last_focus", NULL); + if (!self->has_activity_since_last_focus && !self->has_focus && self->callbacks != Py_None) { + PyObject *ret = PyObject_CallMethod(self->callbacks, "on_activity_since_last_focus", NULL); + if (ret == NULL) PyErr_Print(); + else { + if (ret == Py_True) self->has_activity_since_last_focus = true; + Py_DECREF(ret); + } } uint32_t ch = och < 256 ? self->g_charset[och] : och; if (UNLIKELY(is_combining_char(ch))) { diff --git a/kitty/window.py b/kitty/window.py index 911691476..b2f3ab29c 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -555,6 +555,7 @@ class Window: else: self.watchers = global_watchers().copy() self.last_focused_at = 0. + self.last_resized_at = 0. self.started_at = monotonic() self.current_remote_data: List[str] = [] self.current_mouse_event_button = 0 @@ -831,6 +832,7 @@ class Window: update_ime_position = False if current_pty_size != self.last_reported_pty_size: get_boss().child_monitor.resize_pty(self.id, *current_pty_size) + self.last_resized_at = monotonic() if not self.pty_resized_once: self.pty_resized_once = True self.child.mark_terminal_ready() @@ -1023,9 +1025,12 @@ class Window: def has_activity_since_last_focus(self) -> bool: return self.screen.has_activity_since_last_focus() - def on_activity_since_last_focus(self) -> None: - if get_options().tab_activity_symbol: + def on_activity_since_last_focus(self) -> bool: + if get_options().tab_activity_symbol and (monotonic() - self.last_resized_at) > 0.5: + # Ignore activity soon after a resize as the child program is probably redrawing the screen get_boss().on_activity_since_last_focus(self) + return True + return False def on_bell(self) -> None: cb = get_options().command_on_bell