gtk: +new-window now respects --working-directory and -e

Fixes: #8862
Fixes: #10716

This adds the machinery to pass configuration settings received over
DBus down to the GObject Surface so that that configuration information
can be used to override some settings from the current "live" config
when creating a new window. Currently it's only possible to override
`--working-directory` and `--command`. `-e` on the `ghostty +new-window`
CLI works as well.

Adding more overridable settings is possible, but being able to fully
override any possible setting would better be served with a major
revamp of how Ghostty handles configs, which I is way out of scope at
the moment.
This commit is contained in:
Jeffrey C. Ollie
2026-02-17 20:19:33 -06:00
parent c3febabd28
commit 6961c2265e
17 changed files with 471 additions and 87 deletions

15
src/lib/string.zig Normal file
View File

@@ -0,0 +1,15 @@
const std = @import("std");
// This is a copy of std.mem.cutPrefix from 0.16. Once Ghostty has been ported
// to 0.16 this can be removed.
/// If slice starts with prefix, returns the rest of slice starting at
/// prefix.len.
pub fn cutPrefix(comptime T: type, slice: []const T, prefix: []const T) ?[]const T {
return if (std.mem.startsWith(T, slice, prefix)) slice[prefix.len..] else null;
}
test cutPrefix {
try std.testing.expectEqualStrings("foo", cutPrefix(u8, "--example=foo", "--example=").?);
try std.testing.expectEqual(null, cutPrefix(u8, "--example=foo", "-example="));
}