mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-30 20:37:55 +00:00
apprt: clean up how apprt initializes surfaces
This commit is contained in:
@@ -61,3 +61,24 @@ pub const Mailbox = struct {
|
||||
}, timeout);
|
||||
}
|
||||
};
|
||||
|
||||
/// Returns a new config for a surface for the given app that should be
|
||||
/// used for any new surfaces. The resulting config should be deinitialized
|
||||
/// after the surface is initialized.
|
||||
pub fn newConfig(app: *const App, config: *const Config) !Config {
|
||||
// Create a shallow clone
|
||||
var copy = config.shallowClone(app.alloc);
|
||||
|
||||
// Our allocator is our config's arena
|
||||
const alloc = copy._arena.?.allocator();
|
||||
|
||||
// Get our previously focused surface for some inherited values.
|
||||
const prev = app.focusedSurface();
|
||||
if (prev) |p| {
|
||||
if (try p.pwd(alloc)) |pwd| {
|
||||
copy.@"working-directory" = pwd;
|
||||
}
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user