diff --git a/macos/Sources/TerminalSurfaceView.swift b/macos/Sources/TerminalSurfaceView.swift index 2e7343441..498ac9c30 100644 --- a/macos/Sources/TerminalSurfaceView.swift +++ b/macos/Sources/TerminalSurfaceView.swift @@ -45,7 +45,7 @@ class TerminalSurfaceView_Real: NSView, ObservableObject { // Setup our surface. This will also initialize all the terminal IO. var surface_cfg = ghostty_surface_config_s( nsview: Unmanaged.passUnretained(self).toOpaque(), - scale_factor: 2.0) + scale_factor: 1.0) guard let surface = ghostty_surface_new(app, &surface_cfg) else { self.error = AppError.surfaceCreateError return @@ -59,17 +59,11 @@ class TerminalSurfaceView_Real: NSView, ObservableObject { } override func resize(withOldSuperviewSize oldSize: NSSize) { - print("LAYER: \(self.layer?.bounds)") super.resize(withOldSuperviewSize: oldSize) - print("RESIZE: \(oldSize) NEW: \(self.bounds)") - print("LAYER: \(self.layer?.bounds)") - } - - override func draw(_ dirtyRect: NSRect) { - print("DRAW: \(dirtyRect)") - NSColor.green.setFill() - dirtyRect.fill() - super.draw(dirtyRect) + + if let surface = self.surface { + ghostty_surface_set_size(surface, UInt32(self.bounds.size.width), UInt32(self.bounds.size.height)) + } } override func mouseDown(with event: NSEvent) { diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index c0dc8dba8..aafc95b4a 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -51,6 +51,7 @@ pub const Window = struct { nsview: objc.Object, scale_factor: f64, core_win: *CoreWindow, + size: apprt.WindowSize, pub const Options = extern struct { /// The pointer to the backing NSView for the surface. @@ -67,6 +68,7 @@ pub const Window = struct { .core_win = core_win, .nsview = objc.Object.fromId(opts.nsview), .scale_factor = opts.scale_factor, + .size = .{ .width = 800, .height = 600 }, }; } @@ -80,11 +82,7 @@ pub const Window = struct { } pub fn getSize(self: *const Window) !apprt.WindowSize { - _ = self; - - // Initially our window will have a zero size. Until we can determine - // the size of the window, we just send down this value. - return apprt.WindowSize{ .width = 800, .height = 600 }; + return self.size; } pub fn setSizeLimits(self: *Window, min: apprt.WindowSize, max_: ?apprt.WindowSize) !void { @@ -117,14 +115,14 @@ pub const Window = struct { return false; } - pub fn updateSize(self: *const Window, width: u32, height: u32) void { - const size: apprt.WindowSize = .{ + pub fn updateSize(self: *Window, width: u32, height: u32) void { + self.size = .{ .width = width, .height = height, }; // Call the primary callback. - self.core_win.sizeCallback(size) catch |err| { + self.core_win.sizeCallback(self.size) catch |err| { log.err("error in size callback err={}", .{err}); return; };