mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
WIP: gtk: handle split surfaces when closing tab/window
This commit is contained in:

committed by
Mitchell Hashimoto

parent
a7717289eb
commit
dc0f6e3a5b
@ -219,3 +219,21 @@ fn addChild2(self: *Paned, child: Child) void {
|
||||
self.child2 = child;
|
||||
child.setParent(.{ .paned = .{ self, .end } });
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Paned, alloc: Allocator) void {
|
||||
switch (self.child1) {
|
||||
.none, .surface => {},
|
||||
.paned => |paned| {
|
||||
paned.deinit(alloc);
|
||||
alloc.destroy(paned);
|
||||
},
|
||||
}
|
||||
|
||||
switch (self.child2) {
|
||||
.none, .surface => {},
|
||||
.paned => |paned| {
|
||||
paned.deinit(alloc);
|
||||
alloc.destroy(paned);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -163,3 +163,17 @@ fn gtkTabCloseClick(_: *c.GtkButton, ud: ?*anyopaque) callconv(.C) void {
|
||||
const window = tab.window;
|
||||
window.closeTab(tab);
|
||||
}
|
||||
|
||||
pub fn close(self: *Tab) void {
|
||||
switch (self.child) {
|
||||
.none => return,
|
||||
.surface => {
|
||||
// TODO: I'm not 100% but I don't think we have to do something
|
||||
return;
|
||||
},
|
||||
.paned => |paned| {
|
||||
paned.deinit(self.window.app.core_app.alloc);
|
||||
self.window.app.core_app.alloc.destroy(paned);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,10 @@ fn initActions(self: *Window) void {
|
||||
|
||||
pub fn deinit(self: *Window) void {
|
||||
self.icon.deinit(self.app);
|
||||
for (self.tabs.items) |tab| self.app.core_app.alloc.destroy(tab);
|
||||
for (self.tabs.items) |tab| {
|
||||
tab.close();
|
||||
self.app.core_app.alloc.destroy(tab);
|
||||
}
|
||||
self.tabs.deinit(self.app.core_app.alloc);
|
||||
}
|
||||
|
||||
@ -214,6 +217,7 @@ pub fn removeTab(self: *Window, tab: *Tab) !void {
|
||||
if (tab_idx) |idx| _ = self.tabs.orderedRemove(idx) else return error.TabNotFound;
|
||||
|
||||
// Deallocate the tab
|
||||
tab.close();
|
||||
self.app.core_app.alloc.destroy(tab);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user