mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
apprt/gtk: nested splits are good
This commit is contained in:
@ -87,6 +87,9 @@ pub fn init(
|
||||
// Update our children so that our GL area is properly
|
||||
// added to the paned.
|
||||
self.updateChildren();
|
||||
|
||||
// The new surface should always grab focus
|
||||
surface.grabFocus();
|
||||
}
|
||||
|
||||
/// Focus on first Surface that can be found in given position. If there's a
|
||||
@ -199,8 +202,19 @@ pub fn replace(
|
||||
// Update our paned children. This will reset the divider
|
||||
// position but we want to keep it in place so save and restore it.
|
||||
const pos = c.gtk_paned_get_position(self.paned);
|
||||
self.updateChildren();
|
||||
c.gtk_paned_set_position(self.paned, pos);
|
||||
defer c.gtk_paned_set_position(self.paned, pos);
|
||||
|
||||
if (ptr == &self.top_left) {
|
||||
c.gtk_paned_set_start_child(
|
||||
@ptrCast(self.paned),
|
||||
self.top_left.widget(),
|
||||
);
|
||||
} else {
|
||||
c.gtk_paned_set_end_child(
|
||||
@ptrCast(self.paned),
|
||||
self.bottom_right.widget(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Update the paned children to represent the current state.
|
||||
|
@ -159,27 +159,6 @@ pub fn deinit(self: *Tab) void {
|
||||
}
|
||||
}
|
||||
|
||||
/// Splits the current child surface into a Paned in given direction. Child of
|
||||
/// Tab must be a Surface.
|
||||
pub fn splitSurface(self: *Tab, direction: input.SplitDirection) !void {
|
||||
assert(self.child == .surface);
|
||||
|
||||
const surface = switch (self.child) {
|
||||
.surface => |s| s,
|
||||
else => unreachable,
|
||||
};
|
||||
self.removeChild();
|
||||
|
||||
// Create a Paned with two Surfaces.
|
||||
const paned = try Paned.create(self.window.app.core_app.alloc, surface, direction);
|
||||
|
||||
// Add Paned to the Tab.
|
||||
self.setChild(.{ .paned = paned });
|
||||
|
||||
// Focus on new surface
|
||||
paned.focusFirstSurfaceInPosition(.end);
|
||||
}
|
||||
|
||||
/// Remove the current child from the Tab. Noop if no child set.
|
||||
pub fn removeChild(self: *Tab) void {
|
||||
const widget = self.child.widget() orelse return;
|
||||
|
Reference in New Issue
Block a user