When reporting unused activity in a window, ignore activity that occurs soon after a window resize

Fixes #5881
This commit is contained in:
Kovid Goyal 2023-01-15 09:09:07 +05:30
parent 45b0788f28
commit 865fc24975
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 16 additions and 5 deletions

View File

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

View File

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

View File

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