Remove custom CAPI function

and use the already existing get_config function
This commit is contained in:
SoraTenshi
2023-09-14 00:08:16 +02:00
committed by Mitchell Hashimoto
parent 3cb21dd76e
commit ddb9be0971
3 changed files with 7 additions and 9 deletions

View File

@ -365,7 +365,6 @@ bool ghostty_config_get(ghostty_config_t, void *, const char *, uintptr_t);
ghostty_input_trigger_s ghostty_config_trigger(ghostty_config_t, const char *, uintptr_t); ghostty_input_trigger_s ghostty_config_trigger(ghostty_config_t, const char *, uintptr_t);
uint32_t ghostty_config_errors_count(ghostty_config_t); uint32_t ghostty_config_errors_count(ghostty_config_t);
ghostty_error_s ghostty_config_get_error(ghostty_config_t, uint32_t); ghostty_error_s ghostty_config_get_error(ghostty_config_t, uint32_t);
bool ghostty_config_render_decoration(ghostty_config_t);
ghostty_app_t ghostty_app_new(const ghostty_runtime_config_s *, ghostty_config_t); ghostty_app_t ghostty_app_new(const ghostty_runtime_config_s *, ghostty_config_t);
void ghostty_app_free(ghostty_app_t); void ghostty_app_free(ghostty_app_t);

View File

@ -16,19 +16,22 @@ class FocusedSurfaceWrapper {
class PrimaryWindow: NSWindow { class PrimaryWindow: NSWindow {
var focusedSurfaceWrapper: FocusedSurfaceWrapper = FocusedSurfaceWrapper() var focusedSurfaceWrapper: FocusedSurfaceWrapper = FocusedSurfaceWrapper()
static func getStyleMask(render_decoration: Bool) -> NSWindow.StyleMask { static func getStyleMask(renderDecoration: Bool) -> NSWindow.StyleMask {
var mask: NSWindow.StyleMask = [.resizable, .closable, .miniaturizable] var mask: NSWindow.StyleMask = [.resizable, .closable, .miniaturizable]
if render_decoration { if renderDecoration {
mask.insert(.titled) mask.insert(.titled)
} }
return mask return mask
} }
static func create(ghostty: Ghostty.AppState, appDelegate: AppDelegate, baseConfig: ghostty_surface_config_s? = nil) -> PrimaryWindow { static func create(ghostty: Ghostty.AppState, appDelegate: AppDelegate, baseConfig: ghostty_surface_config_s? = nil) -> PrimaryWindow {
let decorations = baseConfig?.render_decoration ?? ghostty_config_render_decoration(ghostty.config) var renderDecoration = false;
let configString = "window-decoration"
_ = ghostty_config_get(ghostty.config, &renderDecoration, configString, UInt(configString.count))
let window = PrimaryWindow( let window = PrimaryWindow(
contentRect: NSRect(x: 0, y: 0, width: 800, height: 600), contentRect: NSRect(x: 0, y: 0, width: 800, height: 600),
styleMask: getStyleMask(render_decoration: decorations), styleMask: getStyleMask(renderDecoration: baseConfig?.render_decoration ?? renderDecoration),
backing: .buffered, backing: .buffered,
defer: false) defer: false)
window.center() window.center()

View File

@ -119,10 +119,6 @@ export fn ghostty_config_get_error(self: *Config, idx: u32) Error {
return .{ .message = err.message.ptr }; return .{ .message = err.message.ptr };
} }
export fn ghostty_config_render_decoration(self: *Config) bool {
return self.@"window-decoration";
}
/// Sync with ghostty_error_s /// Sync with ghostty_error_s
const Error = extern struct { const Error = extern struct {
message: [*:0]const u8 = "", message: [*:0]const u8 = "",