Add C API function to handle new surfaces of different types

This commit is contained in:
Peter Guy
2025-10-11 22:14:00 -07:00
parent 7cf4c8dc53
commit dba0ff5339
3 changed files with 24 additions and 5 deletions

View File

@@ -1036,7 +1036,10 @@ 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);
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);
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(surface)),
Notification.NewSurfaceConfigKey: SurfaceConfiguration(from: ghostty_surface_inherited_config_window(surface)),
]
)
@@ -810,7 +810,7 @@ extension Ghostty {
name: Notification.ghosttyNewTab,
object: surfaceView,
userInfo: [
Notification.NewSurfaceConfigKey: SurfaceConfiguration(from: ghostty_surface_inherited_config(surface)),
Notification.NewSurfaceConfigKey: SurfaceConfiguration(from: ghostty_surface_inherited_config_tab(surface)),
]
)
@@ -839,7 +839,7 @@ extension Ghostty {
object: surfaceView,
userInfo: [
"direction": direction,
Notification.NewSurfaceConfigKey: SurfaceConfiguration(from: ghostty_surface_inherited_config(surface)),
Notification.NewSurfaceConfigKey: SurfaceConfiguration(from: ghostty_surface_inherited_config_split(surface)),
]
)

View File

@@ -1551,8 +1551,24 @@ 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();
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);
}
/// Update the configuration to the provided config for only this surface.