From 0ecbc2b786db99d23ac36b5b7e1965cc1f78dc00 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 16 Jan 2025 20:30:09 +0530 Subject: [PATCH] Only log an error about modifyOtherKeys if the application attempts to turn it on without first turning on the kitty keyboard protocol --- kitty/screen.c | 10 ++++++++++ kitty/screen.h | 1 + kitty/vt-parser.c | 6 +----- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/kitty/screen.c b/kitty/screen.c index d93e8427d..784791fe7 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -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; ) { diff --git a/kitty/screen.h b/kitty/screen.h index 06e5fa56f..ff3db26b5 100644 --- a/kitty/screen.h +++ b/kitty/screen.h @@ -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 *); diff --git a/kitty/vt-parser.c b/kitty/vt-parser.c index f35565f45..78bc86470 100644 --- a/kitty/vt-parser.c +++ b/kitty/vt-parser.c @@ -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 */