Consolidate the several ghostty_surface_inherited_config

functions back into a single function with a second parameter for the source context.
This commit is contained in:
Peter Guy
2025-10-13 10:59:01 -07:00
parent c035fb5385
commit d660799723
3 changed files with 14 additions and 25 deletions

View File

@@ -1042,10 +1042,7 @@ ghostty_surface_t ghostty_surface_new(ghostty_app_t,
void ghostty_surface_free(ghostty_surface_t);
void* ghostty_surface_userdata(ghostty_surface_t);
ghostty_app_t ghostty_surface_app(ghostty_surface_t);
ghostty_surface_config_s ghostty_surface_inherited_config(ghostty_surface_t); /* deprecated: use context-specific functions */
ghostty_surface_config_s ghostty_surface_inherited_config_window(ghostty_surface_t);
ghostty_surface_config_s ghostty_surface_inherited_config_tab(ghostty_surface_t);
ghostty_surface_config_s ghostty_surface_inherited_config_split(ghostty_surface_t);
ghostty_surface_config_s ghostty_surface_inherited_config(ghostty_surface_t, ghostty_surface_context_e);
void ghostty_surface_update_config(ghostty_surface_t, ghostty_config_t);
bool ghostty_surface_needs_confirm_quit(ghostty_surface_t);
bool ghostty_surface_process_exited(ghostty_surface_t);

View File

@@ -773,7 +773,7 @@ extension Ghostty {
name: Notification.ghosttyNewWindow,
object: surfaceView,
userInfo: [
Notification.NewSurfaceConfigKey: SurfaceConfiguration(from: ghostty_surface_inherited_config_window(surface)),
Notification.NewSurfaceConfigKey: SurfaceConfiguration(from: ghostty_surface_inherited_config(surface, GHOSTTY_SURFACE_CONTEXT_WINDOW)),
]
)
@@ -810,7 +810,7 @@ extension Ghostty {
name: Notification.ghosttyNewTab,
object: surfaceView,
userInfo: [
Notification.NewSurfaceConfigKey: SurfaceConfiguration(from: ghostty_surface_inherited_config_tab(surface)),
Notification.NewSurfaceConfigKey: SurfaceConfiguration(from: ghostty_surface_inherited_config(surface, GHOSTTY_SURFACE_CONTEXT_TAB)),
]
)
@@ -839,7 +839,7 @@ extension Ghostty {
object: surfaceView,
userInfo: [
"direction": direction,
Notification.NewSurfaceConfigKey: SurfaceConfiguration(from: ghostty_surface_inherited_config_split(surface)),
Notification.NewSurfaceConfigKey: SurfaceConfiguration(from: ghostty_surface_inherited_config(surface, GHOSTTY_SURFACE_CONTEXT_SPLIT)),
]
)

View File

@@ -1551,24 +1551,16 @@ pub const CAPI = struct {
}
/// Returns the config to use for surfaces that inherit from this one.
/// Deprecated: Use ghostty_surface_inherited_config_window/tab/split instead.
export fn ghostty_surface_inherited_config(surface: *Surface) Surface.Options {
return surface.newSurfaceOptions(.window);
}
/// Returns the config to use for new windows that inherit from this surface.
export fn ghostty_surface_inherited_config_window(surface: *Surface) Surface.Options {
return surface.newSurfaceOptions(.window);
}
/// Returns the config to use for new tabs that inherit from this surface.
export fn ghostty_surface_inherited_config_tab(surface: *Surface) Surface.Options {
return surface.newSurfaceOptions(.tab);
}
/// Returns the config to use for new splits that inherit from this surface.
export fn ghostty_surface_inherited_config_split(surface: *Surface) Surface.Options {
return surface.newSurfaceOptions(.split);
export fn ghostty_surface_inherited_config(
surface: *Surface,
source: Surface.Options.Context,
) Surface.Options {
const context: apprt.surface.NewSurfaceContext = switch (source) {
.c_window => .window,
.c_tab => .tab,
.c_split => .split,
};
return surface.newSurfaceOptions(context);
}
/// Update the configuration to the provided config for only this surface.