diff --git a/kitty/boss.py b/kitty/boss.py index 9c18f162189..93fc5af1c7d 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -1998,6 +1998,8 @@ def on_drop(self, os_window_id: int, drop: dict[str, bytes] | int, from_self: bo if window.is_visible_in_layout: g = window.geometry if g.left <= x < g.right and g.top <= y < g.bottom: + if get_options().focus_follows_drop and window is not tab.active_window: + tab.set_active_window(window) window.on_drop(drop) break elif tab_bar.left <= x < tab_bar.right and tab_bar.top <= y < tab_bar.bottom: diff --git a/kitty/options/definition.py b/kitty/options/definition.py index 8898809c40f..61cbb274b71 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -866,6 +866,15 @@ ''' ) +opt('focus_follows_drop', 'no', + option_type='to_bool', + long_text=''' +When something is dropped onto a window, automatically focus that window. If +disabled (the default), the drop content is delivered to the target window but +keyboard focus remains on the previously active window. +''' + ) + opt('pointer_shape_when_grabbed', 'arrow', choices=pointer_shape_names, ctype='pointer_shape', long_text=''' diff --git a/kitty/options/types.py b/kitty/options/types.py index 10098147224..89221e4efb1 100644 --- a/kitty/options/types.py +++ b/kitty/options/types.py @@ -362,6 +362,7 @@ 'exe_search_path', 'file_transfer_confirmation_bypass', 'filter_notification', + 'focus_follows_drop', 'focus_follows_mouse', 'font_family', 'font_features', @@ -578,6 +579,7 @@ class Options: enable_audio_bell: bool = True enabled_layouts: list[str] = ['fat', 'grid', 'horizontal', 'splits', 'stack', 'tall', 'vertical'] file_transfer_confirmation_bypass: str = '' + focus_follows_drop: bool = False focus_follows_mouse: bool = False font_family: FontSpec = FontSpec(family=None, style=None, postscript_name=None, full_name=None, system='monospace', axes=(), variable_name=None, features=(), created_from_string='monospace') font_size: float = 11.0