apprt/gtk-ng: winproto callbacks for subprocess env

This commit is contained in:
Mitchell Hashimoto
2025-08-01 21:16:04 -07:00
parent 523799a45f
commit e1e525ba3d
2 changed files with 14 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ const Config = @import("config.zig").Config;
const ResizeOverlay = @import("resize_overlay.zig").ResizeOverlay;
const ChildExited = @import("surface_child_exited.zig").SurfaceChildExited;
const ClipboardConfirmationDialog = @import("clipboard_confirmation_dialog.zig").ClipboardConfirmationDialog;
const Window = @import("window.zig").Window;
const log = std.log.scoped(.gtk_ghostty_surface);
@@ -1061,8 +1062,6 @@ pub const Surface = extern struct {
}
pub fn defaultTermioEnv(self: *Self) !std.process.EnvMap {
_ = self;
const alloc = Application.default().allocator();
var env = try internal_os.getEnvMap(alloc);
errdefer env.deinit();
@@ -1099,6 +1098,14 @@ pub const Surface = extern struct {
env.remove("GTK_PATH");
}
// This is a hack because it ties ourselves (optionally) to the
// Window class. The right solution we should do is emit a signal
// here where the handler can modify our EnvMap, but boxing the
// EnvMap is a bit annoying so I'm punting it.
if (ext.getAncestor(Window, self.as(gtk.Widget))) |window| {
try window.winproto().addSubprocessEnv(&env);
}
return env;
}

View File

@@ -363,6 +363,11 @@ pub const Window = extern struct {
}
}
/// Winproto backend for this window.
pub fn winproto(self: *Self) *winprotopkg.Window {
return &self.private().winproto;
}
/// Create a new tab with the given parent. The tab will be inserted
/// at the position dictated by the `window-new-tab-position` config.
/// The new tab will be selected.