Skip to content

gtk: implement drag-to-move for splits - #10423

Merged
jcollie merged 3 commits into
ghostty-org:mainfrom
pluiedev:pluie/jj-krzqooltoytw
Aug 5, 2026
Merged

jcollie merged 3 commits into
ghostty-org:mainfrom
pluiedev:pluie/jj-krzqooltoytw

Conversation

@pluiedev

@pluiedev pluiedev commented Jan 23, 2026 •

Copy link
Copy Markdown
Member

One major todo is moving splits across different split trees (i.e. moving across tabs and windows), but that would involve a lot more logic. This MVP version works for now.

Video demo (somehow the encode quality is terrible - I'll fix this later):

2026-01-24.01-13-44.mp4

GTK version of #10090

Closes #10224

@pluiedev
pluiedev requested a review from a team as a code owner January 23, 2026 17:12
@pluiedev
pluiedev force-pushed the pluie/jj-krzqooltoytw branch from e23343f to 6fc7f7d Compare January 23, 2026 17:16
@jcollie

jcollie commented Jan 23, 2026

Copy link
Copy Markdown
Member

After playing around a bit, I got this panic when exiting Ghostty:

thread 627727 panic: reached unreachable code
/nix/store/z3mbm3szjjacd2q2kaa795ik361w1irr-zig-0.15.2/lib/std/debug.zig:559:14: 0x2aa13bd in assert (ghostty)
    if (!ok) unreachable; // assertion failure
             ^
/home/jcollie/dev/ghostty/src/App.zig:114:11: 0x2d0fb0d in deinit (ghostty)
    assert(self.font_grid_set.count() == 0);
          ^
/home/jcollie/dev/ghostty/src/App.zig:120:16: 0x2c7ee50 in destroy (ghostty)
    self.deinit();
               ^
/home/jcollie/dev/ghostty/src/main_ghostty.zig:98:22: 0x2c7ea56 in main (ghostty)
    defer app.destroy();
                     ^
/nix/store/z3mbm3szjjacd2q2kaa795ik361w1irr-zig-0.15.2/lib/std/start.zig:627:37: 0x2c7f295 in main (ghostty)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0x7ffff682a4c4 in ??? (libc.so.6)
Unwind information for `libc.so.6:0x7ffff682a4c4` was not available, trace may be incomplete

???:?:?: 0x7ffff682a577 in ??? (libc.so.6)
???:?:?: 0x276a8a4 in ??? (???)
debug(io_exec): termios change mode=.{ .canonical = true, .echo = true }

@pluiedev

Copy link
Copy Markdown
Member Author

Hmm.. what does the font grid have to do with any of this...?

@pluiedev
pluiedev force-pushed the pluie/jj-krzqooltoytw branch from 6666b57 to 04deac3 Compare February 1, 2026 06:53
@pluiedev

pluiedev commented Feb 1, 2026

Copy link
Copy Markdown
Member Author

Hang on. Why is the surface not getting deinit'd when the whole app closes? This is sus. Lemme think about this

@pluiedev

pluiedev commented Feb 1, 2026

Copy link
Copy Markdown
Member Author

I think I realized why - the content provider is constantly holding a stale ref to the surface, so the surfaces themselves are actually never unref'd. Good thing we had an assert there, since otherwise we could have had a gigantic leak

@pluiedev

Copy link
Copy Markdown
Member Author

Hmm.. Resolving this turned out to be much more difficult than imagined. The GLib APIs I've been given here aren't really flexible enough, so I might need to wait for us to assign each surface a unique ID and then make the split tree fully ID-based instead of holding pointers to the RtSurface structs, to fully sidestep the refcounting mechanism. Gonna mark this as draft for now.

Blocked on #8200 or a functional equivalent

@pluiedev
pluiedev marked this pull request as draft February 14, 2026 16:37
jemal added a commit to jemal/ghostty that referenced this pull request Jul 14, 2026
Adds a move_split action (up/down/left/right) that swaps the active
split with its nearest spatial neighbor, scoped to the current split
tree so splits can't be moved across tabs or windows. GTK-only; no
default keybind is set, bind it yourself e.g.
`keybind = alt+shift+h=move_split:left`.

The tree-manipulation core (SplitTree.moveSplit, plus a locate() helper
on the datastruct split tree) is adapted from upstream's in-progress
mouse drag-and-drop implementation (ghostty-org#10423, itself
a GTK port of macOS PR ghostty-org#10090), but exposed here via a keybind instead
of a drag handle, per issue ghostty-org#10224.

Plumbing follows the existing goto_split action end-to-end: a new
MoveSplit C-ABI enum in apprt/action.zig + include/ghostty.h (appended
at the end for ABI compatibility), a Binding.zig keybind action and
command palette entries, and dispatch through Surface.zig into the
gtk apprt.
One major todo is moving splits across different split trees (i.e.
moving across tabs and windows), but that would involve a lot more logic.
This MVP version works for now.

GTK version of ghostty-org#10090

Closes ghostty-org#10224
@pluiedev
pluiedev force-pushed the pluie/jj-krzqooltoytw branch from 04deac3 to 98fae16 Compare August 5, 2026 08:18
@pluiedev

pluiedev commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

Wouldn't you know it, switching to u64 IDs fixed all the issues completely :bobr:

@pluiedev
pluiedev marked this pull request as ready for review August 5, 2026 08:19

@jcollie jcollie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nifty! Now the GTK devs can get people complaining about the drag handle too! One nice thing to have might be is suppressing the drag handle when there's only one split but I won't block this PR for that.

@jcollie
jcollie merged commit 15ac61d into ghostty-org:main Aug 5, 2026
99 checks passed
@github-actions github-actions Bot added this to the 1.4.0 milestone Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GTK: Implement split drag and drop to reorder

2 participants