apprt/glfw: inherit working dir

This commit is contained in:
Mitchell Hashimoto
2023-05-31 19:18:55 -07:00
parent 866de88ee6
commit 0fca74c089

View File

@ -346,10 +346,25 @@ pub const Surface = struct {
try app.app.addSurface(self);
errdefer app.app.deleteSurface(self);
// Our parent pwd will be tracked here
const alloc = app.app.alloc;
var parent_pwd: ?[]const u8 = null;
defer if (parent_pwd) |v| alloc.free(v);
// Shallow copy the config so that we can modify it.
var config = app.config;
// Get our previously focused surface
const parent = app.app.focusedSurface();
if (parent) |p| {
parent_pwd = try p.pwd(alloc);
if (parent_pwd) |v| config.@"working-directory" = v;
}
// Initialize our surface now that we have the stable pointer.
try self.core_surface.init(
app.app.alloc,
&app.config,
alloc,
&config,
.{ .rt_app = app, .mailbox = &app.app.mailbox },
self,
);