@@ -138,22 +138,20 @@ pub const Window = struct {
138
138
}
139
139
140
140
pub fn resize (self :* Window ,width :c_int ,height :c_int )void {
141
- _ = height ;
142
- _ = width ;
143
- _ = self ;
144
- // const frame = objc.NSRect.make(
145
- // 100,
146
- // 100,
147
- // @as(objc.CGFloat, @floatFromInt(width)),
148
- // @as(objc.CGFloat, @floatFromInt(height)),
149
- // );
150
- // // TODO: resize animation can be handled using a DataWrapper on the user-facing API
151
- // _ = objc.msgSendByName(void, self.peer, "setFrame:display:", .{ frame, true }) catch unreachable;
141
+ var frame = self .peer .getProperty (AppKit .NSRect ,"frame" );
142
+ frame .size .width = @floatFromInt (width );
143
+ frame .size .height = @floatFromInt (height );
144
+ self .peer .msgSend (void ,"setFrame:display:" , .{frame ,true });
152
145
}
153
146
154
147
pub fn setTitle (self :* Window ,title : [* :0 ]const u8 )void {
155
- _ = self ;
156
- _ = title ;
148
+ const pool = objc .AutoreleasePool .init ();
149
+ defer pool .deinit ();
150
+
151
+ const NSString = objc .getClass ("NSString" ).? ;
152
+ const string = NSString .msgSend (objc .Object ,"alloc" , .{})
153
+ .msgSend (objc .Object ,"initWithUTF8String:" , .{title });
154
+ self .peer .setProperty ("title" ,string );
157
155
}
158
156
159
157
pub fn setChild (self :* Window ,peer :? PeerType )void {
@@ -174,8 +172,8 @@ pub const Window = struct {
174
172
}
175
173
176
174
pub fn close (self :* Window )void {
177
- _ = self ;
178
- @panic ( "TODO: close window" );
175
+ self . peer . msgSend ( void , "close" , .{}) ;
176
+ _ = activeWindows . fetchSub ( 1 , .Release );
179
177
}
180
178
};
181
179
@@ -233,10 +231,9 @@ pub fn runStep(step: shared.EventLoopStep) bool {
233
231
const app = NSApplication .msgSend (objc .Object ,"sharedApplication" , .{});
234
232
if (! finishedLaunching ) {
235
233
finishedLaunching = true ;
236
- // app.msgSend(void, "finishLaunching", .{});
237
234
if (step == .Blocking ) {
238
235
// Run the NSApplication and stop it immediately using the delegate.
239
- // This is a similar technique to what GLFW does (see cocoa_window.m)
236
+ // This is a similar technique to what GLFW does (see cocoa_window.m in GLFW's source code )
240
237
app .msgSend (void ,"run" , .{});
241
238
}
242
239
}