mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-17 05:32:41 +00:00
Skip the activity callback when tab_activity_symbol is not set
This commit is contained in:
parent
33bd696c72
commit
4e7dade0ab
5 changed files with 19 additions and 1 deletions
|
|
@ -1077,6 +1077,7 @@ class Screen:
|
|||
cursor_key_mode: bool
|
||||
auto_repeat_enabled: bool
|
||||
render_unfocused_cursor: bool
|
||||
track_activity: bool
|
||||
last_reported_cwd: Optional[bytes]
|
||||
|
||||
def __init__(
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ new_screen_object(PyTypeObject *type, PyObject *args, PyObject UNUSED *kwds) {
|
|||
reset_vt_parser(self->vt_parser);
|
||||
self->callbacks = callbacks;
|
||||
Py_INCREF(callbacks);
|
||||
self->track_activity = true;
|
||||
self->test_child = test_child;
|
||||
Py_INCREF(test_child);
|
||||
self->cursor = alloc_cursor();
|
||||
|
|
@ -1241,7 +1242,7 @@ draw_combining_char(Screen *self, text_loop_state *s, char_type ch) {
|
|||
|
||||
static void
|
||||
screen_on_input(Screen *self) {
|
||||
if (!self->has_activity_since_last_focus && !self->has_focus && self->callbacks != Py_None) {
|
||||
if (self->track_activity && !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 {
|
||||
|
|
@ -7235,6 +7236,7 @@ static PyGetSetDef getsetters[] = {
|
|||
|
||||
static PyMemberDef members[] = {
|
||||
{"callbacks", T_OBJECT_EX, offsetof(Screen, callbacks), 0, "callbacks"},
|
||||
{"track_activity", T_BOOL, offsetof(Screen, track_activity), 0, "track_activity"},
|
||||
{"cursor", T_OBJECT_EX, offsetof(Screen, cursor), READONLY, "cursor"},
|
||||
{"vt_parser", T_OBJECT_EX, offsetof(Screen, vt_parser), READONLY, "vt_parser"},
|
||||
{"last_reported_cwd", T_OBJECT, offsetof(Screen, last_reported_cwd), READONLY, "last_reported_cwd"},
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ typedef struct {
|
|||
bool has_focus;
|
||||
uint8_t visibility_state; // 0 = unknown, 1 = potentially visible, 2 = not visible
|
||||
bool has_activity_since_last_focus;
|
||||
bool track_activity;
|
||||
hyperlink_id_type active_hyperlink_id;
|
||||
HYPERLINK_POOL_HANDLE hyperlink_pool;
|
||||
ANSIBuf as_ansi_buf;
|
||||
|
|
|
|||
|
|
@ -812,6 +812,7 @@ class Window:
|
|||
cell_width, cell_height = cell_size_for_window(self.os_window_id)
|
||||
opts = get_options()
|
||||
self.screen: Screen = Screen(self, 24, 80, opts.scrollback_lines, cell_width, cell_height, self.id)
|
||||
self.screen.track_activity = bool(opts.tab_activity_symbol)
|
||||
if copy_colors_from is not None:
|
||||
self.screen.copy_colors_from(copy_colors_from.screen)
|
||||
self.remote_control_passwords = remote_control_passwords
|
||||
|
|
@ -901,6 +902,7 @@ class Window:
|
|||
|
||||
def apply_options(self, is_active: bool) -> None:
|
||||
self.update_effective_padding()
|
||||
self.screen.track_activity = bool(get_options().tab_activity_symbol)
|
||||
self.screen.color_profile.reload_from_opts()
|
||||
|
||||
@property
|
||||
|
|
|
|||
|
|
@ -2259,6 +2259,18 @@ class TestScreen(BaseTest):
|
|||
sc(2, 1, 2, 3, slot=slot)
|
||||
sc(5, 13, slot=slot)
|
||||
|
||||
def test_activity_tracking(self):
|
||||
s = self.create_screen()
|
||||
calls = []
|
||||
s.callbacks.on_activity_since_last_focus = lambda: calls.append(1) or False
|
||||
s.focus_changed(False)
|
||||
s.track_activity = False
|
||||
parse_bytes(s, b'\x1b[31ma\x1b[mb')
|
||||
self.ae(len(calls), 0)
|
||||
s.track_activity = True
|
||||
parse_bytes(s, b'\x1b[31ma\x1b[mb')
|
||||
self.ae(len(calls), 2)
|
||||
|
||||
def test_soft_reset(self):
|
||||
SOFT_RESET = b'\x1b[!p' # DECSTR sequence
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue