Add mouse-based tab drag functionality for reordering and detachment#9296
Add mouse-based tab drag functionality for reordering and detachment#9296seijikohara wants to merge 2 commits intokovidgoyal:masterfrom
Conversation
|
Before reviewing the code, some initial feedback:
enable_tab_drag x y Where x is the drag threshold with negative numbers disabling tab dragging.
|
739232e to
822052c
Compare
|
Thanks for the feedback! I've addressed both points:
I also added a drag thumbnail preview — a semi-transparent NSPanel showing the tab content while dragging outside the tab bar (macOS only). The branch has been rebased onto the latest master. |
|
OK I reviewed the code in detail. Here are my comments:
5b) You need to handle the case when dropping onto an OS window with a hidden Other than these, great work! I am impressed how far you got on your own. |
|
Oh and you also need to handle drag and drop between two kitty instances. In this case I suppose you can just reject the drop. maybe store the pid of the kitty process in the mime entry in the drag data like application/net.kovidgoyal.kitty-tab-1234 where 1234 is the PID. Then in drag_callback you can reject the drag if the PID does not match the current processes PID. |
c744bfd to
c62341d
Compare
Implement mouse-based tab dragging: - Drag tabs horizontally within the tab bar to reorder - Drag outside tab bar to detach into a new OS window - Drag to another OS window to move the tab there (macOS) - Visual feedback: dimmed dragged tab + green drop indicator - Coordinate conversion handles Retina/HiDPI displays Configuration: enable_tab_drag <drag_threshold> [detach_threshold] - First number: drag threshold in pixels (negative disables) - Second number: detach threshold (optional, default 20, negative disables detach while allowing reorder) Cross-window drag converts framebuffer coordinates to screen coordinates using the width/framebuffer_width ratio, then performs hit-testing against all other OS windows. Refs kovidgoyal#7410
This commit adds mouse-based tab dragging functionality using the GLFW Drag API. Users can now drag tabs to reorder them within the tab bar, move tabs between OS windows, or detach tabs into new windows. GLFW changes: - Add drag end callback for handling drops outside windows - Add glfwSetDragTitle API to display tab title on drag image - Store mouse down event for valid drag initiation on macOS - Fix memory management in NSBitmapImageRep, NSImage, NSDraggingItem - Restrict drag operations to within application context - Disable snap-back animation on drag cancel/fail - Convert macOS screen coordinates to GLFW coordinates kitty changes: - Implement drag/drop callbacks for tab MIME type handling - Add drop indicator as placeholder tab [+] using theme colors - Track dragging tab state for external drop handling - Create new OS window when tab is dropped outside all windows - Position new window centered at drop location - Clamp window position to stay within monitor boundaries - Simplify enable_tab_drag config to drag_threshold only - Add thumbnail caching for drag image generation
c62341d to
398eca8
Compare
|
@kovidgoyal Ready for review. Changes in second commit : 398eca8
|
Summary
Implements mouse-based tab dragging for reordering within the tab bar, moving tabs between OS windows, and detaching tabs into new windows on macOS using the GLFW Drag API.
Refs #7410
Changes in this version
GLFWDropData,glfwReadDropData,glfwFinishDrop)_glfwPlatformSetDragTitleand_glfwPlatformSetDragImagePlacementstubs for X11, Wayland, and null platformsFeatures
Tab Reordering
[+]indicatorTab Detachment
Cross-Window Tab Transfer
Drag Image
Configuration
enable_tab_drag(default:5)The value is the drag threshold in pixels - the distance the mouse must move before a drag begins. A negative value disables tab dragging entirely.
Examples:
enable_tab_drag 5— default behaviorenable_tab_drag -1— disable tab draggingTechnical Implementation
GLFW Drag API Integration
glfwStartDragwith MIME typeapplication/net.kovidgoyal.kitty-tab-{PID}drag_callbackhandles ENTER/MOVE/LEAVE/STATUS_UPDATE eventsdrop_callbackuses new chunked API (glfwGetDropMimeTypes,glfwReadDropData,glfwFinishDrop)drag_end_callbackhandles drops outside kitty windows (detach)New GLFW APIs Added
glfwSetDragTitle(window, title)- Sets title displayed above drag thumbnailglfwSetDragEndCallback(window, callback)- Called when drag ends (accepted or rejected)glfwSetDragImagePlacement(window, placement)- Controls thumbnail position (above/below cursor)Commits
Testing
kitty_tests/tab_drag.py: 3 test cases (drop index, tab reorder, cross-window targeting)Limitations