Add draggable window title bars

Implements drag-to-reorder for window title bars, following up on the
merged window title bar feature (#9450) and the design discussion in #9619.

- Drag a title bar and drop on another title bar to swap positions
- Drop on a window body quadrant (left/right/top/bottom) to insert as
  a directional split; Splits layout uses insert_window_next_to(), other
  layouts fall back to move_window_to_group()
- Drop on a tab bar tab to move the window into that tab
- Drop on another OS window to move into its active tab
- Drop outside kitty to detach into a new OS window
- Tab bar highlights the hovered tab during a window drag, mirroring
  how the destination window title bar is highlighted
- toggle_window_title_bars action temporarily force-shows title bars
  for drag-to-reorder when they are normally hidden, auto-hiding after
  the drag completes
- window_title_bar_drag_threshold option (default 5px) controls how far
  the mouse must move before a drag is initiated; 0 disables dragging

MIME type follows the same convention as tab dragging:
application/net.kovidgoyal.kitty-window-{PID}

Ref: #9619
This commit is contained in:
mcrmck
2026-03-08 20:56:38 -04:00
parent db5453c291
commit 59c963c481
15 changed files with 391 additions and 29 deletions

View File

@@ -1550,6 +1550,16 @@ opt('window_title_bar_align', 'center',
choices=('left', 'center', 'right'),
long_text='Horizontal alignment of the text in window title bars.'
)
opt('window_title_bar_drag_threshold', '5',
option_type='positive_int',
long_text='''
Pixel distance the mouse must move before a window title bar drag begins.
Zero disables dragging. Drop on a title bar swaps positions; drop on a
window body inserts in the quadrant direction (left/right/top/bottom).
Drop on the tab bar moves the window to that tab; drop outside kitty
detaches it to a new OS window.
''')
egr() # }}}

View File

@@ -1529,6 +1529,9 @@ class Parser:
choices_for_window_title_bar_align = choices_for_tab_bar_align
def window_title_bar_drag_threshold(self, val: str, ans: dict[str, typing.Any]) -> None:
ans['window_title_bar_drag_threshold'] = positive_int(val)
def window_title_bar_inactive_background(self, val: str, ans: dict[str, typing.Any]) -> None:
ans['window_title_bar_inactive_background'] = to_color_or_none(val)

View File

@@ -504,6 +504,7 @@ option_names = (
'window_title_bar_active_background',
'window_title_bar_active_foreground',
'window_title_bar_align',
'window_title_bar_drag_threshold',
'window_title_bar_inactive_background',
'window_title_bar_inactive_foreground',
'window_title_bar_min_windows',
@@ -705,6 +706,7 @@ class Options:
window_title_bar_active_background: kitty.fast_data_types.Color | None = None
window_title_bar_active_foreground: kitty.fast_data_types.Color | None = None
window_title_bar_align: choices_for_window_title_bar_align = 'center'
window_title_bar_drag_threshold: int = 5
window_title_bar_inactive_background: kitty.fast_data_types.Color | None = None
window_title_bar_inactive_foreground: kitty.fast_data_types.Color | None = None
window_title_bar_min_windows: int = 0