csi: implement private mode 2031 (dark/light mode detection)

* Recognize 'CSI ? 996 n', and respond with
  - 'CSI ? 997 ; 1 n' if the primary theme is active
  - 'CSI ? 997 ; 2 n' if the alternative theme is actice
* Implement private mode 2031, where changing the color
  theme (currently only possible via key bindings) causes the terminal
  to send the same CSI sequences as above.

In this context, foot's primary theme is considered dark, and the
alternative theme light (since the default theme is dark).

Closes #2025
This commit is contained in:
Daniel Eklöf 2025-04-20 12:48:37 +02:00
parent 6bc91b5e28
commit 10e7f29149
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 70 additions and 0 deletions

12
input.c
View file

@ -492,6 +492,9 @@ execute_binding(struct seat *seat, struct terminal *term,
wayl_win_alpha_changed(term->window);
term_font_subpixel_changed(term);
if (term->report_theme_changes)
term_to_slave(term, "\033[?997;1n", 9);
term_damage_view(term);
term_damage_margins(term);
render_refresh(term);
@ -506,6 +509,9 @@ execute_binding(struct seat *seat, struct terminal *term,
wayl_win_alpha_changed(term->window);
term_font_subpixel_changed(term);
if (term->report_theme_changes)
term_to_slave(term, "\033[?997;2n", 9);
term_damage_view(term);
term_damage_margins(term);
render_refresh(term);
@ -516,9 +522,15 @@ execute_binding(struct seat *seat, struct terminal *term,
if (term->colors.active_theme == COLOR_THEME1) {
term_theme_apply(term, &term->conf->colors2);
term->colors.active_theme = COLOR_THEME2;
if (term->report_theme_changes)
term_to_slave(term, "\033[?997;2n", 9);
} else {
term_theme_apply(term, &term->conf->colors);
term->colors.active_theme = COLOR_THEME1;
if (term->report_theme_changes)
term_to_slave(term, "\033[?997;1n", 9);
}
wayl_win_alpha_changed(term->window);