Add mouse-based tab drag functionality for reordering and detachment #9296
+559
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This pull request implements mouse-based tab dragging functionality, enabling users to reorder tabs by dragging them within the tab bar and to detach tabs into new OS windows by dragging them outside the tab bar region.
Refs #7410
Features
Tab Reordering
Tab Detachment
Visual Feedback
Performance Optimization
Configuration Options
Three new options have been added to
kitty.conf:enable_tab_dragyestab_drag_threshold5enable_tab_drag_detachyesImplementation Details
Modified Files
kitty/tabs.py: Core drag logic includingTabDragState, event handling, and reorderingkitty/tab_bar.py: Visual feedback rendering (dimming, drop indicator)kitty/mouse.c: Motion event reporting during tab bar drag operationskitty/boss.py: Tab transfer coordination via existing_move_tab_tomethodkitty/state.h,kitty/state.c: C-level drag state flag and option fieldskitty/options/definition.py: New configuration option definitionsNew Test File
kitty_tests/tab_drag.py: Unit tests for_move_tab_to_indexand_calculate_drop_indexTesting
Limitations
Cross-window tab merging (dragging a tab from one window into another) is not included in this implementation due to fundamental constraints in mouse event routing, where events are always dispatched to the window where the mouse button was initially pressed.