mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
apprt/gtk: if no parent is set on new window, do not inherit wd
This commit is contained in:
@ -36,6 +36,13 @@ pub const Options = struct {
|
||||
|
||||
/// A font size to set on the surface once it is initialized.
|
||||
font_size: ?font.face.DesiredSize = null,
|
||||
|
||||
/// True if this surface has a parent. This is a bit of a hack currently
|
||||
/// to work around newConfig unconditinally inheriting the working
|
||||
/// directory. The proper long term fix is to have the working directory
|
||||
/// inherited upstream likely at the point where this field would be set,
|
||||
/// then remove this field.
|
||||
parent: bool = false,
|
||||
};
|
||||
|
||||
/// Where the title of this surface will go.
|
||||
@ -49,6 +56,9 @@ const Title = union(enum) {
|
||||
/// surface has been initialized.
|
||||
realized: bool = false,
|
||||
|
||||
/// See Options.parent
|
||||
parent: bool = false,
|
||||
|
||||
/// The app we're part of
|
||||
app: *App,
|
||||
|
||||
@ -150,6 +160,7 @@ pub fn init(self: *Surface, app: *App, opts: Options) !void {
|
||||
} else .{ .none = {} },
|
||||
.core_surface = undefined,
|
||||
.font_size = opts.font_size,
|
||||
.parent = opts.parent,
|
||||
.size = .{ .width = 800, .height = 600 },
|
||||
.cursor_pos = .{ .x = 0, .y = 0 },
|
||||
.im_context = im_context,
|
||||
@ -195,6 +206,10 @@ fn realize(self: *Surface) !void {
|
||||
// Get our new surface config
|
||||
var config = try apprt.surface.newConfig(self.app.core_app, &self.app.config);
|
||||
defer config.deinit();
|
||||
if (!self.parent) {
|
||||
// A hack, see the "parent" field for more information.
|
||||
config.@"working-directory" = self.app.config.@"working-directory";
|
||||
}
|
||||
|
||||
// Initialize our surface now that we have the stable pointer.
|
||||
try self.core_surface.init(
|
||||
|
@ -216,6 +216,7 @@ pub fn newTab(self: *Window, parent_: ?*CoreSurface) !void {
|
||||
.gl_area = @ptrCast(gl_area),
|
||||
.title_label = @ptrCast(label_text),
|
||||
.font_size = font_size,
|
||||
.parent = parent_ != null,
|
||||
});
|
||||
errdefer surface.deinit();
|
||||
const page_idx = c.gtk_notebook_append_page(self.notebook, gl_area, label_box_widget);
|
||||
|
Reference in New Issue
Block a user