mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
update size
This commit is contained in:
@ -45,7 +45,7 @@ class TerminalSurfaceView_Real: NSView, ObservableObject {
|
|||||||
// Setup our surface. This will also initialize all the terminal IO.
|
// Setup our surface. This will also initialize all the terminal IO.
|
||||||
var surface_cfg = ghostty_surface_config_s(
|
var surface_cfg = ghostty_surface_config_s(
|
||||||
nsview: Unmanaged.passUnretained(self).toOpaque(),
|
nsview: Unmanaged.passUnretained(self).toOpaque(),
|
||||||
scale_factor: 2.0)
|
scale_factor: 1.0)
|
||||||
guard let surface = ghostty_surface_new(app, &surface_cfg) else {
|
guard let surface = ghostty_surface_new(app, &surface_cfg) else {
|
||||||
self.error = AppError.surfaceCreateError
|
self.error = AppError.surfaceCreateError
|
||||||
return
|
return
|
||||||
@ -59,17 +59,11 @@ class TerminalSurfaceView_Real: NSView, ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func resize(withOldSuperviewSize oldSize: NSSize) {
|
override func resize(withOldSuperviewSize oldSize: NSSize) {
|
||||||
print("LAYER: \(self.layer?.bounds)")
|
|
||||||
super.resize(withOldSuperviewSize: oldSize)
|
super.resize(withOldSuperviewSize: oldSize)
|
||||||
print("RESIZE: \(oldSize) NEW: \(self.bounds)")
|
|
||||||
print("LAYER: \(self.layer?.bounds)")
|
|
||||||
}
|
|
||||||
|
|
||||||
override func draw(_ dirtyRect: NSRect) {
|
if let surface = self.surface {
|
||||||
print("DRAW: \(dirtyRect)")
|
ghostty_surface_set_size(surface, UInt32(self.bounds.size.width), UInt32(self.bounds.size.height))
|
||||||
NSColor.green.setFill()
|
}
|
||||||
dirtyRect.fill()
|
|
||||||
super.draw(dirtyRect)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func mouseDown(with event: NSEvent) {
|
override func mouseDown(with event: NSEvent) {
|
||||||
|
@ -51,6 +51,7 @@ pub const Window = struct {
|
|||||||
nsview: objc.Object,
|
nsview: objc.Object,
|
||||||
scale_factor: f64,
|
scale_factor: f64,
|
||||||
core_win: *CoreWindow,
|
core_win: *CoreWindow,
|
||||||
|
size: apprt.WindowSize,
|
||||||
|
|
||||||
pub const Options = extern struct {
|
pub const Options = extern struct {
|
||||||
/// The pointer to the backing NSView for the surface.
|
/// The pointer to the backing NSView for the surface.
|
||||||
@ -67,6 +68,7 @@ pub const Window = struct {
|
|||||||
.core_win = core_win,
|
.core_win = core_win,
|
||||||
.nsview = objc.Object.fromId(opts.nsview),
|
.nsview = objc.Object.fromId(opts.nsview),
|
||||||
.scale_factor = opts.scale_factor,
|
.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 {
|
pub fn getSize(self: *const Window) !apprt.WindowSize {
|
||||||
_ = self;
|
return self.size;
|
||||||
|
|
||||||
// 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 };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setSizeLimits(self: *Window, min: apprt.WindowSize, max_: ?apprt.WindowSize) !void {
|
pub fn setSizeLimits(self: *Window, min: apprt.WindowSize, max_: ?apprt.WindowSize) !void {
|
||||||
@ -117,14 +115,14 @@ pub const Window = struct {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn updateSize(self: *const Window, width: u32, height: u32) void {
|
pub fn updateSize(self: *Window, width: u32, height: u32) void {
|
||||||
const size: apprt.WindowSize = .{
|
self.size = .{
|
||||||
.width = width,
|
.width = width,
|
||||||
.height = height,
|
.height = height,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Call the primary callback.
|
// 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});
|
log.err("error in size callback err={}", .{err});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user