Turn off focus tracking while doing tty remote control

Fixes #8733
This commit is contained in:
Kovid Goyal 2025-06-16 21:57:19 +05:30
parent 8b395759e2
commit 4a13c53438
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
4 changed files with 17 additions and 3 deletions

View file

@ -30,8 +30,8 @@ func do_chunked_io(io_data *rc_io_data) (serialized_response []byte, err error)
// we cant do inbandresize notification as in the --no-response case the
// command can cause a resize and the loop can quit before the notification
// arrives, leading to the notification being sent to whatever is executed
// after us.
lp, err := loop.New(loop.NoAlternateScreen, loop.NoRestoreColors, loop.NoInBandResizeNotifications)
// after us. Similarly no focus tracking.
lp, err := loop.New(loop.NoAlternateScreen, loop.NoRestoreColors, loop.NoInBandResizeNotifications, loop.NoFocusTracking)
if io_data.on_key_event != nil {
lp.FullKeyboardProtocol()
} else {

View file

@ -209,6 +209,15 @@ func NoRestoreColors(self *Loop) {
self.terminal_options.restore_colors = false
}
func (self *Loop) NoFocusTracking() *Loop {
self.terminal_options.focus_tracking = false
return self
}
func NoFocusTracking(self *Loop) {
self.terminal_options.focus_tracking = false
}
func (self *Loop) ColorSchemeChangeNotifications() *Loop {
self.terminal_options.color_scheme_change_notification = true
return self

View file

@ -26,6 +26,7 @@ func new_loop() *Loop {
l := Loop{controlling_term: nil}
l.terminal_options.Alternate_screen = true
l.terminal_options.restore_colors = true
l.terminal_options.focus_tracking = true
l.terminal_options.in_band_resize_notification = true
l.terminal_options.color_scheme_change_notification = false
l.terminal_options.kitty_keyboard_mode = DISAMBIGUATE_KEYS | REPORT_ALTERNATE_KEYS | REPORT_ALL_KEYS_AS_ESCAPE_CODES | REPORT_TEXT_WITH_KEYS

View file

@ -102,6 +102,7 @@ type TerminalStateOptions struct {
mouse_tracking MouseTracking
kitty_keyboard_mode KeyboardStateBits
in_band_resize_notification bool
focus_tracking bool
color_scheme_change_notification bool
}
@ -131,7 +132,10 @@ func (self *TerminalStateOptions) SetStateEscapeCodes() string {
reset_modes(&sb,
IRM, DECKM, DECSCNM, BRACKETED_PASTE,
MOUSE_BUTTON_TRACKING, MOUSE_MOTION_TRACKING, MOUSE_MOVE_TRACKING, MOUSE_UTF8_MODE, MOUSE_SGR_MODE)
set_modes(&sb, DECARM, DECAWM, DECTCEM, FOCUS_TRACKING)
set_modes(&sb, DECARM, DECAWM, DECTCEM)
if self.focus_tracking {
set_modes(&sb, FOCUS_TRACKING)
}
if self.in_band_resize_notification {
set_modes(&sb, INBAND_RESIZE_NOTIFICATION)
}