diff --git a/kitty/screen.c b/kitty/screen.c index de40a8a68..d10bb0dc6 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -1525,8 +1525,8 @@ write_escape_code_to_child(Screen *self, unsigned char which, const char *data) } static void -send_visibility_report(Screen *self, bool potentially_visible) { - write_escape_code_to_child(self, ESC_CSI, potentially_visible ? "?999;1n" : "?999;2n"); +send_visibility_report(Screen *self) { + write_escape_code_to_child(self, ESC_CSI, self->visibility_state != 2 ? "?999;1n" : "?999;2n"); } void @@ -1534,17 +1534,10 @@ screen_visibility_changed(Screen *self, bool potentially_visible) { const uint8_t state = potentially_visible ? 1 : 2; if (self->visibility_state != state) { self->visibility_state = state; - if (self->modes.mVISIBILITY_REPORTS) send_visibility_report(self, potentially_visible); + if (self->modes.mVISIBILITY_REPORTS) send_visibility_report(self); } } -static void -report_current_visibility(Screen *self) { - const bool potentially_visible = is_kitty_window_visible(self->window_id); - self->visibility_state = potentially_visible ? 1 : 2; - send_visibility_report(self, potentially_visible); -} - static bool write_escape_code_to_child_python(Screen *self, unsigned char which, PyObject *data) { bool written = false; @@ -1822,7 +1815,7 @@ set_mode_from_const(Screen *self, unsigned int mode, bool val) { break; case VISIBILITY_REPORTS: self->modes.mVISIBILITY_REPORTS = val; - if (val) report_current_visibility(self); + if (val) send_visibility_report(self); break; default: private = mode >= 1 << 5; @@ -2965,7 +2958,7 @@ report_device_status(Screen *self, unsigned int which, bool private) { CALLBACK("report_color_scheme_preference", NULL); } break; case 998: // https://rockorager.dev/misc/visibility-reports/ - if (private) report_current_visibility(self); + if (private) send_visibility_report(self); break; } } diff --git a/kitty/state.c b/kitty/state.c index 9f024061f..56e08965a 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -165,25 +165,6 @@ window_for_window_id(id_type kitty_window_id) { return NULL; } -bool -is_kitty_window_visible(id_type kitty_window_id) { - for (size_t i = 0; i < global_state.num_os_windows; i++) { - OSWindow *os_window = global_state.os_windows + i; - for (size_t t = 0; t < os_window->num_tabs; t++) { - Tab *tab = os_window->tabs + t; - for (size_t w = 0; w < tab->num_windows; w++) { - Window *window = tab->windows + w; - if (window->id == kitty_window_id) { - return is_os_window_potentially_visible(os_window) && t == os_window->active_tab && window->visible; - } - } - } - } - // If the view cannot be found, its visibility is unknown and must be - // treated conservatively as potentially visible. - return true; -} - void update_os_window_visibility_reports(OSWindow *os_window) { const bool os_window_is_visible = is_os_window_potentially_visible(os_window); diff --git a/kitty/state.h b/kitty/state.h index 246e84ffc..77a15990c 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -567,7 +567,6 @@ void mark_os_window_for_close(OSWindow* w, CloseRequest cr); void update_os_window_viewport(OSWindow *window, bool notify_boss); bool should_os_window_be_rendered(OSWindow* w); bool is_os_window_potentially_visible(OSWindow* w); -bool is_kitty_window_visible(id_type kitty_window_id); void update_os_window_visibility_reports(OSWindow *w); void wakeup_main_loop(void); bool make_window_context_current(id_type);