gtk: get closing of tabs working again (closing windows still broken)

This commit is contained in:
Thorsten Ball
2023-11-25 13:46:48 +01:00
committed by Mitchell Hashimoto
parent 8cf9d97ac3
commit 0065bae0d4
3 changed files with 19 additions and 9 deletions

View File

@ -90,6 +90,18 @@ pub fn init(
surface.grabFocus(); surface.grabFocus();
} }
pub fn destroy(self: *Split) void {
const window = self.container.window() orelse return;
self.top_left.destroy();
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.
pub fn removeTopLeft(self: *Split) void { pub fn removeTopLeft(self: *Split) void {
self.removeChild(self.top_left, self.bottom_right); self.removeChild(self.top_left, self.bottom_right);
@ -120,7 +132,7 @@ 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.shutdown(); remove.destroy();
window.app.core_app.alloc.destroy(self); window.app.core_app.alloc.destroy(self);
} }

View File

@ -79,12 +79,10 @@ pub const Container = union(enum) {
}; };
} }
pub fn shutdown(self: Elem) void { pub fn destroy(self: Elem) void {
switch (self) { switch (self) {
.surface => |s| s.shutdown(), .surface => |s| s.unref(),
.split => { .split => |s| s.destroy(),
@panic("TODO: shutdownsplit");
},
} }
} }
@ -416,9 +414,9 @@ pub fn deinit(self: *Surface) void {
if (self.cursor) |cursor| c.g_object_unref(cursor); if (self.cursor) |cursor| c.g_object_unref(cursor);
} }
// shutdown removes the long-held reference to the gl_area and kicks off the // unref removes the long-held reference to the gl_area and kicks off the
// deinit/destroy process for this surface. // deinit/destroy process for this surface.
pub fn shutdown(self: *Surface) void { pub fn unref(self: *Surface) void {
c.g_object_unref(self.gl_area); c.g_object_unref(self.gl_area);
} }

View File

@ -142,7 +142,7 @@ 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) void {
self.elem.shutdown(); self.elem.destroy();
} }
// TODO: move this // TODO: move this