mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
gtk: fix closing of windows that contains splits
This commit is contained in:

committed by
Mitchell Hashimoto

parent
0065bae0d4
commit
a18fb4a661
@ -90,16 +90,11 @@ pub fn init(
|
|||||||
surface.grabFocus();
|
surface.grabFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn destroy(self: *Split) void {
|
pub fn destroy(self: *Split, alloc: Allocator) void {
|
||||||
const window = self.container.window() orelse return;
|
self.top_left.deinit(alloc);
|
||||||
|
self.bottom_right.deinit(alloc);
|
||||||
|
|
||||||
self.top_left.destroy();
|
alloc.destroy(self);
|
||||||
self.bottom_right.destroy();
|
|
||||||
|
|
||||||
self.removeChildren();
|
|
||||||
|
|
||||||
// TODO: this is the same as in removeChild?
|
|
||||||
window.app.core_app.alloc.destroy(self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove the top left child.
|
/// Remove the top left child.
|
||||||
@ -115,6 +110,7 @@ pub fn removeBottomRight(self: *Split) void {
|
|||||||
// TODO: Is this Zig-y?
|
// TODO: Is this Zig-y?
|
||||||
inline fn removeChild(self: *Split, remove: Surface.Container.Elem, keep: Surface.Container.Elem) void {
|
inline fn removeChild(self: *Split, remove: Surface.Container.Elem, keep: Surface.Container.Elem) void {
|
||||||
const window = self.container.window() orelse return;
|
const window = self.container.window() orelse return;
|
||||||
|
const alloc = window.app.core_app.alloc;
|
||||||
|
|
||||||
// TODO: Grab focus
|
// TODO: Grab focus
|
||||||
|
|
||||||
@ -132,8 +128,8 @@ inline fn removeChild(self: *Split, remove: Surface.Container.Elem, keep: Surfac
|
|||||||
self.container.replace(keep);
|
self.container.replace(keep);
|
||||||
|
|
||||||
// TODO: is this correct?
|
// TODO: is this correct?
|
||||||
remove.destroy();
|
remove.deinit(alloc);
|
||||||
window.app.core_app.alloc.destroy(self);
|
alloc.destroy(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: ehhhhhh
|
// TODO: ehhhhhh
|
||||||
|
@ -79,10 +79,10 @@ pub const Container = union(enum) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn destroy(self: Elem) void {
|
pub fn deinit(self: Elem, alloc: Allocator) void {
|
||||||
switch (self) {
|
switch (self) {
|
||||||
.surface => |s| s.unref(),
|
.surface => |s| s.unref(),
|
||||||
.split => |s| s.destroy(),
|
.split => |s| s.destroy(alloc),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,15 +141,13 @@ pub fn init(self: *Tab, window: *Window, parent_: ?*CoreSurface) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Deinits tab by deiniting child elem.
|
/// Deinits tab by deiniting child elem.
|
||||||
pub fn deinit(self: *Tab) void {
|
pub fn deinit(self: *Tab, alloc: Allocator) void {
|
||||||
self.elem.destroy();
|
self.elem.deinit(alloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move this
|
// TODO: move this
|
||||||
/// Replace the surface element that this tab is showing.
|
/// Replace the surface element that this tab is showing.
|
||||||
pub fn replaceElem(self: *Tab, elem: Surface.Container.Elem) void {
|
pub fn replaceElem(self: *Tab, elem: Surface.Container.Elem) void {
|
||||||
// _ = c.g_object_ref_sink(self.elem.widget());
|
|
||||||
|
|
||||||
// Remove our previous widget
|
// Remove our previous widget
|
||||||
c.gtk_box_remove(self.box, self.elem.widget());
|
c.gtk_box_remove(self.box, self.elem.widget());
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ fn initActions(self: *Window) void {
|
|||||||
pub fn deinit(self: *Window) void {
|
pub fn deinit(self: *Window) void {
|
||||||
self.icon.deinit(self.app);
|
self.icon.deinit(self.app);
|
||||||
for (self.tabs.items) |tab| {
|
for (self.tabs.items) |tab| {
|
||||||
tab.deinit();
|
tab.deinit(self.app.core_app.alloc);
|
||||||
self.app.core_app.alloc.destroy(tab);
|
self.app.core_app.alloc.destroy(tab);
|
||||||
}
|
}
|
||||||
self.tabs.deinit(self.app.core_app.alloc);
|
self.tabs.deinit(self.app.core_app.alloc);
|
||||||
@ -219,7 +219,7 @@ pub fn removeTab(self: *Window, tab: *Tab) !void {
|
|||||||
if (tab_idx) |idx| _ = self.tabs.orderedRemove(idx) else return error.TabNotFound;
|
if (tab_idx) |idx| _ = self.tabs.orderedRemove(idx) else return error.TabNotFound;
|
||||||
|
|
||||||
// Deallocate the tab
|
// Deallocate the tab
|
||||||
tab.deinit();
|
tab.deinit(self.app.core_app.alloc);
|
||||||
self.app.core_app.alloc.destroy(tab);
|
self.app.core_app.alloc.destroy(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user