@@ -135,9 +135,7 @@ fn initWindow(
135
135
const layer = objc .quartz_core .MetalLayer .new ();
136
136
defer layer .release ();
137
137
138
- if (core_window .color == .transparent ) {
139
- layer .setOpaque (false );
140
- }
138
+ if (core_window .color == .transparent ) layer .setOpaque (false );
141
139
142
140
metal_descriptor .* = .{
143
141
.layer = layer ,
@@ -228,13 +226,13 @@ fn initWindow(
228
226
const delegate = objc .mach .WindowDelegate .allocInit ();
229
227
defer native_window .setDelegate (@ptrCast (delegate ));
230
228
{
231
- var windowWillResize_toSize = objc .foundation .stackBlockLiteral (
232
- WindowDelegateCallbacks .windowWillResize_toSize ,
229
+ var windowDidResize = objc .foundation .stackBlockLiteral (
230
+ WindowDelegateCallbacks .windowDidResize ,
233
231
context ,
234
232
null ,
235
233
null ,
236
234
);
237
- delegate .setBlock_windowWillResize_toSize ( windowWillResize_toSize .asBlock ().copy ());
235
+ delegate .setBlock_windowDidResize ( windowDidResize .asBlock ().copy ());
238
236
239
237
var windowShouldClose = objc .foundation .stackBlockLiteral (
240
238
WindowDelegateCallbacks .windowShouldClose ,
@@ -254,19 +252,28 @@ fn initWindow(
254
252
}
255
253
256
254
const WindowDelegateCallbacks = struct {
257
- pub fn windowWillResize_toSize (block : * objc .foundation .BlockLiteral (* Context ), size : objc . app_kit . Size ) callconv (.C ) void {
255
+ pub fn windowDidResize (block : * objc .foundation .BlockLiteral (* Context )) callconv (.C ) void {
258
256
const core : * Core = block .context .core ;
259
- const s : Size = .{ .width = @intFromFloat (size .width ), .height = @intFromFloat (size .height ) };
260
257
261
- var window = core .windows .getValue (block .context .window_id );
262
- window .width = s .width ;
263
- window .height = s .height ;
264
- window .swap_chain_update .set ();
265
- core .windows .setValueRaw (block .context .window_id , window );
258
+ var core_window = core .windows .getValue (block .context .window_id );
259
+
260
+ if (core_window .native ) | native | {
261
+ const native_window : * objc.app_kit.Window = native .window ;
262
+
263
+ const frame = native_window .frame ();
264
+
265
+ const content_rect = native_window .contentRectForFrameRect (frame );
266
+
267
+ core_window .width = @intFromFloat (content_rect .size .width );
268
+ core_window .height = @intFromFloat (content_rect .size .height );
269
+ core_window .swap_chain_update .set ();
270
+ }
271
+
272
+ core .windows .setValueRaw (block .context .window_id , core_window );
266
273
267
274
core .pushEvent (.{ .window_resize = .{
268
275
.window_id = block .context .window_id ,
269
- .size = s ,
276
+ .size = .{ . width = core_window . width , . height = core_window . height } ,
270
277
} });
271
278
}
272
279
0 commit comments