From 0af2a3f693fbca383c8bce9db2a9870fb71953e9 Mon Sep 17 00:00:00 2001 From: Peter Guy Date: Sat, 11 Oct 2025 22:23:08 -0700 Subject: [PATCH] Enable distinguishing between a new tab in a new window (which should inherit based on the window setting), and a new tab in an existing window (which should inherit base on tab setting) --- src/apprt/gtk/class/application.zig | 4 ++-- src/apprt/gtk/class/window.zig | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/apprt/gtk/class/application.zig b/src/apprt/gtk/class/application.zig index b16bce049..848aa22db 100644 --- a/src/apprt/gtk/class/application.zig +++ b/src/apprt/gtk/class/application.zig @@ -2238,8 +2238,8 @@ const Action = struct { .{}, ); - // Create a new tab - win.newTab(parent); + // Create a new tab with window context (first tab in new window) + win.newTabForWindow(parent); // Show the window gtk.Window.present(win.as(gtk.Window)); diff --git a/src/apprt/gtk/class/window.zig b/src/apprt/gtk/class/window.zig index 77fd2eea5..c2a8924f2 100644 --- a/src/apprt/gtk/class/window.zig +++ b/src/apprt/gtk/class/window.zig @@ -361,10 +361,14 @@ pub const Window = extern struct { /// at the position dictated by the `window-new-tab-position` config. /// The new tab will be selected. pub fn newTab(self: *Self, parent_: ?*CoreSurface) void { - _ = self.newTabPage(parent_); + _ = self.newTabPage(parent_, .tab); } - fn newTabPage(self: *Self, parent_: ?*CoreSurface) *adw.TabPage { + pub fn newTabForWindow(self: *Self, parent_: ?*CoreSurface) void { + _ = self.newTabPage(parent_, .window); + } + + fn newTabPage(self: *Self, parent_: ?*CoreSurface, context: apprt.surface.NewSurfaceContext) *adw.TabPage { const priv = self.private(); const tab_view = priv.tab_view; @@ -372,7 +376,9 @@ pub const Window = extern struct { const tab = gobject.ext.newInstance(Tab, .{ .config = priv.config, }); - if (parent_) |p| tab.setParent(p); + if (parent_) |p| { + tab.setParentWithContext(p, context); + } // Get the position that we should insert the new tab at. const config = if (priv.config) |v| v.get() else { @@ -1231,7 +1237,7 @@ pub const Window = extern struct { _: *adw.TabOverview, self: *Self, ) callconv(.c) *adw.TabPage { - return self.newTabPage(if (self.getActiveSurface()) |v| v.core() else null); + return self.newTabPage(if (self.getActiveSurface()) |v| v.core() else null, .tab); } fn tabOverviewOpen(