Only log an error about modifyOtherKeys if the application attempts to turn it on without first turning on the kitty keyboard protocol

This commit is contained in:
Kovid Goyal 2025-01-16 20:30:09 +05:30
parent 0ffaaff8a7
commit 0ecbc2b786
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 12 additions and 5 deletions

View file

@ -1207,6 +1207,16 @@ screen_reset_mode(Screen *self, unsigned int mode) {
set_mode_from_const(self, mode, false);
}
void
screen_modify_other_keys(Screen *self, unsigned int val) {
// Only report an error about modifyOtherKeys if the kitty keyboard
// protocol is not in effect and the application is trying to turn it on. There are some applications that try to enable both.
debug_input("modifyOtherKeys: %u\n", val);
if (!screen_current_key_encoding_flags(self) && val) {
log_error("The application is trying to use xterm's modifyOtherKeys. This is superseded by the kitty keyboard protocol https://sw.kovidgoyal.net/kitty/keyboard-protocol. The application should be updated to use that.");
}
}
uint8_t
screen_current_key_encoding_flags(Screen *self) {
for (unsigned i = arraysz(self->main_key_encoding_flags); i-- > 0; ) {

View file

@ -277,6 +277,7 @@ void screen_set_key_encoding_flags(Screen *self, uint32_t val, uint32_t how);
void screen_push_key_encoding_flags(Screen *self, uint32_t val);
void screen_pop_key_encoding_flags(Screen *self, uint32_t num);
uint8_t screen_current_key_encoding_flags(Screen *self);
void screen_modify_other_keys(Screen *self, unsigned int);
void screen_report_key_encoding_flags(Screen *self);
int screen_detect_url(Screen *screen, unsigned int x, unsigned int y);
int screen_cursor_at_a_shell_prompt(const Screen *);

View file

@ -1299,11 +1299,7 @@ dispatch_csi(PS *self) {
break;
}
if (start_modifier == '>' && !end_modifier) {
REPORT_ERROR(
"The application is trying to use xterm's modifyOtherKeys."
" This is superseded by the kitty keyboard protocol: https://sw.kovidgoyal.net/kitty/keyboard-protocol/"
" the application should be updated to use that"
);
CALL_CSI_HANDLER1(screen_modify_other_keys, 0);
break;
}
/* fallthrough */