From 8db88cceb758b5be23e7db1fe74a48102ab07dc0 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Tue, 28 Jul 2026 14:16:05 -0500 Subject: terminal: add visibility reports Applications cannot infer whether their terminal view is observable from keyboard focus alone, so they may continue expensive rendering while the surface is hidden. Implement private mode 2033 and the one-shot visibility query. Report Wayland xdg_toplevel suspension as not visible and otherwise remain conservative by treating the terminal as potentially visible. Amp-Thread-ID: https://ampcode.com/threads/T-019fb2b7-f245-7124-a69a-1484812532bb Co-authored-by: Amp --- terminal.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index 374d4371..3fa813a5 100644 --- a/terminal.c +++ b/terminal.c @@ -2110,6 +2110,7 @@ term_reset(struct terminal *term, bool hard) term->insert_mode = false; term->bracketed_paste = false; term->focus_events = false; + term->visibility_reports = false; term->num_lock_modifier = true; term->bell_action_enabled = true; term->mouse_tracking = MOUSE_NONE; @@ -3315,6 +3316,14 @@ term_visual_focus_out(struct terminal *term) render_refresh_csd(term); } +void +term_send_visibility_report(struct terminal *term) +{ + term_to_slave( + term, + !term->window->is_suspended ? "\033[?999;1n" : "\033[?999;2n", 9); +} + void term_kbd_focus_in(struct terminal *term) { -- cgit v1.3